Is this your first time here? SwingWiki is a Java Swing Developer community site with an big archive of Swing-related usenet groups and mailing lists, but also tips, tricks and articles and book reviews written by your colleagues from around the world. If you came here through a search engine and did not find what you were looking for, make sure to check the wiki table of contents.

Localizing JOptionPane labels

JOptionPane always displays standard button labels. To localize it for languages not supported by Swing, or to provide your own customized messages, just define an array of buttons. This code simulates standard dialog showQuestionMessage method with custom button and question labels. ResourceManager.get() simply returns a custom label string.

  public boolean getAnswer(String questionResource){
  Object[] yesnoOptions = {ResourceManager.get("LABEL_YES"),ResourceManager.get("LABEL_NO")};
    JOptionPane pane = new JOptionPane(
      JDialog dialog = pane.createDialog(ResourceManager.dialogParent, ResourceManager.get("LABEL_QUESTION"));;
      Object vl=pane.getValue();
      return (vl==yesnoOptions[0]);

Comments? Corrections? Contact us or Login to edit pages directly (registration is free and takes less than displaying a JLabel)
  howto/localizing_joptionpane.txt · Last modified: 2005/02/12 18:00
Recent changes | RSS changes | Table of contents | News Archive | Terms And Conditions | Register | The Quest For Software++| Ruby Resources

Sedo - Buy and Sell Domain Names and Websites project info: Statistics for project etracker� web controlling instead of log file analysis