Why does this code don't work properly.
The screen always flips between een with screen with a green rectangle and my windows desktop with a green rectangle
tankx
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
| .....
Rectangle bounds = mainFrame.getBounds(); try { System.out.println("1.."); gd.setFullScreenWindow(mainFrame); System.out.println("2.."); mainFrame.createBufferStrategy(2); BufferStrategy bufferStrategy = mainFrame.getBufferStrategy(); for(int i=0;i<10;i++) { Graphics g = bufferStrategy.getDrawGraphics(); g.setColor(Color.black); g.fillRect(0,0,bounds.width, bounds.height); g.setColor(Color.green); g.fillRect(i,i,i+30, i+30); bufferStrategy.show(); g.dispose(); try { Thread.sleep(1000); } catch (InterruptedException e) {} } System.out.println("4.."); } finally { gd.setFullScreenWindow(null); System.out.println("3.."); } ..... |