-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwindowSizeControl.java
More file actions
87 lines (67 loc) · 2.56 KB
/
Copy pathwindowSizeControl.java
File metadata and controls
87 lines (67 loc) · 2.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import java.awt.Frame;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsEnvironment;
import java.awt.Insets;
import java.awt.LayoutManager;
import java.awt.Toolkit;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class samp
{
static GraphicsConfiguration gc = new Frame().getGraphicsConfiguration();
public static void main(String args[]) throws InterruptedException
{
System.out.println(Toolkit.getDefaultToolkit().getScreenSize());
int height=Toolkit.getDefaultToolkit().getScreenSize().height;
int width=Toolkit.getDefaultToolkit().getScreenSize().width;
int UseWidth= GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds().width;
int UseHeight=GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds().height;
int midWidth= UseWidth/2;
int midHeight=UseHeight/2;
int currentHeight;
int currentWidth;
JFrame frame = new JFrame("Test");
frame.setVisible(true);
JLabel label=new JLabel();
frame.add(label);
// Insets ins= Toolkit.getDefaultToolkit().getScreenInsets(gc);
// System.out.println(ins);
// frame.setSize(500,200);
frame.setBounds(0,0,UseWidth/2,UseHeight/2);
currentHeight=frame.getSize().height;
currentWidth=frame.getSize().width;
label.setText("Quad 1");
Thread.sleep(1000);
frame.setBounds(UseWidth/2,0,UseWidth/2,UseHeight/2);
label.setText("Quad 2");
Thread.sleep(1000);
frame.setBounds(0,UseHeight/2,UseWidth/2,UseHeight/2);
label.setText("Quad 3");
Thread.sleep(1000);
frame.setBounds(UseWidth/2,UseHeight/2,UseWidth/2,UseHeight/2);
label.setText("Quad 4");
Thread.sleep(1000);
frame.setBounds(midWidth-currentWidth/2,midHeight-currentHeight/2,currentWidth,currentHeight);
label.setText("Center");
Thread.sleep(1000);
frame.setBounds(0,0,midWidth,UseHeight);
label.setText("Left");
Thread.sleep(1000);
frame.setBounds(midWidth,0,midWidth,UseHeight);
label.setText("Right");
Thread.sleep(1000);
frame.setBounds(0,0,UseWidth,midHeight);
label.setText("Top");
Thread.sleep(1000);
currentHeight=frame.getSize().height;
currentWidth=frame.getSize().width;
frame.setBounds(midWidth-currentWidth/2,midHeight-currentHeight/2,currentWidth,currentHeight);
label.setText("Center");
Thread.sleep(1000);
frame.setBounds(0,midHeight,UseWidth,midHeight);
label.setText("Bottom");
Thread.sleep(1000);
//frame.setBounds(arg0, arg1, arg2, arg3);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}