importjava.awt.Button;
importjava.awt.event.ActionEvent;
importjava.awt.event.ActionListener;
importjavax.swing.JFrame;
publicclassDemo{
publicstaticvoidmain(String[]args){
Demodemo=newDemo();
demo.run();
}
publicvoidrun(){
JFrameframe=newJFrame("title1");
frame.setLayout(null);
frame.setBounds(10,10,500,300);
Buttonbutton=newButton("click");
button.setBounds(15,15,200,100);
frame.add(button);
frame.setVisible(true);
button.addActionListener(newActionListener(){
@Override
publicvoidactionPerformed(ActionEvente){
JFrameframe=newJFrame("title2");
frame.setLayout(null);
frame.setBounds(20,20,300,100);
frame.setVisible(true);
}
});
}
}
哪里不懂可以追问,很简陋的程序哈。