CORE API / NOTES</>↗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 / NOTES</>↗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 / NOTES</>↗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 / NOTES</>↗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, […]
BASIC / NOTES</>↗Basic26 Sep 2010
The exceptions that you catch in a try-catch block must have been raised by a method that you’ve called. You can raise an exception with a statement that consists of the throw keyword, followed by an exception object. This exception object is an instance of any subclass of the Throwable class. In the example below […]
BASIC / NOTES</>↗Basic25 Sep 2010
If a try block can throw several kind of exceptions, and you want to handle each exception differently, you can put several catch blocks to handle it. package org.kodejava.basic; public class MultipleCatchExample { public static void main(String[] args) { int[] numbers1 = {1, 2, 3, 4, 5}; int[] numbers2 = {1, 2, 3, 4, 5, […]