Java Code Examples for javax.swing.JFrame.invalidate()

The following are Jave code examples for showing how to use invalidate() of the javax.swing.JFrame class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: incubator-netbeans   File: AbstractWindowRunner.java   View Source Code Vote up 5 votes
private void ungrayMainWindow() {
    if (oldGlassPane != null) {
        JFrame jf = (JFrame) WindowManager.getDefault().getMainWindow();
        jf.setGlassPane(oldGlassPane);
        jf.getGlassPane().setVisible(false);          
        jf.invalidate();
        jf.repaint();
    }
}
 
Example 2
Project: incubator-netbeans   File: EditorOnlyDisplayer.java   View Source Code Vote up 5 votes
private boolean switchCurrentEditor() {
    final TopComponent tc = TopComponent.getRegistry().getActivated();
    if( null == tc || !TopComponentTracker.getDefault().isEditorTopComponent( tc ) )
        return false;

    final WindowManagerImpl wmi = WindowManagerImpl.getInstance();
    final JFrame mainWnd = ( JFrame ) wmi.getMainWindow();
    if( SwingUtilities.isDescendingFrom( tc, mainWnd.getContentPane() ) )
        return true;
    JPanel panel = new JPanel( new BorderLayout() );
    panel.add( tc, BorderLayout.CENTER  );
    try {
        mainWnd.setContentPane( panel );
    } catch( IndexOutOfBoundsException e ) {
        Logger.getLogger(EditorOnlyDisplayer.class.getName()).log(Level.INFO, "Error while switching current editor.", e);
        //#245541 - something is broken in the component hierarchy, let's try restoring to the default mode
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                cancel(false);
            }
        });
    }
    mainWnd.invalidate();
    mainWnd.revalidate();
    mainWnd.repaint();
    SwingUtilities.invokeLater( new Runnable() {
        @Override
        public void run() {
            tc.requestFocusInWindow();
        }
    });
    return true;
}