Skip to content

Commit 4194b0e

Browse files
window
1 parent d93bd00 commit 4194b0e

File tree

2 files changed

+91
-0
lines changed

2 files changed

+91
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package com.window;
2+
3+
import java.awt.Window;
4+
5+
public class TestWindows {
6+
void test1(){
7+
Window w = new Window(null);
8+
w.pack();
9+
w.setType(Window.Type.NORMAL);
10+
}
11+
12+
void test2(){
13+
Window w = new Window(null);
14+
w.setType(Window.Type.NORMAL);
15+
w.setVisible(false);
16+
w.createBufferStrategy(1);
17+
}
18+
19+
void test3(){
20+
Window w = new Window(null);
21+
w.setType(Window.Type.NORMAL);
22+
w.setVisible(true);
23+
w.dispose();
24+
w.createBufferStrategy(1);
25+
}
26+
27+
void test4(){
28+
Window w = new Window(null);
29+
w.pack();
30+
w.setType(Window.Type.NORMAL);
31+
}
32+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package com.window;
2+
3+
import java.awt.AWTKeyStroke;
4+
import java.awt.BufferCapabilities;
5+
import java.awt.Frame;
6+
import java.awt.GraphicsConfiguration;
7+
import java.awt.Window;
8+
import java.util.Set;
9+
10+
import liquidjava.specification.ExternalRefinementsFor;
11+
import liquidjava.specification.Refinement;
12+
import liquidjava.specification.StateRefinement;
13+
import liquidjava.specification.StateSet;
14+
15+
@StateSet({"displayable", "notDisplayable"})
16+
@ExternalRefinementsFor("java.awt.Window")
17+
public interface WindowRefinements{
18+
19+
@StateRefinement(to="notDisplayable(this)")
20+
void Window(Frame owner);
21+
22+
@StateRefinement(to="notDisplayable(this)")
23+
void Window(Window owner);
24+
25+
@StateRefinement(to="notDisplayable(this)")
26+
void Window(Window owner, GraphicsConfiguration gc);
27+
28+
29+
// to displayable
30+
@StateRefinement(to="displayable(this)")
31+
void addNotify(); // Makes this Window displayable by creating the connection to its native screen resource. This method is called internally by the toolkit and should not be called directly by programs.
32+
33+
@StateRefinement(to="displayable(this)")
34+
void pack(); //If the window and/or its owner are not displayable yet, both of them are made displayable
35+
36+
@StateRefinement(from="notDisplayable(this)")
37+
@StateRefinement(from="notDisplayable(this) && b",to="displayable(this)") // if its not displayable yet, is made displayable
38+
@StateRefinement(from="displayable(this)") // stays displayable
39+
void setVisible(boolean b);
40+
41+
42+
@StateRefinement(to="notDisplayable(this)")
43+
void dispose(); // makes not displayable. It can be displayed again later by calling pack().
44+
45+
@StateRefinement(from="displayable(this)")
46+
void createBufferStrategy(@Refinement("_ > 0")int numBuffers);// IllegalStateException - if the component is not displayable
47+
48+
49+
void createBufferStrategy(@Refinement("_ > 0") int numBuffers, BufferCapabilities caps);
50+
51+
@StateRefinement(from="notDisplayable(this)")
52+
void setType(Window.Type type); // Sets the type of the window. This method can only be called while the window is not displayable.
53+
54+
55+
Set<AWTKeyStroke> getFocusTraversalKeys(@Refinement("_ >= 0 && _ <= 3") int id);
56+
57+
void setOpacity(@Refinement("_ >= 0 && _ <= 1") float opacity);
58+
59+
}

0 commit comments

Comments
 (0)