BASIC / CATATAN</>↗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 / CATATAN</>↗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 […]
CORE API / CATATAN</>↗Core API30 Sep 2010
This example show you how to convert a raw IP address, an array of byte, returned by InetAddress.getAddress() method call to its string representation. package org.kodejava.net; import java.net.InetAddress; import java.net.UnknownHostException; public class RawIPToString { public static void main(String[] args) { byte[] ip = new byte[0]; try { InetAddress address = InetAddress.getLocalHost(); ip = address.getAddress(); } […]
SWING / CATATAN</>↗Swing28 Sep 2010
To create a vertical JSlider set the orientation on the JSlider‘s constructor to JSlider.VERTICAL. If you do not pass JSlider.VERTICAL as a constructor parameter use the setOrientation() method instead. package org.kodejava.swing; import javax.swing.*; import java.awt.*; public class JSliderVertical extends JPanel { public JSliderVertical() { initializeUI(); } public static void showFrame() { JPanel panel = new […]
SWING / CATATAN</>↗Swing28 Sep 2010
This simple example show you how to use the JSlider component. A JSlider component is intended to let the user easily enter a numeric value bounded by a minimum and maximum value. There are a couples properties that you need to set when creating a JSlider. These include setting setMinorTickSpacing(), setMajorTickSpacing(), setPaintTicks() and setPaintLabels(). These […]
SWING / CATATAN</>↗Swing27 Sep 2010
To create a scrollable JTable component we have to use a JScrollPane as the container of the JTable. Besides, that we also need to set the table auto resize mode to JTable.AUTO_RESIZE_OFF so that a horizontal scroll bar displayed by the scroll pane when needed. If we do not turn off the auto resize mode, […]