Java Code Examples for org.openide.windows.TopComponent#add()

The following examples show how to use org.openide.windows.TopComponent#add() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Utils.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Shows given Scene wrapped in TopComponent and JFrame.
 * @param scene Scene to be shown
 * @return TopComponent instance where scene resides
 */
public static TopComponent showScene(Scene scene) {
    JComponent sceneView = scene.getView();
    if (sceneView == null) {
        sceneView = scene.createView();
    }
    int width = 450, height = 250;
    JFrame frame = new JFrame("Test Scene");
    TopComponent tc = new TopComponent();
    tc.setLayout(new BorderLayout());
    tc.add(sceneView);
    frame.add(tc);
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
    frame.setBounds((screenSize.width - width) / 2, (screenSize.height - height) / 2, width, height);
    frame.setVisible(true);
    return tc;
}
 
Example 2
Source File: LaoutPreviewTopComponent.java    From NBANDROID-V2 with Apache License 2.0 6 votes vote down vote up
static void showLaoutPreview(JPanel panel, String name) {
    WindowManager wm = WindowManager.getDefault();
    TopComponent topComponent = wm.findTopComponent("LaoutPreviewTopComponent"); // NOI18N
    if (topComponent == null) {
        topComponent = new LaoutPreviewTopComponent();
    }
    if (topComponent instanceof LaoutPreviewTopComponent) {
        if (!topComponent.isOpened()) {
            Mode mode = wm.findMode("commonpalette");
            if (mode != null) {
                mode.dockInto(topComponent);
            }
            topComponent.removeAll();
            if (panel != null) {
                topComponent.add(panel);
            }
            topComponent.updateUI();
            topComponent.setName("Laout Preview [" + name + "]");
            topComponent.setToolTipText("Laout Preview [" + name + "]");
            topComponent.open();
        }
    }

}
 
Example 3
Source File: PerfWatchProjects.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public static void assertTextDocuments() throws Exception {
    closeTopComponents();
    Thread.sleep(2000);
            TopComponent tc = new TopComponent();
            tc.setLayout(new FlowLayout());
            tc.add(new JTextArea());
            tc.open();
            tc.requestVisible();
            tc.requestActive();
            String jVMversion = System.getProperty("java.specification.version");
            System.out.println("Java.specification.version="+jVMversion);
            if (!("1.8".equals(jVMversion))) {
                try {
                    System.out.println("Cleaning well known static fields");
                    cleanWellKnownStaticFields();
                } catch (Exception ex) {
                    throw new IllegalStateException(ex);
                }
            }
            System.setProperty("assertgc.paths", "0");
            try {
                Thread.sleep(4000);
            } catch (InterruptedException exc) {
                Exceptions.printStackTrace(exc);
            }
            try {
                Log.assertInstances("Are all documents GCed?", "TextDocument");
            } catch (AssertionFailedError afe) {
                throw afe;
            } finally {
                dumpHeap(null);
            }
}
 
Example 4
Source File: PagePanel.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
protected void showAlternativeView() {
    final TopComponent parent = (TopComponent) this.getParent();
    parent.remove(this);
    this.setVisible(false);
    parent.add(alternativeView, BorderLayout.CENTER);
    alternativeView.setVisible(true);
    parent.revalidate();
}
 
Example 5
Source File: MetadataPlotTopComponent.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void showAlternativeView() {
    // this is overridden to avoid the clearance of the MetadataPlotPanel when
    // switching back from the MetadataTableViewPagePanel
    final TopComponent parent = (TopComponent) this.getParent();
    parent.remove(this);
    this.setVisible(false);
    final PagePanel alternativeView = getAlternativeView();
    alternativeView.handleLayerContentChanged();
    parent.add(alternativeView, BorderLayout.CENTER);
    alternativeView.setVisible(true);
    parent.revalidate();

}