一个很吊的swing循环生成窗口。
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(); } }
这个程序可以循环生成自己
下面为效果图