Exemplo n.º 1
0
    /**
     * Updates the <code>Toolbar</code> represented by this folder.
     *
     * @param cookies array of instance cookies for the folder
     * @return the updated <code>ToolbarPool</code> representee
     */
    protected Object createInstance(InstanceCookie[] cookies)
        throws java.io.IOException, ClassNotFoundException {
      // refresh the toolbar's content
      getToolbar().removeAll();
      for (int i = 0; i < cookies.length; i++) {
        try {
          Object obj = cookies[i].instanceCreate();
          if (obj instanceof Presenter.Toolbar) {
            obj = ((Presenter.Toolbar) obj).getToolbarPresenter();
          }
          if (obj instanceof Component) {
            Component comp = (Component) obj;
            getToolbar().add(comp);
          }
        } catch (java.io.IOException ex) {
        } catch (ClassNotFoundException ex) {
        }
      }

      // invalidate the toolbar and its parent
      toolbar.invalidate();
      java.awt.Container parent = toolbar.getParent();
      if (parent != null) {
        parent.validate();
        parent.repaint();
      }
      return toolbar;
    }
Exemplo n.º 2
0
    /** Returns the tool bar for the panel. */
    protected JComponent getToolBar() {
      JToolBar tbarDir = new JToolBar();
      JButton btnNew = new JButton();
      // m_btnSave = new JButton("Save File");
      // i118n
      // btnNew.setText("New Label");
      btnNew.setText(Util.getAdmLabel("_adm_New_Label"));
      btnNew.setActionCommand("new");
      // m_btnSave.setActionCommand("save");

      ActionListener alTool =
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              doAction(e);
            }
          };

      btnNew.addActionListener(alTool);
      // m_btnSave.addActionListener(alTool);

      tbarDir.setFloatable(false);
      tbarDir.add(btnNew);
      /*tbarDir.add(new JLabel("        "));
      tbarDir.add(m_btnSave);*/

      return tbarDir;
    }
Exemplo n.º 3
0
 private JToolBar buildToolBar() {
   // build tool bar
   JToolBar toolBar = new JToolBar("Toolbar");
   toolBar.add(makeToolbarButton("stock_new.png", "New file", "New"));
   toolBar.add(makeToolbarButton("stock_open.png", "Open file", "Open"));
   toolBar.add(makeToolbarButton("stock_save.png", "Save file", "Save"));
   // run button is special
   runButton = makeToolbarButton("Play24.gif", "Run Program", "Run");
   toolBar.add(runButton);
   toolBar.add(makeToolbarButton("stock_text_left.png", "Pretty Print", "Pretty"));
   toolBar.addSeparator();
   toolBar.add(new JButton(copyAction));
   toolBar.add(new JButton(cutAction));
   toolBar.add(new JButton(pasteAction));
   return toolBar;
 }
Exemplo n.º 4
0
  public final void initializeGui() {
    // set up the main GUI
    gui.setBorder(new EmptyBorder(5, 5, 5, 5));
    JToolBar tools = new JToolBar();
    tools.setFloatable(false);
    gui.add(tools, BorderLayout.PAGE_START);
    tools.add(new JButton("New")); // TODO - add functionality!
    tools.addSeparator();
    tools.add(new JLabel("Player:")); // TODO - add functionality!
    tools.addSeparator();
    tools.add(message);

    playBoard = new JPanel(new GridLayout(0, 11));
    playBoard.setBorder(new LineBorder(Color.BLACK));
    gui.add(playBoard);

    // create the chess board squares
    Insets buttonMargin = new Insets(0, 0, 0, 0);
    for (int ii = 0; ii < playBoardSquares.length; ii++) {
      for (int jj = 0; jj < playBoardSquares[ii].length; jj++) {
        JButton b = new JButton();
        b.setMargin(buttonMargin);
        // our chess pieces are 64x64 px in size, so we'll
        // 'fill this in' using a transparent icon..
        ImageIcon icon = new ImageIcon(new BufferedImage(50, 50, BufferedImage.TYPE_INT_ARGB));
        b.setIcon(icon);
        b.setBackground(Color.BLUE);
        playBoardSquares[jj][ii] = b;
      }
    }

    // fill the chess board
    playBoard.add(new JLabel(""));
    // fill the top row
    for (int ii = 0; ii < 10; ii++) {
      playBoard.add(new JLabel(COLS.substring(ii, ii + 1), SwingConstants.CENTER));
    }
    // fill the black non-pawn piece row
    for (int ii = 0; ii < 10; ii++) {
      for (int jj = 0; jj < 10; jj++) {
        switch (jj) {
          case 0:
            playBoard.add(new JLabel("" + (ii + 1), SwingConstants.CENTER));
          default:
            playBoard.add(playBoardSquares[jj][ii]);
        }
      }
    }
  }
