Set JOptionPane button labels to French in Java

Description

The following code shows how to set JOptionPane button labels to French.

Example


//  w  ww.  j  ava 2 s . c  o  m
   
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.UIManager;

public class Main {
  public static void main(final String[] args) {

    UIManager.put("OptionPane.cancelButtonText", "Annuler");
    UIManager.put("OptionPane.noButtonText", "Non");
    UIManager.put("OptionPane.okButtonText", "D'accord");
    UIManager.put("OptionPane.yesButtonText", "Oui");

    JFrame parent = new JFrame();

    
    String multiLineMsg[] = { "Hello,", "World"} ;
    JOptionPane.showMessageDialog(parent, multiLineMsg);
  }
}

The code above generates the following result.

Set JOptionPane button labels to French in Java




















Home »
  Java Tutorial »
    Swing »




Action
Border
Color Chooser
Drag and Drop
Event
Font Chooser
JButton
JCheckBox
JComboBox
JDialog
JEditorPane
JFileChooser
JFormattedText
JFrame
JLabel
JList
JOptionPane
JPasswordField
JProgressBar
JRadioButton
JScrollBar
JScrollPane
JSeparator
JSlider
JSpinner
JSplitPane
JTabbedPane
JTable
JTextArea
JTextField
JTextPane
JToggleButton
JToolTip
JTree
Layout
Menu
Timer