Example usage for java.awt Frame setVisible

List of usage examples for java.awt Frame setVisible

Introduction

In this page you can find the example usage for java.awt Frame setVisible.

Prototype

public void setVisible(boolean b) 

Source Link

Document

Shows or hides this Window depending on the value of parameter b .

Usage

From source file:de.prozesskraft.pkraft.Createdoc.java

/**
 * Create contents of the window.//from w ww. ja  v  a 2 s .c o m
 */
protected static void createContents(PmodelViewPage page) {
    shell = new Shell();
    shell.setSize(3500, 1500);
    shell.setText("SWT Application");
    shell.setLayout(new GridLayout(1, false));

    Composite composite = new Composite(shell, SWT.NONE);

    GridData gd_composite = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
    gd_composite.minimumWidth = 10;
    gd_composite.minimumHeight = 10;
    composite.setLayoutData(gd_composite);
    composite.setLayout(new GridLayout(1, false));

    Composite composite2 = new Composite(composite, SWT.EMBEDDED | SWT.NO_BACKGROUND);
    GridData gd_composite2 = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
    gd_composite2.minimumWidth = 10;
    gd_composite2.minimumHeight = 10;
    composite2.setLayoutData(gd_composite2);

    Frame frame = SWT_AWT.new_Frame(composite2);

    //      Label lblNewLabel = new Label(composite, SWT.BORDER);
    //      lblNewLabel.setBounds(100, 10, 66, 17);
    //      lblNewLabel.setText("sxsdsds");

    frame.add(page, BorderLayout.CENTER);
    page.init();
    frame.pack();
    frame.setLocation(0, 0);
    frame.setVisible(true);

    page.refresh();
}

From source file:CustomAlphaTest.java

protected void addCanvas3D(Canvas3D c3d) {
    Frame frame = new Frame("Custom Alpha Test");

    Panel aPanel = new Panel();
    aPanel.setLayout(new BorderLayout());
    aPanel.add(c3d, BorderLayout.CENTER);

    frame.add(aPanel);//from   ww w  . j  a v  a  2  s . co m

    frame.pack();
    frame.setSize(new Dimension(320, 320));
    frame.validate();
    frame.setVisible(true);

    doLayout();
}

From source file:LightTest.java

protected void createLight(LightObject light, BranchGroup objRoot) {
    Frame frame = new Frame(light.getName());
    Panel aPanel = new Panel();
    frame.add(aPanel);//from ww w  .ja  v a 2 s. com
    light.addUiToPanel(aPanel);
    frame.pack();
    frame.setSize(new Dimension(400, 250));
    frame.validate();
    frame.setVisible(true);

    // add the geometry that depicts the light
    // to the scenegraph
    objRoot.addChild(light.createGeometry());

    // finally add the light itself to the scenegraph
    objRoot.addChild(light.getLight());
}

From source file:gdsc.core.ij.Utils.java

/**
 * Show the plot. Replace a currently open plot with the specified title or else create a new plot window.
 *
 * @param title//w  w w  .  j  a  va 2 s .  co m
 *            the title
 * @param plot
 *            the plot
 * @param preserveLimits
 *            Use flags to preserve the current limits of an existing plot
 * @return the plot window
 */
