@@ -57,7 +57,7 @@ public class bug7154030 {
5757
5858 private static JButton button = null ;
5959 private static JFrame frame ;
60- private static int locx , locy , frw , frh ;
60+ private static volatile int locx , locy , frw , frh ;
6161
6262 public static void main (String [] args ) throws Exception {
6363 try {
@@ -76,6 +76,7 @@ public void run() {
7676 JDesktopPane desktop = new JDesktopPane ();
7777 button = new JButton ("button" );
7878 frame = new JFrame ();
79+ frame .setUndecorated (true );
7980
8081 button .setSize (200 , 200 );
8182 button .setLocation (100 , 100 );
@@ -102,12 +103,14 @@ public void run() {
102103
103104 Dimension screenSize = Toolkit .getDefaultToolkit ().getScreenSize ();
104105 Rectangle screen = new Rectangle (0 , 0 , (int ) screenSize .getWidth (), (int ) screenSize .getHeight ());
105- Rectangle bounds = frame .getBounds ();
106- Insets insets = frame .getInsets ();
107- locx = bounds .x + insets .left ;
108- locy = bounds .y + insets .top ;
109- frw = bounds .width - insets .left - insets .right ;
110- frh = bounds .height - insets .top - insets .bottom ;
106+ SwingUtilities .invokeAndWait (() -> {
107+ Rectangle bounds = frame .getBounds ();
108+ Insets insets = frame .getInsets ();
109+ locx = bounds .x + insets .left ;
110+ locy = bounds .y + insets .top ;
111+ frw = bounds .width - insets .left - insets .right ;
112+ frh = bounds .height - insets .top - insets .bottom ;
113+ });
111114
112115 BufferedImage fullScreen = robot .createScreenCapture (screen );
113116 Graphics g = fullScreen .getGraphics ();
0 commit comments