发布网友 发布时间:2022-10-16 02:45
共1个回答
热心网友 时间:2023-10-15 00:30
import javax.swing.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class popupWindows{
JFrame mainWindow;
public popupWindows(){
mainWindow = new JFrame("pop up window");
//mainWindow.setBounds(10,10,10,10);
JButton JB = new JButton("PopUp");
JB.addActionListener(new creatNewWindow());
mainWindow.setVisible(true);
mainWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
mainWindow.add(JB);
mainWindow.pack();
}
class creatNewWindow implements ActionListener{
public void actionPerformed(ActionEvent e){
new popupWindows().mainWindow.setBounds(100,100,100,100);
}
}
public static void main(String[] args){
new popupWindows();
}
}