This is the intended behavior (assuming you're on windows).
  For every repaint the window is re-rendered into a buffer which
  is then copied into the layered GDI window.

  Thanks,
    Dmitri


jav...@javadesktop.org wrote:
There seems to be a performance issue for non-opaque windows (Java6u10 or 
above). The test case below demonstrates the issue. As soon as the mouse moves 
over the button the red panel will be repainted. Is this the correct behavior 
or is there a way to minimize repaints? If the window is opaque everything 
works fine. Unnecessary repaints are a big problem for real apps with many 
components because the whole app performance slows extremely down.

[code]
public class NonOpaqueWindowRepaintTest extends JFrame
{
  public NonOpaqueWindowRepaintTest()
  {
super(); setLayout(new FlowLayout()); JPanel p = new JPanel(){
      @Override
      protected void paintComponent(Graphics g){
        System.err.println("Red panel repaint - " + g.getClipBounds());
        super.paintComponent(g);
      }
    };
    p.setBorder(new LineBorder(Color.GREEN));
    p.setBackground(Color.RED);
    p.setPreferredSize(new Dimension(200,200));
    add(p);
    add(new JButton("Test"));

    setWindowNonOpaque(this);

    setTitle(getClass().getSimpleName());
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(400, 300); setLocationRelativeTo(null);
    setVisible(true);
  }
private void setWindowNonOpaque(Window w)
  {
try {
      Class<?> c = Class.forName("com.sun.awt.AWTUtilities");
      Method m = c.getMethod("setWindowOpaque", Window.class, boolean.class);
      m.invoke(null, w, false);
} catch (Exception e) {
      e.printStackTrace();
} }

  public static void main(String[] args) throws Exception
  {
    EventQueue.invokeLater(new Runnable(){
      public void run()
      {
        JFrame.setDefaultLookAndFeelDecorated(true);
        new NonOpaqueWindowRepaintTest();
} }); } }
[/code]

Thanks,
Wolfgang
[Message sent by forum member 'wzberger' (wzberger)]

http://forums.java.net/jive/thread.jspa?messageID=321379

===========================================================================
To unsubscribe, send email to lists...@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
lists...@java.sun.com and include in the body of the message "help".

===========================================================================
To unsubscribe, send email to lists...@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
lists...@java.sun.com and include in the body of the message "help".

Reply via email to