在按钮事件里让JFrame消失(dispose()方法),然后让你的JDialog显示出来就行了
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
this.dispose();
new NewJDialog().setVisible(true);
}
改一下你的getJButton方法:
private JButton getJButton() {
if (jButton == null) {
jButton = new JButton();
jButton.setBounds(new Rectangle(61, 55, 69, 28));
jButton.setText("dialog");
jButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
System.out.println("actionPerformed()"); // TODO
getJDialog().setVisible(true);//获得Dialog对象后设置它为可见
}
});
}
return jButton;
}