public static PlotWindow display(String title, Plot plot, int preserveLimits) {
    newWindow = false;
    Frame plotWindow = null;
    int[] wList = WindowManager.getIDList();
    int len = wList != null ? wList.length : 0;
    for (int i = 0; i < len; i++) {
        ImagePlus imp = WindowManager.getImage(wList[i]);
        if (imp != null && imp.getWindow() instanceof PlotWindow) {
            if (imp.getTitle().equals(title)) {
                plotWindow = imp.getWindow();
                break;
            }
        }
    }
    PlotWindow p = null;
    if (plotWindow == null) {
        p = plot.show();
        newWindow = true;
    } else {
        // Since the new IJ 1.50 plot functionality to have scalable plots this can sometimes error
        try {
            plotWindow.setVisible(true);
            p = (PlotWindow) plotWindow;
            Plot oldPlot = p.getPlot();
            Dimension d = oldPlot.getSize();
            double[] limits = oldPlot.getLimits();
            plot.setSize(d.width, d.height);
            if ((preserveLimits & PRESERVE_ALL) == PRESERVE_ALL) {
                // Setting the limits before drawing avoids a double draw
                plot.setLimits(limits[0], limits[1], limits[2], limits[3]);
                preserveLimits = 0;
            }
            // If only some of the limits are to be preserved then we must get the current default min/max.
            // This cannot be done for a Plot class but we can do it for Plot2 (which makes public extra 
            // functionality).
            if ((preserveLimits & PRESERVE_ALL) != 0 && plot instanceof Plot2) {
                Plot2 p2 = (Plot2) plot;
                double[] currentLimits = p2.getDefaultMinAndMax();
                if (currentLimits != null) {
                    preserveLimits(plot, preserveLimits, limits, currentLimits);
                    preserveLimits = 0;
                }
            }
            p.drawPlot(plot);
            preserveLimits(plot, preserveLimits, limits);
            p.toFront();
        } catch (Throwable t) {
            // Allow debugging
            t.printStackTrace();

            // Get the location and close the error window
            Point location = null;
            Dimension d = null;
            double[] limits = null;
            if (p != null) {
                location = p.getLocation();
                Plot oldPlot = p.getPlot();
                d = oldPlot.getSize();
                limits = oldPlot.getLimits();
                try {
                    p.close();
                } catch (Throwable tt) {
                    // Ignore
                }
            }

            // Show a new window
            if (d != null) {
                plot.setSize(d.width, d.height);
            }
            p = plot.show();
            if (location != null) {
                p.setLocation(location);
            }
            if (limits != null) {
                preserveLimits(plot, preserveLimits, limits);
            }
            newWindow = true;
        }
    }
    return p;
}

From source file:de.prozesskraft.pmodel.PmodelPartUi1.java

/**
 * Create contents of the view part.//from  w  w w . j a v a2s .  c o m
 */
