CACHE CUSTOM JOPTIONPANES Some JDialogs use fairly complex JOptionPanes, with many components that need to be initialized each time the dialog is displayed. Rather than instantiate and place all those objects at every invocation, you can create the JOptionPane once and reuse it as needed. To do this, create a new class that extends the JOptionPane class and add all your component creation and placement code to the constructor. You can implement the Singleton pattern for the new class or just keep a reference to the instance in an accessible variable. In order to get and set the values and states for the components, you can then either add getter/setter methods or just make the relevant component instances accessible to other classes. Here's a simple example that uses a single entry field: import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.util.*; public class ReusableDialogPane extends JOptionPane { public JTextField entry = new JTextField(); public boolean isOK = false; private JDialog dialog = null; public ReusableDialogPane() { super(); JButton saveButton = new JButton(); JButton cancelButton = new JButton(); setLayout(new BorderLayout()); cancelButton.setText("Cancel"); cancelButton.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent ae){dialog.hide();}}); entry.setText(""); saveButton.setText("Save"); saveButton.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent ae){isOK=true;dialog.hide();}}); JPanel jPanel1 = new JPanel(); jPanel1.setLayout(new BorderLayout()); this.add(jPanel1, BorderLayout.SOUTH); jPanel1.add(saveButton, BorderLayout.EAST); jPanel1.add(cancelButton, BorderLayout.WEST); this.add(entry, BorderLayout.CENTER); } public void showDialog(Component parent,String title) { dialog = super.createDialog(parent,title); isOK = false; dialog.show(); dialog.dispose(); } } To use this class, create a single accessible instance and then, whenever you want to display the dialog, set the component value(s), call showDialog(), and then check the isOK variable to see if the user cancelled the dialog and, if not, read the new values from the components. Here's a demonstration application: import java.io.*; import java.util.zip.*; public class OptionPaneTest { static ReusableDialogPane pane = new ReusableDialogPane(); public static void main(String [] args) throws Exception { pane.entry.setText("test"); pane.showDialog(null,"Test Dialog"); if(pane.isOK) { System.out.println("got new value "+pane.entry.getText()); pane.entry.setText("try again"); pane.showDialog(null,"Example of reuse"); }else{ // Dialog cancelled } System.exit(0); } } ------------------------------------------