AWT / NOTES</>↗AWT20 Jan 2007
package org.kodejava.awt; import java.awt.GraphicsEnvironment; public class FontFamilyNameList { public static void main(String[] args) { // Get all available font family names from GraphicsEnvironment GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); String[] familyNames = ge.getAvailableFontFamilyNames(); // Iterates familyNames array to display the available font's family names for (String familyName : familyNames) { System.out.println("Family nam...
AWT / NOTES</>↗AWT16 Jan 2007
package org.kodejava.awt; import java.awt.Font; import java.awt.GraphicsEnvironment; public class FontNameList { public static void main(String[] args) { // Get all available fonts from GraphicsEnvironment GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); Font[] fonts = ge.getAllFonts(); // Iterates all available fonts and get their name and family name for (Font font : fonts) { String fontName = font.getName(); String familyName […]
CORE API / NOTES</>↗Core API13 Jan 2007
package org.kodejava.text; import java.util.Locale; import java.text.NumberFormat; import java.text.ParseException; public class LocaleNumberParse { public static void main(String[] args) { try { // In this example we are trying to parse a number string in a // defined format. Basically we want to covert the string for a // locale into a correct number value. Number number […]
CORE API / NOTES</>↗Core API12 Jan 2007
package org.kodejava.text; import java.util.Locale; import java.text.NumberFormat; public class LocaleNumberFormat { public static void main(String[] args) { // Format number for Italy locale. In Italy locale the decimal point // symbol is a comma. NumberFormat formatter = NumberFormat.getNumberInstance(Locale.ITALY); try { String number = formatter.format(195325.75); System.out.println("Number in Italy: " + number); } catch (NumberFormatException e) { e.printStackTrace(); […...
CORE API / NOTES</>↗Core API11 Jan 2007
package org.kodejava.text; import java.text.CharacterIterator; import java.text.StringCharacterIterator; public class IterateSubstringExample { private static final String text = "How razorback-jumping frogs can level six piqued gymnasts"; public static void main(String[] args) { CharacterIterator it = new StringCharacterIterator(text, 4, 27, 5); // In this loop we just iterator a subset of character defined in the // StringCharacterIterator above. […]
CORE API / NOTES</>↗Core API08 Jan 2007
In this example we use the java.text.CharacterIterator implementation class java.text.StringCharacterIterator to reverse a string. It’s done by reading a string from the last index up to the beginning of the string. package org.kodejava.text; import java.text.CharacterIterator; import java.text.StringCharacterIterator; public class StringCharacterIteratorReverseExample { private static final String text = "Jackdaws love my big sphinx of quartz"; public […]