@PostConstruct
public void createControls(Composite composite) {

    composite.setSize(613, 649);
    GridData gd_composite = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
    gd_composite.minimumWidth = 10;
    gd_composite.minimumHeight = 10;
    composite.setLayoutData(gd_composite);
    composite.setLayout(new GridLayout(1, false));

    Composite composite_1 = new Composite(composite, SWT.NONE);
    GridLayout gl_composite_1 = new GridLayout(4, false);
    gl_composite_1.marginWidth = 0;
    gl_composite_1.marginHeight = 0;
    composite_1.setLayout(gl_composite_1);
    GridData gd_composite_1 = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
    gd_composite_1.heightHint = 445;
    gd_composite_1.widthHint = 122;
    composite_1.setLayoutData(gd_composite_1);

    Composite composite_11 = new Composite(composite_1, SWT.NONE);
    composite_11.setLayout(new GridLayout(1, false));
    GridData gd_composite_11 = new GridData(SWT.LEFT, SWT.FILL, false, true, 1, 1);
    gd_composite_11.heightHint = 437;
    gd_composite_11.widthHint = 169;
    composite_11.setLayoutData(gd_composite_11);

    Group grpVisual = new Group(composite_11, SWT.NONE);
    grpVisual.setText("visual");
    grpVisual.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    grpVisual.setLayout(new GridLayout(2, false));

    //      ExpandBar barVisual = new ExpandBar(composite_11, SWT.V_SCROLL);
    //      Composite grpVisual = new Composite(barVisual, SWT.NONE);
    //      ExpandItem item0 = new ExpandItem(barVisual, SWT.NONE, 0);
    //      item0.setText("visual settings");
    //      item0.setHeight(grpVisual.computeSize(SWT.DEFAULT, SWT.DEFAULT).y);
    //      item0.setControl(grpVisual);
    //      item0.setExpanded(true);
    //      barVisual.setSpacing(8);

    Label lblNewLabel_2 = new Label(grpVisual, SWT.NONE);
    lblNewLabel_2.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    lblNewLabel_2.setText("size");

    scale_size = new Scale(grpVisual, SWT.NONE);
    scale_size.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    scale_size.setMaximum(200);
    scale_size.setMinimum(10);
    scale_size.setSelection(100);
    scale_size.addMouseWheelListener(listener_mousewheel_size);

    Label lblNewLabel_21 = new Label(grpVisual, SWT.NONE);
    lblNewLabel_21.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    lblNewLabel_21.setText("zoom");

    scale_zoom = new Scale(grpVisual, SWT.NONE);
    scale_zoom.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    scale_zoom.setMaximum(200);
    scale_zoom.setMinimum(10);
    scale_zoom.setSelection(100);
    scale_zoom.addMouseWheelListener(listener_mousewheel_zoom);

    //      Label lblNewLabel_3 = new Label(grpVisual, SWT.NONE);
    //      lblNewLabel_3.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    //      lblNewLabel_3.setText("label");

    //      spinner_labelsize = new Spinner(grpVisual, SWT.BORDER);
    //      spinner_labelsize.setMaximum(20);
    //      spinner_labelsize.setSelection(10);
    //      spinner_labelsize.setMinimum(0);

    Label lblNewLabel_4 = new Label(grpVisual, SWT.NONE);
    lblNewLabel_4.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    lblNewLabel_4.setText("text");

    spinner_textsize = new Spinner(grpVisual, SWT.BORDER);
    spinner_textsize.setMaximum(20);
    spinner_textsize.setSelection(10);
    spinner_textsize.setMinimum(0);

    button_fix = new Button(grpVisual, SWT.NONE | SWT.TOGGLE);
    button_fix.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    button_fix.setText("fix");

    Button btnNewButton2 = new Button(grpVisual, SWT.NONE);
    btnNewButton2.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1));
    btnNewButton2.setText("autoscale");
    btnNewButton2.addSelectionListener(listener_autoscale_button);

    Group grpFunction = new Group(composite_11, SWT.NONE);
    grpFunction.setLayout(new GridLayout(2, false));
    grpFunction.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
    grpFunction.setText("function");

    button_refresh = new Button(grpFunction, SWT.NONE | SWT.PUSH);
    button_refresh.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    button_refresh.setText("refresh");
    button_refresh.addListener(SWT.Selection, (Listener) listener_refresh_button);
    button_refresh.setEnabled(true);

    //      button_refresh.getDisplay().asyncExec( new Runnable()
    //      {
    //         public void run()
    //         {
    //            // das Prozess Binary File ueberwachen
    //            // Wenn modifiziert wurde? dann soll Enable=true gesetzt werden
    //      //      Path processRootDir = Paths.get(einstellungen.getProcess().getRootdir());
    //            Path processRootDir = Paths.get("/localhome/avoge/Desktop");
    //      
    //            System.err.println("watching directory " + processRootDir);
    //            
    //            try {
    //               // Watch Service erstellen
    //               WatchService service = FileSystems.getDefault().newWatchService();
    //      
    //               // Watch key erstellen
    //               WatchKey key = processRootDir.register(service, ENTRY_MODIFY);
    //               
    //               while(true)
    //               {
    //                  try {
    //                     Thread.sleep(500);
    //                  } catch (InterruptedException e) {
    //                     // TODO Auto-generated catch block
    //                     e.printStackTrace();
    //                  }
    //                  WatchKey key1;
    //                  try
    //                  {
    //                     key1 = service.take();
    //                  }
    //                  catch (InterruptedException x)
    //                  {
    //                     break;
    //                  }
    //                  
    //                  for(WatchEvent<?> event: key1.pollEvents())
    //                  {
    //                     WatchEvent.Kind<?> kind = event.kind();
    //                     
    //                     if(kind == OVERFLOW)
    //                     {
    //                        continue;
    //                     }
    //                     
    //                     WatchEvent<Path> ev = (WatchEvent<Path>) event;
    //                     Path filename = ev.context();
    //                     Path child = processRootDir.resolve(filename);
    //                     log("debug", "directory modified");
    //      //               if(child.equals(Paths.get(einstellungen.getProcess().getRootdir() + "/process.pmb")))
    ////                     if(child.equals(Paths.get("/localhome/avoge/Desktop/testfileNotification")))
    //                     {
    //                        button_refresh.setEnabled(true);
    //                        log("debug", "binary modified");
    //                     }
    //                  }
    //               }
    //      
    //            } catch (IOException e) {
    //               // TODO Auto-generated catch block
    //               e.printStackTrace();
    //            }
    //         }
    //      });

    button_startmanager = new Button(grpFunction, SWT.NONE);
    button_startmanager.setSelection(true);
    GridData gd_btnNewButton = new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1);
    gd_btnNewButton.widthHint = 69;
    button_startmanager.setLayoutData(gd_btnNewButton);
    button_startmanager.setText("start new manager");
    button_startmanager.addSelectionListener(listener_startmanager_button);

    button_stopmanager = new Button(grpFunction, SWT.NONE);
    button_stopmanager.setSelection(true);
    GridData gd_button_stopmanager = new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1);
    gd_button_stopmanager.widthHint = 69;
    button_stopmanager.setLayoutData(gd_button_stopmanager);
    button_stopmanager.setText("stop manager");
    button_stopmanager.addSelectionListener(listener_stopmanager_button);

    label_marked = new Label(composite_11, SWT.NONE);
    label_marked.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    label_marked.setText("New Label");

    SashForm sashForm = new SashForm(composite_1, SWT.SMOOTH);
    sashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

    new Label(composite_1, SWT.NONE);

    Composite composite_12 = new Composite(sashForm, SWT.EMBEDDED | SWT.NO_BACKGROUND);
    composite_12.setLayout(new GridLayout(1, false));
    GridData gd_composite_12 = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1);
    gd_composite_12.heightHint = 390;
    gd_composite_12.minimumWidth = 10;
    gd_composite_12.minimumHeight = 10;
    composite_12.setLayoutData(gd_composite_12);

    Frame frame = SWT_AWT.new_Frame(composite_12);

    frame.add(applet, BorderLayout.CENTER);
    applet.init();
    frame.pack();
    frame.setLocation(0, 0);
    frame.setVisible(true);

    Composite composite_13 = new Composite(sashForm, SWT.NONE);
    composite_13.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    GridLayout gl_composite_13 = new GridLayout(1, false);
    gl_composite_13.marginWidth = 0;
    gl_composite_13.marginHeight = 0;
    composite_13.setLayout(gl_composite_13);
    //      tabFolder_13.addSelectionListener(listener_tabFolder_selection);
    new Label(composite_1, SWT.NONE);

    //      SashForm sashForm_13 = new SashForm(composite_13, SWT.SMOOTH | SWT.VERTICAL);
    //      composite_13.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

    composite_131 = new Composite(composite_13, SWT.BORDER);
    composite_131.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
    GridLayout gl_composite_131 = new GridLayout(1, false);
    gl_composite_131.marginWidth = 0;
    gl_composite_131.marginHeight = 0;
    composite_131.setLayout(gl_composite_131);

    composite_132 = new Composite(composite_13, SWT.BORDER);
    composite_132.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    GridLayout gl_composite_132 = new GridLayout(1, false);
    gl_composite_132.marginWidth = 0;
    gl_composite_132.marginHeight = 0;
    composite_132.setLayout(gl_composite_132);

    Composite composite_2 = new Composite(composite, SWT.NONE);
    composite_2.setLayout(new GridLayout(1, false));
    GridData gd_composite_2 = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1);
    gd_composite_2.heightHint = 164;
    composite_2.setLayoutData(gd_composite_2);

    //      text_logging = new Text(composite_2, SWT.BORDER | SWT.READ_ONLY | SWT.V_SCROLL | SWT.MULTI);
    //      text_logging.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

    text_logging = new StyledText(composite_2, SWT.BORDER | SWT.READ_ONLY | SWT.V_SCROLL | SWT.MULTI);
    text_logging.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

    // virtuelle ablage fuer gerade nicht anzuzeigende composites
    shell_dummy_insight = new Shell(display);
    //      shell_dummy_insight.setLayout(new FillLayout());

    bindingContextVisual = initDataBindingsVisual();
    bindingContextMarked = initDataBindingsMarked();
    bindingContextRefresh = initDataBindingsRefresh();

    // erzeugen der 'step-insight' listeners beim wechsel der markierung
    generateNewInsight(einstellungen);

    // erzeugen den insight fuer den Prozess
    createControlsProcessInsight(composite_131);
    new Label(composite_131, SWT.NONE);

    // erzeugen der ersten insight ansicht fuer den aktuell markierten step (root)
    createControlsStepInsight(composite_132);

    // die processing darstellung refreshen
    applet_refresh();

}

