SWING / NOTES</>↗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 / NOTES</>↗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 / NOTES</>↗Core API27 Aug 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 / NOTES</>↗Core API25 Aug 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 […]
CORE API / NOTES</>↗Core API20 Aug 2010
The DateFormat class allows you to format dates and times with predefined styles in a locale-sensitive manner. Formatting dates or times with the DateFormat class is a two-step process. First, you create a formatter with the getDateInstance() method for formatting date or getTimeInstance() method for formatting time or getDateTimeInstance() when you want formatting both date […]
CORE API / NOTES</>↗Core API15 Aug 2010
This example show you how to change the currency symbol for the defined locale using the DecimalFormatSymbols.setCurrencySymbol() method. After changing the currency symbol, the DecimalFormatSymbols instance is passed to the DecimalFormat object which does the formatting. package org.kodejava.text; import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; import java.text.NumberFormat; import java.util.Locale; public class CurrencyFormatSymbols { public static vo...