Index: src/com/sun/rave/windowmgr/MainWindow.java =================================================================== RCS file: /rave/winsys/windowmgr/src/com/sun/rave/windowmgr/MainWindow.java,v retrieving revision 1.16 diff -u -r1.16 MainWindow.java --- src/com/sun/rave/windowmgr/MainWindow.java 2004/05/25 01:15:36 1.16 +++ src/com/sun/rave/windowmgr/MainWindow.java 2004/10/26 15:59:56 @@ -11,20 +11,17 @@ package com.sun.rave.windowmgr; +import java.awt.AWTEvent; import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.Graphics; import java.awt.Image; -import java.awt.Toolkit; import java.awt.Rectangle; +import java.awt.event.PaintEvent; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; +import java.awt.image.BufferedImage; -import java.net.URL; - -import java.util.Locale; - -import javax.swing.ImageIcon; import javax.swing.JComponent; import javax.swing.JFrame; import javax.swing.JPanel; @@ -39,11 +36,8 @@ import org.openide.filesystems.Repository; import org.openide.util.HelpCtx; import org.openide.util.NbBundle; -import org.openide.util.SharedClassObject; import org.openide.util.Utilities; -import org.openide.ErrorManager; - //import com.sun.rave.plaf.LookAndFeelFactory; import org.openide.util.RequestProcessor; @@ -168,15 +162,58 @@ firePropertyChange(ABOUT_TO_SHOW, null, null); } + public Graphics getGraphics() { + // Return the dummy graphics that paint nowhere, until we receive a paint() + if (waitingForPaintDummyGraphic != null) { + // If we are the PaintEvent we are waiting for is being dispatched + // we better return the correct graphics. + AWTEvent event = EventQueue.getCurrentEvent(); + if (event == null || (event.getID() != PaintEvent.PAINT && event.getSource() != this)) { + return waitingForPaintDummyGraphic; + } + releaseWaitingForPaintDummyGraphic(); + } + return super.getGraphics(); + } + + public void paint(Graphics g) { + // As a safeguard, always release the dummy graphic when we get a paint + if (waitingForPaintDummyGraphic != null) { + releaseWaitingForPaintDummyGraphic(); + // Since the release did not occur before the getGraphics() call, + // I need to get the actual graphics now that I've released + g = getGraphics(); + } + super.paint(g); + } + public void setLayoutPane(JComponent layoutPane){ getContentPane().add(layoutPane, BorderLayout.CENTER); } + + protected Image waitingForPaintDummyImage; + protected Graphics waitingForPaintDummyGraphic; - public void showWindow(){ + public void showWindow() { + // The setVisible will cause a PaintEvent to be queued up, as a LOW_PRIORITY one + // As the painting of my child components occurs, they cause painting of their own + // When the PaintEvent queued from the setVisible is finally processed, it assumes + // nothing has been displayed and redraws the whole window. + // So we make it such that, UNTIL there is the repaint is dispatched, return a graphics + // which goes nowhere. + waitingForPaintDummyImage = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB); + waitingForPaintDummyGraphic = waitingForPaintDummyImage.getGraphics(); setVisible(true); - //mainWindowShowing = true; } + protected void releaseWaitingForPaintDummyGraphic() { + if (waitingForPaintDummyGraphic != null) { + waitingForPaintDummyGraphic.dispose(); + waitingForPaintDummyGraphic = null; + waitingForPaintDummyImage = null; + } + } + private boolean enableFixedSwitcher() { FileObject fo = Repository.getDefault().getDefaultFileSystem(). findResource("Toolbars/WorkspaceSwitcher"); // NOI18N Index: src/com/sun/rave/windowmgr/toolbars/ToolbarProcessor.java =================================================================== RCS file: /rave/winsys/windowmgr/src/com/sun/rave/windowmgr/toolbars/ToolbarProcessor.java,v retrieving revision 1.2 diff -u -r1.2 ToolbarProcessor.java --- src/com/sun/rave/windowmgr/toolbars/ToolbarProcessor.java 2003/10/17 21:36:38 1.2 +++ src/com/sun/rave/windowmgr/toolbars/ToolbarProcessor.java 2004/10/26 15:59:56 @@ -10,8 +10,8 @@ import java.io.IOException; import org.openide.loaders.XMLDataObject; -import org.openide.cookies.InstanceCookie; import org.openide.util.WeakListener; +import org.openide.cookies.InstanceCookie; /** * ToolbarProcessor is cookie of XMLDataObject which creates ToolbarConfiguration.