From source file:com.mirth.connect.plugins.rtfviewer.RTFViewer.java

@Override
public void viewAttachments(List<String> attachmentIds) {
    // do viewing code

    Frame frame = new Frame("RTF Viewer");

    frame.setLayout(new BorderLayout());

    try {//from   w ww  . j  av  a 2s  .c  om

        Attachment attachment = parent.mirthClient.getAttachment(attachmentIds.get(0));
        byte[] rawRTF = Base64.decodeBase64(attachment.getData());
        JEditorPane jEditorPane = new JEditorPane("text/rtf", new String(rawRTF));

        if (jEditorPane.getDocument().getLength() == 0) {
            // decoded when it should not have been.  i.e.) the attachment data was not encoded.
            jEditorPane.setText(new String(attachment.getData()));
        }

        jEditorPane.setEditable(false);
        JScrollPane scrollPane = new javax.swing.JScrollPane();
        scrollPane.setViewportView(jEditorPane);
        frame.add(scrollPane);
        frame.addWindowListener(new WindowAdapter() {

            public void windowClosing(WindowEvent e) {
                e.getWindow().dispose();
            }
        });

        frame.setSize(600, 800);

        Dimension dlgSize = frame.getSize();
        Dimension frmSize = parent.getSize();
        Point loc = parent.getLocation();

        if ((frmSize.width == 0 && frmSize.height == 0) || (loc.x == 0 && loc.y == 0)) {
            frame.setLocationRelativeTo(null);
        } else {
            frame.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x,
                    (frmSize.height - dlgSize.height) / 2 + loc.y);
        }

        frame.setVisible(true);
    } catch (Exception e) {
        parent.alertException(parent, e.getStackTrace(), e.getMessage());
    }
}