Exemplo n.º 5
0
  /**
   * Make the UI for this widget.
   *
   * @param floatToolBar true if the toolbar should be floatable
   * @return UI as a Component
   */
  private JComponent doMakeContents(boolean floatToolBar) {

    String imgp = "/auxdata/ui/icons/";
    KeyListener listener =
        new KeyAdapter() {
          public void keyPressed(KeyEvent e) {
            if ((e.getSource() instanceof JComboBox)) {
              return;
            }
            int code = e.getKeyCode();
            char c = e.getKeyChar();
            if ((code == KeyEvent.VK_RIGHT) || (code == KeyEvent.VK_KP_RIGHT)) {
              if (e.isShiftDown()) {
                gotoIndex(anime.getNumSteps() - 1);
              } else {
                actionPerformed(CMD_FORWARD);
              }
            } else if ((code == KeyEvent.VK_LEFT) || (code == KeyEvent.VK_KP_LEFT)) {
              if (e.isShiftDown()) {
                gotoIndex(0);
              } else {
                actionPerformed(CMD_BACKWARD);
              }
            } else if (code == KeyEvent.VK_ENTER) {
              actionPerformed(CMD_STARTSTOP);
            } else if ((code == KeyEvent.VK_P) && e.isControlDown()) {
              actionPerformed(CMD_PROPS);
            } else if (Character.isDigit(c)) {
              int step = new Integer("" + c).intValue() - 1;
              if (step < 0) {
                step = 0;
              }
              if (step >= anime.getNumSteps()) {
                step = anime.getNumSteps() - 1;
              }
              gotoIndex(step);
            }
          }
        };

    List buttonList = new ArrayList();
    buttonList.add(timesCbx);
    // Update the list of times
    setTimesInTimesBox();

    Dimension preferredSize = timesCbx.getPreferredSize();
    if (preferredSize != null) {
      int height = preferredSize.height;
      if (height < 50) {
        JComponent filler = GuiUtils.filler(3, height);
        buttonList.add(filler);
      }
    }

    String[][] buttonInfo = {
      {"Go to first frame", CMD_BEGINNING, getIcon("Rewind")},
      {"One frame back", CMD_BACKWARD, getIcon("StepBack")},
      {"Run/Stop", CMD_STARTSTOP, getIcon("Play")},
      {"One frame forward", CMD_FORWARD, getIcon("StepForward")},
      {"Go to last frame", CMD_END, getIcon("FastForward")},
      {"Properties", CMD_PROPS, getIcon("Information")}
    };

    for (int i = 0; i < buttonInfo.length; i++) {
      JButton btn = GuiUtils.getScaledImageButton(buttonInfo[i][2], getClass(), 2, 2);
      btn.setToolTipText(buttonInfo[i][0]);
      btn.setActionCommand(buttonInfo[i][1]);
      btn.addActionListener(this);
      btn.addKeyListener(listener);
      //            JComponent wrapper = GuiUtils.center(btn);
      //            wrapper.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
      btn.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
      buttonList.add(btn);
      //            buttonList.add(wrapper);
      if (i == 2) {
        startStopBtn = btn;
      }
    }

    JComponent contents = GuiUtils.hflow(buttonList, 1, 0);
    if (boxPanel == null) {
      boxPanel = new AnimationBoxPanel(this);
      if (timesArray != null) {
        updateBoxPanel(timesArray);
      }
    }
    boxPanel.addKeyListener(listener);
    if (!getBoxPanelVisible()) {
      boxPanel.setVisible(false);
    }
    contents =
        GuiUtils.doLayout(new Component[] {boxPanel, contents}, 1, GuiUtils.WT_Y, GuiUtils.WT_N);
    //      GuiUtils.addKeyListenerRecurse(listener,contents);
    if (floatToolBar) {
      JToolBar toolbar = new JToolBar(JToolBar.HORIZONTAL);
      toolbar.setFloatable(true);
      contents = GuiUtils.left(contents);
      toolbar.add(contents);
      contents = toolbar;
    }

    updateRunButton();
    madeContents = true;
    return contents;
  }
Exemplo n.º 6
0
 public void removeAll() {
   super.removeAll();
   addGrip();
 }
