JAVA Swing窗口在桌面上浮动
2012-02-15
0
1 class Util {
2 private Toolkit tool;
3 private int width;
4 private int height;
5 private int screenWidth;
6 private int screenHeight;
7 private int leftMargin;
8 private int topMargin;
9 private static JFrame win;
10 enum X {LEFT, RIGHT};
11 enum Y {UP, DOWN};
12 public Util(JFrame win, int width, int height) {
13 Util.win = win;
14 this.width = width;
15 this.height = height;
16 tool = win.getToolkit();
17 this.screenWidth = tool.getScreenSize().width;
18 this.screenHeight = tool.getScreenSize().height;
19 Util.win.setVisible(true);
20 Util.win.addKeyListener(new KeyAdapter() {
21 @Override
22 public void keyPressed(KeyEvent e) {
23 //