From source file:net.sf.freecol.FreeCol.java

public static void startYourAddition() throws FontFormatException, IOException {
    Frame mainFrame;//from  w w  w  . ja va2 s.  com
    Frame mainFrame2;
    TextField t1;
    TextField t2;
    TextField t3;
    TextField t4;
    Frame mainFrame3 = new Frame("Haha, am i middle?");
    mainFrame = new Frame("Haha, am I right?!");
    mainFrame.setSize(400, 400);
    mainFrame.setLayout(null);

    t1 = new TextField("Enter here");
    t1.setBounds(160, 200, 150, 50);

    t2 = new TextField("What grade do we deserve?");
    t3 = new TextField("Enter here");
    t3.setBounds(160, 200, 150, 50);

    t4 = new TextField("What letter grade do we deserve?");
    Button b = new Button("click ----->");
    b.setBounds(30, 250, 130, 30);
    b.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            t2.setText("I think you meant 100");
        }
    });
    Button c = new Button("Submit");
    c.setBounds(150, 250, 80, 30);
    c.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            String in = t1.getText();
            if (in.equals("100")) {
                t1.setText("Correct");
                t1.setEditable(false);
                t1.setBackground(new Color(95, 216, 109));

                if (t3.getText().equals("Correct")) {
                    mainFrame3.setVisible(true);
                }
            } else {
                t1.setText("Wrong");
                t1.setBackground(new Color(214, 81, 96));
            }
        }
    });

    t2.setBounds(160, 0, 175, 100);
    t2.setEditable(false);

    mainFrame.add(b);
    mainFrame.add(c);
    mainFrame.add(t1);
    mainFrame.add(t2);

    mainFrame.setLocation(1280, 0);

    mainFrame.setVisible(true);

    ///////////////The left area below and above is right

    mainFrame2 = new Frame("Haha, am i left?");
    mainFrame2.setSize(400, 400);
    mainFrame2.setLayout(null);

    Button b2 = new Button("click ----->");
    b2.setBounds(30, 250, 130, 30);
    b2.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            t4.setText("I think you meant A");
        }
    });
    Button c2 = new Button("Submit");
    c2.setBounds(150, 250, 80, 30);
    c2.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            String in = t3.getText();
            if (in.equals("A")) {
                t3.setText("Correct");
                t3.setEditable(false);
                t3.setBackground(new Color(95, 216, 109));

                if (t1.getText().equals("Correct")) {
                    mainFrame3.setVisible(true);
                }

            } else {
                t3.setText("Wrong");
                t3.setBackground(new Color(214, 81, 96));
            }
        }
    });

    t4.setBounds(120, 0, 220, 100);
    t4.setEditable(false);

    mainFrame2.add(b2);
    mainFrame2.add(c2);
    mainFrame2.add(t3);
    mainFrame2.add(t4);

    mainFrame2.setVisible(true);

    //Overall correct

    mainFrame3.setSize(400, 400);
    mainFrame3.setLayout(null);
    mainFrame3.setLocation(640, 420);
    mainFrame3.setBackground(new Color(95, 216, 109));
    TextField t6 = new TextField("Soooooo give us an A!!!");
    t6.setBounds(160, 200, 200, 50);
    t6.setBackground(new Color(102, 136, 232));

    mainFrame3.add(t6);
}

