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

The following examples show how to use org.openide.windows.TopComponent#setLayout() . 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: 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);
            }
}