The Java version of Neil's example is very similar.The Button class
public class Button1 extends Button {
private MyForm myForm = null;
@Override
public void onClick() throws IOException, AutomationException {
if(myForm == null){
myForm = MyForm.getInstance();
}
myForm.setVisible(true);
}
}
The Form class
public class MyForm extends JFrame {
private JPanel contentPane;
private static MyForm instance = null;
public static MyForm getInstance(){
if(instance == null){
instance = new MyForm();
}
return instance;
}
/**
* Create the frame.
*/
public MyForm() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
contentPane.setLayout(new BorderLayout(0, 0));
setContentPane(contentPane);
}
// handle closing of the form, maybe dispose on close...
}