From source file:com.mirth.connect.plugins.textviewer.TextViewer.java

@Override
public void viewAttachments(String channelId, Long messageId, String attachmentId) {
    // do viewing code
    Frame frame = new Frame("Text Viewer");
    frame.setLayout(new BorderLayout());

    try {/*from  w w  w  . j  av a  2s . c o m*/
        Attachment attachment = parent.mirthClient.getAttachment(channelId, messageId, attachmentId);
        byte[] content = Base64.decodeBase64(attachment.getContent());

        boolean isRTF = attachment.getType().toLowerCase().contains("rtf");
        //TODO set character encoding
        JEditorPane jEditorPane = new JEditorPane(isRTF ? "text/rtf" : "text/plain", new String(content));

        if (jEditorPane.getDocument().getLength() == 0) {
            // decoded when it should not have been.  i.e.) the attachment data was not encoded.
            jEditorPane.setText(new String(attachment.getContent()));
        }

        jEditorPane.setEditable(false);
        JScrollPane scrollPane = new javax.swing.JScrollPane();
        scrollPane.setViewportView(jEditorPane);
        frame.add(scrollPane);
        frame.addWindowListener(new WindowAdapter() {

            public void windowClosing(WindowEvent e) {
                e.getWindow().dispose();
            }
        });

        frame.setSize(600, 800);

        Dimension dlgSize = frame.getSize();
        Dimension frmSize = parent.getSize();
        Point loc = parent.getLocation();

        if ((frmSize.width == 0 && frmSize.height == 0) || (loc.x == 0 && loc.y == 0)) {
            frame.setLocationRelativeTo(null);
        } else {
            frame.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x,
                    (frmSize.height - dlgSize.height) / 2 + loc.y);
        }

        frame.setVisible(true);
    } catch (Exception e) {
        parent.alertThrowable(parent, e);
    }
}

From source file:HelloUniverse.java

