protected void showDeployAgentDialog() {
   // TODO Auto-generated method stub
   JInternalFrame fr = new JInternalFrame("Deploy Agent");
   fr.getContentPane().add(new NewAgentPanel());
   fr.pack();
   fr.setClosable(true);
   fr.setIconifiable(true);
   fr.setResizable(true);
   fr.setMaximizable(true);
   fr.setVisible(true);
   jDesktopPane1.add(fr);
 }
 /**
  * Creates a new {@code JInternalFrame} with a size of 200 x 100. The title of the created
  * internal frame includes the value of a counter that is automatically increased every time a new
  * internal frame is created. This method is {@code not} executed in the event dispatch thread
  * (EDT.)
  *
  * @return the created frame.
  */
 @RunsInCurrentThread
 protected static JInternalFrame createInternalFrame() {
   // TODO: should be create and add
   JInternalFrame internalFrame =
       new JInternalFrame(concat("Internal Frame ", ++internalFrameCounter));
   internalFrame.setIconifiable(true);
   internalFrame.setMaximizable(true);
   internalFrame.setResizable(true);
   internalFrame.setSize(new Dimension(200, 100));
   internalFrame.setVisible(true);
   return internalFrame;
 }
 /*
  * Class under test for void void setPalette(boolean)
  */
 public void testSetPalette() {
   TestMetalInternalFrameTitlePane pane = new TestMetalInternalFrameTitlePane(frame);
   frame.setClosable(true);
   frame.setIconifiable(true);
   frame.setMaximizable(true);
   // test set to true
   pane.setPalette(true);
   assertTrue("isPalette is true", pane.isPalette);
   assertTrue("changed close icon", pane.getCloseButton().getIcon() == pane.paletteCloseIcon);
   assertTrue("1 child", pane.getComponentCount() == 1);
   // is layoutContainer called?
   // test set to false
   pane.setPalette(false);
   assertFalse("isPalette is false", pane.isPalette);
   assertTrue("changed close icon", pane.getCloseButton().getIcon() == pane.getCloseIcon());
   assertTrue("3 children", pane.getComponentCount() == 3);
 }
 private void showDomainDialog(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_showDomainDialog
   // TODO add your handling code here:
   JInternalFrame fr = new JInternalFrame("Add new Domain");
   fr.getContentPane().add(new NewDomainPanel());
   fr.pack();
   fr.setClosable(true);
   fr.setIconifiable(true);
   fr.setResizable(true);
   fr.setMaximizable(true);
   fr.setVisible(true);
   jDesktopPane1.add(fr);
   GridBagConstraints gc = new GridBagConstraints();
   gc.gridx = 0;
   gc.gridy = GridBagConstraints.RELATIVE;
   gc.insets = new Insets(6, 12, 0, 12);
   gc.fill = GridBagConstraints.HORIZONTAL;
   domainsPanel.add(new JButton("Dynamic"), gc);
 } // GEN-LAST:event_showDomainDialog
    public DialogDecoration() {
      setLayout(new BorderLayout());

      clipboardPanel = new JClipboardPanel();
      clipboardPanel.addPropertyChangeListener(DialogDecoration.this);

      frame = new JInternalFrame("Clipboard");
      frame.setContentPane(clipboardPanel);
      frame.setResizable(true);
      frame.setClosable(true);
      frame.setIconifiable(false);
      frame.pack();
      frame.setVisible(true);

      desktop = new JLayeredPane();
      desktop.setOpaque(false);
      desktop.add(frame);

      add(BorderLayout.CENTER, desktop);
    }
 /*
  * Test MetalInternalFrameTitlePane.MetalTitlePaneLayout class
  */
 public void testMetalTitlePaneLayout() {
   TestMetalInternalFrameTitlePane pane = new TestMetalInternalFrameTitlePane(frame);
   pane.setSize(200, 31);
   LayoutManager layout = pane.getLayout();
   final Rectangle iconButtonBounds = new Rectangle(134, 7, 16, 16);
   final Rectangle maximizeButtonBounds = new Rectangle(156, 7, 16, 16);
   final Rectangle closeButtonBounds = new Rectangle(178, 7, 16, 16);
   // test layoutContainer(): non-iconifiable, non-maximizable, non-closable
   layout.layoutContainer(null);
   //        assertEquals("iconButton", zeroBounds,
   //                     pane.getComponent(0).getBounds());
   //        assertTrue("maximizeButton", pane.getComponent(1).getBounds().
   //                equals(zeroBounds));
   //        assertTrue("closeButton", pane.getComponent(2).getBounds().
   //                equals(zeroBounds));
   // test layoutContainer(): iconifiable, maximizable, closable
   frame.setIconifiable(true);
   frame.setMaximizable(true);
   frame.setClosable(true);
   layout.layoutContainer(pane);
   if (isHarmony()) {
     assertEquals("iconButton", iconButtonBounds, pane.getComponent(0).getBounds());
     assertEquals("maximizeButton", maximizeButtonBounds, pane.getComponent(1).getBounds());
     assertEquals("closeButton", closeButtonBounds, pane.getComponent(2).getBounds());
   }
   // test layoutContainer(): isPalette == true
   pane.setPalette(true);
   layout.layoutContainer(null);
   // these bounds can be changed in the future
   if (isHarmony()) {
     assertEquals(
         "palette: closeButton", new Rectangle(189, 11, 8, 8), pane.getComponent(0).getBounds());
   }
   // minimumLayoutSize(), preferredLayoutSize() implementations
   assertTrue("", layout.minimumLayoutSize(pane) != null);
   assertTrue("", layout.preferredLayoutSize(pane) != null);
 }