Exemplo n.º 7
0
    /** Create the UI for this editor */
    void makeUI() {

      JPanel mainPanel = new JPanel(new BorderLayout());
      mainPanel.setBorder(new LineBorder(Color.blue));
      getContentPane().add(mainPanel, BorderLayout.CENTER);

      // the map and associated toolbar
      npEditControl = new NPController();
      mapEditPanel = npEditControl.getNavigatedPanel(); // here's where the map will be drawn
      mapEditPanel.setPreferredSize(new Dimension(250, 250));
      mapEditPanel.setSelectRegionMode(true);
      JToolBar navToolbar = mapEditPanel.getNavToolBar();
      navToolbar.setFloatable(false);
      JToolBar moveToolbar = mapEditPanel.getMoveToolBar();
      moveToolbar.setFloatable(false);
      // toolbar.remove("setReference");

      JPanel toolbar = new JPanel();
      List localMaps = maps;
      if (localMaps == null) {
        localMaps = getDefaultMaps();
      }
      JMenu mapMenu = new JMenu("Maps");
      JMenuBar menuHolder = new JMenuBar();
      menuHolder.setBorder(null);
      menuHolder.add(mapMenu);
      toolbar.add(menuHolder);
      for (int mapIdx = 0; mapIdx < localMaps.size(); mapIdx++) {
        final MapData mapData = (MapData) localMaps.get(mapIdx);
        final JCheckBoxMenuItem cbx =
            new JCheckBoxMenuItem(mapData.getDescription(), mapData.getVisible());
        if (mapData.getVisible()) {
          toggleMap(mapData, true);
        }
        mapMenu.add(cbx);
        cbx.addItemListener(
            new ItemListener() {
              public void itemStateChanged(ItemEvent event) {
                toggleMap(mapData, cbx.isSelected());
              }
            });
      }
      GuiUtils.limitMenuSize(mapMenu, "Maps ", 20);

      toolbar.add(navToolbar);
      toolbar.add(moveToolbar);

      JPanel mapSide = new JPanel();
      mapSide.setLayout(new BorderLayout());
      TitledBorder mapBorder =
          new TitledBorder(
              standardBorder, "Edit Projection", TitledBorder.ABOVE_TOP, TitledBorder.CENTER);
      mapSide.setBorder(mapBorder);
      mapSide.add(toolbar, BorderLayout.NORTH);
      mapSide.add(mapEditPanel, BorderLayout.CENTER);
      mainPanel.add(mapSide, BorderLayout.WEST);

      // the projection parameters

      // the Projection name
      JLabel nameLabel = GuiUtils.rLabel("Name: ");
      nameTF = new JTextField(20);

      // the list of Projection classes is kept in a comboBox
      typeLabel = GuiUtils.rLabel("Type: ");
      projClassCB = new JComboBox();
      // standard list of projection classes
      List classNames = getDefaultProjections();
      for (int i = 0; i < classNames.size(); i++) {
        String className = (String) classNames.get(i);
        try {
          projClassCB.addItem(new ProjectionClass(className));
        } catch (ClassNotFoundException ee) {
          System.err.println("ProjectionManager failed on " + className + " " + ee);
        } catch (IntrospectionException ee) {
          System.err.println("ProjectionManager failed on " + className + " " + ee);
        }
      }
      GuiUtils.tmpInsets = new Insets(4, 4, 4, 4);
      JPanel topPanel =
          GuiUtils.doLayout(
              new Component[] {nameLabel, nameTF, typeLabel, projClassCB},
              2,
              GuiUtils.WT_N,
              GuiUtils.WT_N);

      // the Projection parameter area
      paramPanel = new JPanel();
      paramPanel.setLayout(new BorderLayout());
      paramPanel.setBorder(
          new TitledBorder(
              standardBorder,
              "Projection Parameters",
              TitledBorder.ABOVE_TOP,
              TitledBorder.CENTER));

      // the bottom button panel
      JPanel buttPanel = new JPanel();
      JButton acceptButton = new JButton("Save");
      JButton previewButton = new JButton("Preview");
      JButton cancelButton = new JButton("Cancel");
      buttPanel.add(acceptButton, null);
      buttPanel.add(previewButton, null);
      buttPanel.add(cancelButton, null);

      JPanel mainBox = GuiUtils.topCenterBottom(topPanel, paramPanel, buttPanel);
      mainPanel.add(mainBox, BorderLayout.CENTER);
      pack();

      // enable event listeners when we're done constructing the UI
      projClassCB.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              ProjectionClass selectClass = (ProjectionClass) projClassCB.getSelectedItem();
              setProjection(selectClass.makeDefaultProjection());
            }
          });

      acceptButton.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
              accept();
            }
          });
      previewButton.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
              ProjectionClass projClass = findProjectionClass(editProjection);
              if (null != projClass) {
                setProjFromDialog(projClass, editProjection);
                setProjection(editProjection);
              }
            }
          });
      cancelButton.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
              NewProjectionDialog.this.setVisible(false);
            }
          });
    }
Exemplo n.º 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);
  }