CORE API / CATATAN</>↗Core API08 Sep 2010
We can use the java.text.Collator class to sort strings in language-specific order. Using the java.text.Collator class makes the string not just sorted by the ASCII code of their characters, but it will follow the language natural order of the characters. If the predefined collation rules do not meet your needs, you can design your own […]
SWING / CATATAN</>↗Swing06 Sep 2010
To create an instance of a JColorChooser with a default or initial color such as Color.BLUE you can pass the Color object to the constructor of the JColorChooser component. The example below shows how to do it. package org.kodejava.swing; import javax.swing.*; import java.awt.*; public class JColorChooserDefaultColor extends JFrame { public JColorChooserDefaultColor() throws HeadlessException { initializeUI(); […]
SWING / CATATAN</>↗Swing05 Sep 2010
To get the selected color from JColorChooser we need to create an implementation of the ChangeListener interface. This interface provides a single method call stateChanged(ChangeEvent e). The instance of this interface implementation need to be passed to JColorChooser by calling the JColorChooser.getSelectionModel().addChangeListener() method. In this example our ChangeListener implementation get the selected color and replace […]
SWING / CATATAN</>↗Swing01 Sep 2010
The JColorChooser is a Swing component that provides a palette from where we can select a color code in RGB format. The JColorChooser component has two parts, the tabbed pane of color selection and a preview box. The tabbed has three tabs which allows us to select a color from a swatches, a HSB (Hue, […]
CORE API / CATATAN</>↗Core API27 Agt 2010
package org.kodejava.text; import java.text.DateFormatSymbols; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; public class ChangeDateFormatSymbols { public static void main(String[] args) { Locale id = new Locale("in", "ID"); String pattern = "EEEE, dd MMM yyyy"; Date today = new Date(); // Gets formatted date specify by the given pattern for // Indonesian Locale no changes for default […]
CORE API / CATATAN</>↗Core API25 Agt 2010
If you want to change formatting styles provided by DateFormat, you can use SimpleDateFormat class. The SimpleDateFormat class is locale-sensitive. If you instantiate SimpleDateFormat without a Locale parameter, it will format the date and time according to the default Locale. Both the pattern and the Locale determine the format. For the same pattern, SimpleDateFormat may […]