Exemple #7
0
  public static void init(
      JInternalFrame comp, Thing thing, Container parent, ActionContext actionContext) {
    JComponentCreator.init(comp, thing, parent, actionContext);

    String title = JavaCreator.createText(thing, "title", actionContext);
    if (title != null) {
      comp.setTitle(title);
    }

    Boolean closable = JavaCreator.createBoolean(thing, "closable");
    if (closable != null) {
      comp.setClosable(closable);
    }

    Boolean closed = JavaCreator.createBoolean(thing, "closed");
    if (closed != null) {
      try {
        comp.setClosed(closed);
      } catch (PropertyVetoException e) {
        e.printStackTrace();
      }
    }

    Cursor cursor = AwtCreator.createCursor(thing, "cursor", actionContext);
    if (cursor != null) {
      comp.setCursor(cursor);
    }

    Integer defaultCloseOperation = null;
    String d = thing.getString("defaultCloseOperation");
    if ("DO_NOTHING_ON_CLOSE".equals(d)) {
      defaultCloseOperation = JInternalFrame.DO_NOTHING_ON_CLOSE;
    } else if ("HIDE_ON_CLOSE".equals(d)) {
      defaultCloseOperation = JInternalFrame.HIDE_ON_CLOSE;
    } else if ("DISPOSE_ON_CLOSE".equals(d)) {
      defaultCloseOperation = JInternalFrame.DISPOSE_ON_CLOSE;
    }
    if (defaultCloseOperation != null) {
      comp.setDefaultCloseOperation(defaultCloseOperation);
    }

    Boolean focusCycleRoot = JavaCreator.createBoolean(thing, "focusCycleRoot");
    if (focusCycleRoot != null) {
      comp.setFocusCycleRoot(focusCycleRoot);
    }

    Icon frameIcon = SwingCreator.createIcon(thing, "frameIcon", actionContext);
    if (frameIcon != null) {
      comp.setFrameIcon(frameIcon);
    }

    Boolean setIcon = JavaCreator.createBoolean(thing, "setIcon");
    if (setIcon != null) {
      try {
        comp.setIcon(setIcon);
      } catch (PropertyVetoException e) {
        e.printStackTrace();
      }
    }

    Boolean iconifiable = JavaCreator.createBoolean(thing, "iconifiable");
    if (iconifiable != null) {
      comp.setIconifiable(iconifiable);
    }

    Integer layer = JavaCreator.createInteger(thing, "layer");
    if (layer != null) {
      comp.setLayer(layer);
    }

    Boolean maximizable = JavaCreator.createBoolean(thing, "maximizable");
    if (maximizable != null) {
      comp.setMaximizable(maximizable);
    }

    Boolean maximum = JavaCreator.createBoolean(thing, "maximum");
    if (maximum != null) {
      try {
        comp.setMaximum(maximum);
      } catch (PropertyVetoException e) {
        e.printStackTrace();
      }
    }

    Boolean resizable = JavaCreator.createBoolean(thing, "resizable");
    if (resizable != null) {
      comp.setResizable(resizable);
    }

    Boolean selected = JavaCreator.createBoolean(thing, "selected");
    if (selected != null) {
      try {
        comp.setSelected(selected);
      } catch (PropertyVetoException e) {
        e.printStackTrace();
      }
    }
  }
