List of usage examples for java.util ResourceBundle getString
public final String getString(String key)
From source file:Main.java
public static void main(String[] argv) throws Exception { Locale locale = Locale.getDefault(); ResourceBundle rb = ResourceBundle.getBundle("JFileChooser", locale); UIManager.put("FileChooser.lookInLabelText", rb.getString("lookInLabelText")); UIManager.put("FileChooser.filesOfTypeLabelText", rb.getString("filesOfTypeLabelText")); UIManager.put("FileChooser.upFolderToolTipText", rb.getString("upFolderToolTipText")); }
From source file:Main.java
public static void main(String[] args) { ResourceBundle bundle = ResourceBundle.getBundle("MessagesBundle", Locale.UK); System.out.println("Message in " + Locale.UK + ": " + bundle.getString("greeting")); Locale.setDefault(new Locale("in", "ID")); bundle = ResourceBundle.getBundle("MessagesBundle"); System.out.println("Message in " + Locale.getDefault() + ": " + bundle.getString("greeting")); }/*from ww w . j a v a 2 s .c o m*/
From source file:HelloResourceBundleExample.java
public static void main(String [] argv) { try {// w ww.j a v a 2 s. c om Locale frenchLocale = new Locale("fr", "FR"); ResourceBundle rb = ResourceBundle.getBundle("HelloResourceBundle", frenchLocale); System.out.println(rb.getString("Hello")); System.out.println(rb.getString("Goodbye")); } catch (MissingResourceException mre) { mre.printStackTrace(); } }
From source file:XMLResourceBundleControl.java
public static void main(String args[]) { ResourceBundle bundle = ResourceBundle.getBundle("Strings", new XMLResourceBundleControl()); String string = bundle.getString("Key"); System.out.println("Key: " + string); }
From source file:XMLResourceBundleControl.java
public static void main(String args[]) { ResourceBundle bundle = ResourceBundle.getBundle("Strings", new XMLResourceBundleControl()); String string = bundle.getString("Key"); System.out.println("Key: " + string); }
From source file:XMLResourceBundleControl.java
public static void main(String args[]) { ResourceBundle bundle = ResourceBundle.getBundle("Strings", new XMLResourceBundleControl()); String string = bundle.getString("Key"); System.out.println("Key: " + string); }/* w ww . j a va2s.com*/
From source file:Animals.java
public static void main(String[] argv) { ResourceBundle animalResources; try {/* w w w .j ava 2 s . c o m*/ animalResources = ResourceBundle.getBundle("AnimalResources", Locale.getDefault()); System.out.println(animalResources.getString("Animals")); } catch (MissingResourceException mre) { mre.printStackTrace(); } }
From source file:RBPropDemo.java
public static void main(String[] args) { ResourceBundle.clearCache();// w w w. java 2 s. c o m String bundleName = "myproj.MyResources"; ResourceBundle myResources = ResourceBundle.getBundle(bundleName, Locale.GERMAN); System.out.println("Key's values:"); System.out.println(myResources.getString("okKey")); System.out.println(myResources.getString("cancelKey")); System.out.println(myResources.getString("submitKey")); System.out.println("\nChecking okKey in resource bundle:"); if (myResources.containsKey("okKey")) { System.out.println("okKey exists! " + " Value = " + myResources.getString("okKey")); } else { System.out.println("The key Doesn't Exist"); } System.out.println("\nGet a set of keys:"); Set<String> keySet = myResources.keySet(); Object[] keys = keySet.toArray(); for (int i = 0; i < keys.length; i++) { System.out.println("Key " + (i + 1) + " = " + keys[i]); } }
From source file:JOptionPaneDemonstrationLocalized.java
public static void main(String[] argv) { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); Font unicodeFont = new Font("LucidaSans", Font.PLAIN, 12); ResourceBundle bundle = ResourceBundle.getBundle("JOptionPaneResources", Locale.getDefault()); String[] textMessages = new String[3]; textMessages[0] = bundle.getString("Yes"); textMessages[1] = bundle.getString("No"); textMessages[2] = bundle.getString("Cancel"); JOptionPane jop = new JOptionPane(bundle.getString("MessageText"), JOptionPane.ERROR_MESSAGE, JOptionPane.YES_NO_CANCEL_OPTION, null, textMessages); JDialog jopDialog = jop.createDialog(null, bundle.getString("TitleText")); jop.setFont(unicodeFont);/*from w ww. ja va2s .com*/ jopDialog.setVisible(true); Object userSelection = jop.getValue(); }
From source file:net.java.sen.tools.MkCompoundTable.java
/** * Build compound word table./*from w w w.ja v a 2 s . c o m*/ */ public static void main(String args[]) { ResourceBundle rb = ResourceBundle.getBundle("dictionary"); int pos_start = Integer.parseInt(rb.getString("pos_start")); int pos_size = Integer.parseInt(rb.getString("pos_size")); try { log.info("reading compound word information ... "); HashMap compoundTable = new HashMap(); log.info("load dic: " + rb.getString("compound_word_file")); BufferedReader dicStream = new BufferedReader(new InputStreamReader( new FileInputStream(rb.getString("compound_word_file")), rb.getString("dic.charset"))); String t; int line = 0; StringBuffer pos_b = new StringBuffer(); while ((t = dicStream.readLine()) != null) { CSVParser parser = new CSVParser(t); String csv[] = parser.nextTokens(); if (csv.length < (pos_size + pos_start)) { throw new RuntimeException("format error:" + line); } pos_b.setLength(0); for (int i = pos_start; i < (pos_start + pos_size - 1); i++) { pos_b.append(csv[i]); pos_b.append(','); } pos_b.append(csv[pos_start + pos_size - 1]); pos_b.append(','); for (int i = pos_start + pos_size; i < (csv.length - 2); i++) { pos_b.append(csv[i]); pos_b.append(','); } pos_b.append(csv[csv.length - 2]); compoundTable.put(pos_b.toString(), csv[csv.length - 1]); } dicStream.close(); log.info("done."); log.info("writing compound word table ... "); ObjectOutputStream os = new ObjectOutputStream( new FileOutputStream(rb.getString("compound_word_table"))); os.writeObject(compoundTable); os.close(); log.info("done."); } catch (Exception e) { e.printStackTrace(); System.exit(1); } }