import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.lang.*;
public class test{
public static void main(String [] agur){
testFrame frame = new testFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
class testFrame extends JFrame{
testFrame(){
super.setTitle("java a test");
super.setSize(800,800);
jp j = new jp();
add(j);
}
}
class jp extends JPanel implements MouseListener{
private static int Max=0;
private static int []pointx = new int[100];
private static int []pointy = new int[100];
private final static int sizeX = 80;
private final static int sizeY = 80;
jp(){
this.addMouseListener(this);
for(int i=0;i<100;i++){
pointx[i] = (int)Math.round(Math.random()*1000);
pointy[i] = (int)Math.round(Math.random()*1000);
}
}
public void mousePressed(MouseEvent e){
Max++;
testgame t = new testgame(pointx[Max],pointy[Max],sizeX,sizeY);
t.setVisible(true);
t.setResizable(false);
}
public void mouseReleased(MouseEvent e){}
public void mouseEntered(MouseEvent e){}
public void mouseExited(MouseEvent e){}
public void mouseClicked(MouseEvent e){}
}
class testgame extends JFrame implements WindowListener {
private static int a;
private static int b;
private static int c;
private static int d;
private JLabel jla = new JLabel();
private static int tem=0;
testgame(int a,int b,int c,int d){
this.a = a;
this.b = b;
this.c = c;
this.d = d;
setTitle("aaaaaaaa");
super.setBounds(a,b,c,d);
jla.setText(""+tem);
add(jla,BorderLayout.CENTER);
tem++;
this.addWindowListener(this);
}
public void windowClosing(WindowEvent e){
JOptionPane.showMessageDialog(null, "不能退出!", "信息提示!",JOptionPane.ERROR_MESSAGE);
}
public void windowOpened(WindowEvent e){}
public void windowIconified(WindowEvent e){}
public void windowDeiconified(WindowEvent e){}
public void windowClosed(WindowEvent e){}
public void windowActivated(WindowEvent e){}
public void windowDeactivated(WindowEvent e){}
}
我建议你还是先看看软件建模UML吧。。。
这是一个简单订单系统的领域类图