Exemple #8
0
  public SceneLayoutApp() {
    super();
    new Pair();
    final JFrame frame = new JFrame("Scene Layout");

    final JPanel panel = new JPanel(new BorderLayout());
    frame.setContentPane(panel);
    final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    frame.setMaximumSize(screenSize);
    frame.setSize(screenSize);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    final JMenuBar mb = new JMenuBar();
    frame.setJMenuBar(mb);

    final JMenu jMenu = new JMenu("File");
    mb.add(jMenu);
    mb.add(new JMenu("Edit"));
    mb.add(new JMenu("Help"));
    JMenu menu = new JMenu("Look and Feel");

    //
    // Get all the available look and feel that we are going to use for
    // creating the JMenuItem and assign the action listener to handle
    // the selection of menu item to change the look and feel.
    //
    UIManager.LookAndFeelInfo[] lookAndFeelInfos = UIManager.getInstalledLookAndFeels();
    for (int i = 0; i < lookAndFeelInfos.length; i++) {
      final UIManager.LookAndFeelInfo lookAndFeelInfo = lookAndFeelInfos[i];
      JMenuItem item = new JMenuItem(lookAndFeelInfo.getName());
      item.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              try {
                //
                // Set the look and feel for the frame and update the UI
                // to use a new selected look and feel.
                //
                UIManager.setLookAndFeel(lookAndFeelInfo.getClassName());
                SwingUtilities.updateComponentTreeUI(frame);
              } catch (ClassNotFoundException e1) {
                e1.printStackTrace();
              } catch (InstantiationException e1) {
                e1.printStackTrace();
              } catch (IllegalAccessException e1) {
                e1.printStackTrace();
              } catch (UnsupportedLookAndFeelException e1) {
                e1.printStackTrace();
              }
            }
          });
      menu.add(item);
    }

    mb.add(menu);
    jMenu.add(new JMenuItem(new scene.action.QuitAction()));

    panel.add(new JScrollPane(desktopPane), BorderLayout.CENTER);
    final JToolBar bar = new JToolBar();

    panel.add(bar, BorderLayout.NORTH);

    final JComboBox comboNewWindow =
        new JComboBox(
            new String[] {"320:180", "320:240", "640:360", "640:480", "1280:720", "1920:1080"});

    comboNewWindow.addActionListener(new CreateSceneWindowAction());

    comboNewWindow.setBorder(BorderFactory.createTitledBorder("Create New Window"));
    bar.add(comboNewWindow);
    bar.add(
        new AbstractAction("Progress Bars") {

          /** Invoked when an action occurs. */
          @Override
          public void actionPerformed(ActionEvent e) {
            new ProgressBarAnimator();
          }
        });
    bar.add(
        new AbstractAction("Sliders") {

          /** Invoked when an action occurs. */
          @Override
          public void actionPerformed(ActionEvent e) {
            new SliderBarAnimator();
          }
        });

    final JCheckBox permaViz = new JCheckBox();
    permaViz.setText("Show the dump window");
    permaViz.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));

    dumpWindow = new JInternalFrame("perma dump window");
    dumpWindow.setContentPane(new JScrollPane(permText));

    permaViz.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            dumpWindow.setVisible(permaViz.isSelected());
          }
        });

    comboNewWindow.setMaximumSize(comboNewWindow.getPreferredSize());

    permaViz.setSelected(false);
    bar.add(new CreateWebViewV1Action());
    bar.add(new CreateWebViewV2Action());
    bar.add(permaViz);
    desktopPane.add(dumpWindow);
    dumpWindow.setSize(400, 400);
    dumpWindow.setResizable(true);
    dumpWindow.setClosable(false);
    dumpWindow.setIconifiable(false);
    final JMenuBar m = new JMenuBar();
    final JMenu cmenu = new JMenu("Create");
    m.add(cmenu);
    final JMenuItem menuItem =
        new JMenuItem(
            new AbstractAction("new") {
              @Override
              public void actionPerformed(ActionEvent e) {
                Runnable runnable =
                    new Runnable() {
                      public void run() {
                        Object[] in = (Object[]) XSTREAM.fromXML(permText.getText());

                        final JInternalFrame ff = new JInternalFrame();

                        final ScenePanel c = new ScenePanel();
                        ff.setContentPane(c);
                        desktopPane.add(ff);
                        final Dimension d = (Dimension) in[0];
                        c.setMaximumSize(d);
                        c.setPreferredSize(d);

                        ff.setSize(d.width + 50, d.height + 50);
                        ScenePanel.panes.put(c, (List<Pair<Point, ArrayList<URL>>>) in[1]);

                        c.invalidate();
                        c.repaint();

                        ff.pack();
                        ff.setClosable(true);

                        ff.setMaximizable(false);
                        ff.setIconifiable(false);
                        ff.setResizable(false);
                        ff.show();
                      }
                    };

                SwingUtilities.invokeLater(runnable);
              }
            });
    cmenu.add(menuItem);
    //        JMenuBar menuBar = new JMenuBar();

    //        getContentPane().add(menuBar);

    dumpWindow.setJMenuBar(m);
    frame.setVisible(true);
  }
  /** The graphic handling and deployment. */
  private void initComponents() {
    jDesktopPane1 = new javax.swing.JDesktopPane();
    jInternalFrame1 = new javax.swing.JInternalFrame();
    tf = new javax.swing.JTextField();
    b1 = new javax.swing.JButton();
    jInternalFrame3 = new javax.swing.JInternalFrame();
    ta = new javax.swing.JTextArea();
    jsp_ta = new javax.swing.JScrollPane(ta);
    jMenuBar1 = new javax.swing.JMenuBar();
    jMenu1 = new javax.swing.JMenu();
    jMenuItem3 = new javax.swing.JMenuItem();
    jSeparator1 = new javax.swing.JSeparator();
    jMenuItem4 = new javax.swing.JMenuItem();

    jInternalFrame1
        .getContentPane()
        .setLayout(
            new javax.swing.BoxLayout(
                jInternalFrame1.getContentPane(), javax.swing.BoxLayout.X_AXIS));

    jInternalFrame1.setIconifiable(true);
    jInternalFrame1.setMaximizable(true);
    jInternalFrame1.setResizable(true);
    jInternalFrame1.setTitle("Message editor");
    jInternalFrame1.setToolTipText(
        "Move and resize all of these to make the chat room appearance match your preferences.");
    jInternalFrame1.setVisible(true);
    tf.setFont(new java.awt.Font("Lucida Sans", 0, 12));
    jInternalFrame1.getContentPane().add(tf);

    b1.setText("Send Message");
    jInternalFrame1.getContentPane().add(b1);

    jInternalFrame1.setBounds(10, 10, 440, 60);
    jDesktopPane1.add(jInternalFrame1, javax.swing.JLayeredPane.DEFAULT_LAYER);

    jInternalFrame3.setIconifiable(true);
    jInternalFrame3.setMaximizable(true);
    jInternalFrame3.setResizable(true);
    jInternalFrame3.setTitle("Messages");
    jInternalFrame3.setToolTipText(
        "Move and resize all of these to make the chat room appearance match your preferences.");
    jInternalFrame3.setVisible(true);
    ta.setBackground(new Color(255, 255, 255));
    ta.setEditable(false);
    ta.setFont(new java.awt.Font("Lucida Sans", 0, 12));
    // jsp_ta.setAutoscrolls(true);
    jsp_ta.setDoubleBuffered(true);

    jInternalFrame3.getContentPane().add(jsp_ta, java.awt.BorderLayout.CENTER);

    jInternalFrame3.setBounds(10, 80, 420, 240);

    jDesktopPane1.add(jInternalFrame3, javax.swing.JLayeredPane.DEFAULT_LAYER);

    getContentPane().add(jDesktopPane1, java.awt.BorderLayout.CENTER);

    jMenu1.setText("Private room options");
    jMenu1.setMnemonic(KeyEvent.VK_O);
    jMenu1.setToolTipText("Choose some options.");
    jMenuItem3.setText("Save conversation");
    jMenuItem3.setMnemonic(KeyEvent.VK_S);
    jMenuItem3.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK));
    jMenu1.add(jMenuItem3);
    jMenu1.add(jSeparator1);
    jMenuItem4.setText("Exit");
    jMenuItem4.setMnemonic(KeyEvent.VK_E);
    jMenuItem4.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E, ActionEvent.CTRL_MASK));
    jMenu1.add(jMenuItem4);
    jMenuBar1.add(jMenu1);
    setJMenuBar(jMenuBar1);

    this.pack();

    b1.addActionListener(this);
    tf.addActionListener(this);
    jMenuItem3.addActionListener(this);
    jMenuItem4.addActionListener(this);

    posx = (int) Math.random() * 640;
    posy = (int) Math.random() * 480;

    this.pack();
    this.setSize(dimx, dimy);
    this.setLocation(posx, posy);
    this.show();
  }
 public static JComponent createContent() {
   JDesktopPane desktopPane = new JDesktopPane();
   // Web Browser 1 internal frame
   JInternalFrame webBrowser1InternalFrame = new JInternalFrame("Web Browser 1");
   webBrowser1InternalFrame.setBounds(10, 10, 400, 280);
   webBrowser1InternalFrame.setResizable(true);
   webBrowser1InternalFrame.setVisible(true);
   JWebBrowser webBrowser1 = new JWebBrowser(JWebBrowser.proxyComponentHierarchy());
   webBrowser1.navigate("http://djproject.sf.net");
   webBrowser1InternalFrame.add(webBrowser1, BorderLayout.CENTER);
   desktopPane.add(webBrowser1InternalFrame);
   // Flash Player internal frame
   JInternalFrame flashPlayerInternalFrame = new JInternalFrame("Flash Player");
   flashPlayerInternalFrame.setBounds(100, 100, 400, 280);
   flashPlayerInternalFrame.setResizable(true);
   flashPlayerInternalFrame.setVisible(true);
   JFlashPlayer flashPlayer = new JFlashPlayer(JFlashPlayer.proxyComponentHierarchy());
   flashPlayer.setControlBarVisible(false);
   flashPlayer.load(SimpleFlashExample.class, "resource/Movement-pointer_or_click.swf");
   flashPlayerInternalFrame.add(flashPlayer, BorderLayout.CENTER);
   desktopPane.add(flashPlayerInternalFrame);
   // Web Browser 2 internal frame, with a button on top
   JInternalFrame webBrowser2InternalFrame =
       new JInternalFrame("Web Browser 2 with a JButton on top");
   webBrowser2InternalFrame.setBounds(190, 190, 400, 280);
   webBrowser2InternalFrame.setResizable(true);
   webBrowser2InternalFrame.setVisible(true);
   GridBagLayout gridBag = new GridBagLayout();
   GridBagConstraints cons = new GridBagConstraints();
   cons.fill = GridBagConstraints.BOTH;
   cons.gridx = 0;
   cons.gridy = 0;
   JPanel webBrowser2ContentPane =
       new JPanel(gridBag) {
         @Override
         public boolean isOptimizedDrawingEnabled() {
           return false;
         }
       };
   // When a frame is iconified, components are destroyed. To avoid this, we use the option to
   // destroy on finalization.
   final JWebBrowser webBrowser2 =
       new JWebBrowser(JWebBrowser.proxyComponentHierarchy(), JWebBrowser.destroyOnFinalization());
   webBrowser2.navigate("http://www.google.com");
   cons.weightx = 1;
   cons.weighty = 1;
   gridBag.setConstraints(webBrowser2, cons);
   webBrowser2ContentPane.add(webBrowser2);
   JButton webBrowser2Button = new JButton("A Swing button");
   cons.fill = GridBagConstraints.NONE;
   cons.weightx = 0;
   cons.weighty = 0;
   gridBag.setConstraints(webBrowser2Button, cons);
   webBrowser2ContentPane.add(webBrowser2Button);
   webBrowser2ContentPane.setComponentZOrder(webBrowser2Button, 0);
   webBrowser2InternalFrame.add(webBrowser2ContentPane, BorderLayout.CENTER);
   webBrowser2InternalFrame.setIconifiable(true);
   desktopPane.add(webBrowser2InternalFrame);
   JPanel contentPane =
       new JPanel(new BorderLayout()) {
         @Override
         public void removeNotify() {
           super.removeNotify();
           // webBrowser2 is destroyed on finalization.
           // Rather than wait for garbage collection, release when the component is removed from
           // its parent.
           webBrowser2.disposeNativePeer();
         }
       };
   contentPane.add(desktopPane, BorderLayout.CENTER);
   return contentPane;
 }