Localizing a JOptionPane

You can do so by changing the UI Look and Feel default values. The following text values are changeable:

   OptionPane.cancelButtonText
   OptionPane.noButtonText
   OptionPane.okButtonText
   OptionPane.yesButtonText

You can change them by adjusting the default value in the hashtable contained in UIManager class. The program below an example. As a side note, the other default keys that are used by JOptionPane and can be customized to fit your needs are these:

   OptionPane.background
   OptionPane.border
   OptionPane.buttonAreaBorder
   OptionPane.cancelButtonText
   OptionPane.errorIcon
   OptionPane.fontOptionPane.foreground
   OptionPane.informationIcon
   OptionPane.messageAreaBorder
   OptionPane.messageForeground
   OptionPane.minimumSize
   OptionPane.noButtonText
   OptionPane.okButtonText
   OptionPane.questionIcon
   OptionPane.warningIcon
   OptionPane.yesButtonText

Main.java:

import java.awt.event.*;
import javax.swing.*;
import java.awt.*;
 
public class Main extends JFrame
{
   public Main() {
      getContentPane().setLayout(new FlowLayout());
 
      UIManager.put("OptionPane.yesButtonText", "Ja");
      UIManager.put("OptionPane.noButtonText", "Neen");
 
      Button button = new Button("Show JOptionPane");
      button.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent e) {
            JOptionPane.showConfirmDialog(Main.this, "Does this JOptionPane " +
                "contain Dutch buttons?", "Question", JOptionPane.YES_NO_OPTION);
         }
      });
 
      getContentPane().add(button);
 
      addWindowListener(new WindowAdapter() {
         public void windowClosing(WindowEvent we) {
            System.exit(0);
         }
      });
   }
 
   public static void main(String [] args) {
      Main main = new Main();
      main.pack();
      main.setVisible(true);
   } 
}