BASIC / NOTES</>↗Basic03 Oct 2010
A class is a specification or blueprint from which individual objects are created. A class contains fields that represent the object’s states and methods that defines the operations that are possible on the objects of the class. The file name that contains the definition of a class is always the same as the public class […]
SWING / NOTES</>↗Swing03 Oct 2010
On a normal JSlider the value range displayed left-to-right on a horizontal JSlider and bottom-to-top on vertical JSlider. To reverse the slider values from their normal order you can use the setInverted() method of the JSlider instance. Passing a true boolean value into this method call reverse the values order. package org.kodejava.swing; import javax.swing.*; import […]
SWING / NOTES</>↗Swing03 Oct 2010
The JSlider‘s setLabelTable() method allows you to define a custom labels for the JSlider. The label table is a Hashtable that contains an Integer number as the keys and a JLabel component as their values. The integer keys correspond to the JSlider tick where the labels will be customized. package org.kodejava.swing; import javax.swing.*; import java.awt.*; […]
SWING / NOTES</>↗Swing03 Oct 2010
The JSlider‘s setSnapToTicks() method call is used to move JSlider‘s knob to the nearest tick mark from where you positioned the knob. The default value of this property is false. To make it snap to the closest tick set this property to true. package org.kodejava.swing; import javax.swing.*; import java.awt.*; public class SnapToTickJSlider extends JPanel { […]
BASIC / NOTES</>↗Basic30 Sep 2010
You can define your own exception class for your application specific purposes. The exception class is created by extending the java.lang.Exception class for checked exception or java.lang.RuntimeException for unchecked exception. By creating your own Exception classes, you could identify the problem more precisely. package org.kodejava.basic; public class CustomExceptionExample { public static void main(String[] args) { […]
BASIC / NOTES</>↗Basic30 Sep 2010
By throwing a checked exception, you force the caller to handle the exception in a catch block. If a method throws a checked exception, it must declare that it throw the exception in the method declaration. All exceptions are checked exceptions, except for those indicated by java.lang.Error, java.lang.RuntimeException, and their subclasses. Runtime exception are exceptional […]