public VirtualInputDevice(String[] args) {

    // default user-definable values
    printvalues = false;/*from  w ww .  j  a  va 2s. c  o  m*/
    xscreeninitloc = 400;
    yscreeninitloc = 0;
    xscreensize = 400;
    yscreensize = 200;
    xobjinitloc = 0.0f;
    yobjinitloc = 0.0f;
    zobjinitloc = 2.2f;
    xaxisrotinit = 0.0f;
    yaxisrotinit = 0.0f;
    zaxisrotinit = 0.0f;

    for (int i = 0; i < args.length; i += 2) {
        if (args[i] == null)
            break;
        else if (args[i] == "printvalues")
            printvalues = (Boolean.valueOf(args[i + 1])).booleanValue();
        else if (args[i] == "xscreeninitloc")
            xscreeninitloc = (Integer.valueOf(args[i + 1])).intValue();
        else if (args[i] == "yscreeninitloc")
            yscreeninitloc = (Integer.valueOf(args[i + 1])).intValue();
        else if (args[i] == "xscreensize")
            xscreensize = (Integer.valueOf(args[i + 1])).intValue();
        else if (args[i] == "yscreensize")
            yscreensize = (Integer.valueOf(args[i + 1])).intValue();
        else if (args[i] == "xobjinitloc")
            xobjinitloc = (Float.valueOf(args[i + 1])).floatValue();
        else if (args[i] == "yobjinitloc")
            yobjinitloc = (Float.valueOf(args[i + 1])).floatValue();
        else if (args[i] == "zobjinitloc")
            zobjinitloc = (Integer.valueOf(args[i + 1])).floatValue();
    }

    if (printvalues == true) {
        System.out.println("Initial values for VirtualInputDevice:");
        System.out.println("xscreeninitloc = " + xscreeninitloc);
        System.out.println("yscreeninitloc = " + yscreeninitloc);
        System.out.println("xscreeninitsize = " + xscreensize);
        System.out.println("yscreeninitsize = " + yscreensize);
        System.out.println("xobjinitloc = " + xobjinitloc);
        System.out.println("yobjinitloc = " + yobjinitloc);
        System.out.println("zobjinitloc = " + zobjinitloc);
        System.out.println("xaxisrotinit = " + xaxisrotinit);
        System.out.println("yaxisrotinit = " + yaxisrotinit);
        System.out.println("zaxisrotinit = " + zaxisrotinit);
    }

    // initialize the InputDevice GUI
    Frame deviceFrame = new Frame();
    deviceFrame.setSize(xscreensize, yscreensize);
    deviceFrame.setLocation(xscreeninitloc, yscreeninitloc);
    deviceFrame.setTitle("Virtual Input Device");
    ButtonPositionControls positionControls;
    // initialize position with initial x, y, and z position
    positionControls = new ButtonPositionControls(xobjinitloc, yobjinitloc, zobjinitloc);
    WheelControls rotControls;
    // initialize rotations with initial angles in radians)
    rotControls = new WheelControls(xaxisrotinit, yaxisrotinit, zaxisrotinit);
    positionControls.setDevice(this);
    Panel devicePanel = new Panel();
    devicePanel.setLayout(new BorderLayout());
    devicePanel.add("East", positionControls);
    devicePanel.add("West", rotControls);
    deviceFrame.add(devicePanel);
    deviceFrame.pack();
    deviceFrame.setVisible(true);

    initPos.set(xobjinitloc, yobjinitloc, zobjinitloc);

    this.positionControls = positionControls;
    this.rotControls = rotControls;

    // default processing mode
    processingMode = InputDevice.DEMAND_DRIVEN;

    sensors[0] = new Sensor(this);
}

From source file:SplineInterpolatorTest.java

public UiAlpha(Alpha alpha) {
    m_Alpha = alpha;/*from   www  . ja v a 2  s .  co m*/

    Frame frame = new Frame("Alpha Control Panel");
    JPanel panel = new JPanel();
    frame.add(panel);
    addUiToPanel(panel);
    frame.pack();
    frame.setSize(new Dimension(400, 80));
    frame.validate();
    frame.setVisible(true);
}