Ejemplo n.º 1
0
 public void actionPerformed(ActionEvent e) {
   if (e.getSource() == exitItem) {
     kbc.stopLoop();
     setVisible(false);
     dispose();
   } else if (e.getSource() == saveItem) {
     saveImage();
   } else if (e.getSource() == sleepItem1) {
     setDelay(1);
   } else if (e.getSource() == sleepItem2) {
     setDelay(2);
   } else if (e.getSource() == sleepItem5) {
     setDelay(5);
   } else if (e.getSource() == sleepItem10) {
     setDelay(10);
   } else if (e.getSource() instanceof JCheckBoxMenuItem) {
     JCheckBoxMenuItem jmi = (JCheckBoxMenuItem) e.getSource();
     String stat = jmi.getText();
     if (jmi.isSelected()) {
       kbc.addStatistic(stat);
     } else {
       kbc.removeStatistic(stat);
     }
   }
 }
Ejemplo n.º 2
0
    @Override
    public void actionPerformed(ActionEvent evt) {
      JCheckBoxMenuItem menuItem = (JCheckBoxMenuItem) evt.getSource();
      boolean curState = menuItem.isSelected();

      TreePath path = resultTree.getSelectionPath();
      DefaultMutableTreeNode operNode = (DefaultMutableTreeNode) path.getLastPathComponent();

      HyperSearchOperationNode operNodeObj = (HyperSearchOperationNode) operNode.getUserObject();
      if (curState) operNodeObj.cacheResultNodes(operNode);
      operNode.removeAllChildren();
      if (curState) {
        Exception excp = null;
        try {
          operNodeObj.insertTreeNodes(resultTree, operNode);
        } catch (Exception ex) {
          operNodeObj.restoreFlatNodes(resultTree, operNode);
          menuItem.setSelected(false);
          excp = ex;
        } finally {
          ((DefaultTreeModel) resultTree.getModel()).nodeStructureChanged(operNode);
          expandAllNodes(operNode);
          resultTree.scrollPathToVisible(new TreePath(operNode.getPath()));
        }
        if (excp != null) throw new RuntimeException(excp);
      } else operNodeObj.restoreFlatNodes(resultTree, operNode);

      operNodeObj.setTreeViewDisplayed(menuItem.isSelected());
    }
Ejemplo n.º 3
0
            public void actionPerformed(ActionEvent e) {
              blurItem.setEnabled(!disablingItem.isSelected());
              embossItem.setEnabled(!disablingItem.isSelected());
              busyPainterItem.setEnabled(!disablingItem.isSelected());

              busyPainterUI.setLocked(disablingItem.isSelected());
            }
Ejemplo n.º 4
0
 /** Unconfigures a JCheckBoxMenuItem for an Action. */
 public static void unconfigureJCheckBoxMenuItem(JCheckBoxMenuItem mi, Action a) {
   PropertyChangeListener propertyHandler =
       (PropertyChangeListener) mi.getClientProperty("actionPropertyHandler");
   if (propertyHandler != null) {
     a.removePropertyChangeListener(propertyHandler);
     mi.putClientProperty("actionPropertyHandler", null);
   }
 }
Ejemplo n.º 5
0
 /**
  * Create the Statistics Menu, showing all available statistics for the chosen ChartableKstat.
  *
  * @param cks the ChartableKstat to show the statistics of in the menu
  * @param statistics the initial statistics, which will be checked
  * @return the Statistics Menu
  */
 protected JMenu statisticsMenu(ChartableKstat cks, List<String> statistics) {
   JMenu jmstat = new JMenu(KstatResources.getString("CHART.SHOW"));
   jmstat.setMnemonic(KeyEvent.VK_S);
   for (String stat : cks.getStatistics()) {
     JCheckBoxMenuItem jmi = new JCheckBoxMenuItem(stat, statistics.contains(stat));
     jmi.addActionListener(this);
     jmstat.add(jmi);
   }
   return jmstat;
 }
Ejemplo n.º 6
0
 public void actionPerformed(ActionEvent e) {
   super.actionPerformed(e);
   JMenuItem jmi = (JMenuItem) e.getSource();
   if (displayset.contains(jmi)) {
     mainPanel.setNames(jmi.getText());
   } else if (jmi == hiddenItem) {
     mainPanel.showIgnored(hiddenItem.isSelected());
   } else if (jmi == aggrItem) {
     mainPanel.showAggregates(aggrItem.isSelected());
   }
 }
Ejemplo n.º 7
0
  public void showForCreation() {

    hiddenObstacle.setSelected(false);
    hiddenObstacle.setEnabled(false);
    for (JRadioButton tof : typeOfFood) {
      tof.setEnabled(true);
    }
    newCreatureButton.setEnabled(true);
    newJewelButton.setEnabled(true);
    group.setSelected(model, true);
  }
Ejemplo n.º 8
0
  private void generateMenus() {

    _menuBar = new JMenuBar();

    JMenu menuFile = new JMenu("File");
    JMenu menuGame = new JMenu("Game");
    JMenu menuHelp = new JMenu("Help");

    menuFile.setMnemonic('f');
    menuGame.setMnemonic('g');
    menuHelp.setMnemonic('h');

    JMenuItem menuFileExit = new JMenuItem("Exit", 'x');
    JMenuItem menuFileNew = new JMenuItem("New", 'n');

    _menuGameGo = new JMenuItem("Go", 'g');
    _menuGamePause = new JMenuItem("Pause", 'p');
    _menuGamePause.setEnabled(false);

    JCheckBoxMenuItem menuGameZoomToggle = new JCheckBoxMenuItem("Zoom 2X", false);
    menuGameZoomToggle.setMnemonic('z');

    JMenuItem menuGameOptions = new JMenuItem("Options...", 'o');

    JMenuItem menuHelpAbout = new JMenuItem("About", 'a');

    menuFileExit.addActionListener(this);
    menuFileNew.addActionListener(this);

    _menuGameGo.addActionListener(this);
    _menuGamePause.addActionListener(this);
    menuGameZoomToggle.addActionListener(this);
    menuGameOptions.addActionListener(this);

    menuHelpAbout.addActionListener(this);

    menuFile.add(menuFileNew);
    menuFile.add(menuFileExit);

    menuGame.add(_menuGameGo);
    menuGame.add(_menuGamePause);
    menuGame.add(menuGameZoomToggle);
    menuGame.add(menuGameOptions);

    menuHelp.add(menuHelpAbout);

    _menuBar.add(menuFile);
    _menuBar.add(menuGame);
    _menuBar.add(menuHelp);

    setJMenuBar(_menuBar);
  }
Ejemplo n.º 9
0
 /** Configures a JCheckBoxMenuItem for an Action. */
 public static void configureJCheckBoxMenuItem(final JCheckBoxMenuItem mi, final Action a) {
   mi.setSelected((Boolean) a.getValue(Actions.SELECTED_KEY));
   PropertyChangeListener propertyHandler =
       new PropertyChangeListener() {
         public void propertyChange(PropertyChangeEvent evt) {
           if (evt.getPropertyName().equals(Actions.SELECTED_KEY)) {
             mi.setSelected((Boolean) a.getValue(Actions.SELECTED_KEY));
           }
         }
       };
   a.addPropertyChangeListener(propertyHandler);
   mi.putClientProperty("actionPropertyHandler", propertyHandler);
 }
Ejemplo n.º 10
0
  public Vector getItems() {
    Vector items = new Vector();

    ActionListener al = new PopupMenuHandler();

    JMenuItem colorItem = new JMenuItem(colorString);
    colorItem.addActionListener(al);
    items.addElement(colorItem);

    JCheckBoxMenuItem dashedItem = new JCheckBoxMenuItem(dashedString);
    dashedItem.setSelected(dashed);
    dashedItem.addActionListener(al);
    items.addElement(dashedItem);

    return items;
  }
Ejemplo n.º 11
0
  // enable/disable all menu items/actions
  private void setAllEnabled(boolean enabled) {
    DbgOutput.println(2, "enabled: " + enabled);
    fileMenu.setEnabled(enabled);
    newItem.setEnabled(enabled);
    openItem.setEnabled(enabled);
    closeItem.setEnabled(enabled);
    // dumpItem.setEnabled(enabled);
    flushItem.setEnabled(enabled);
    optionsItem.setEnabled(enabled);
    settingsItem.setEnabled(enabled);

    debugMenu.setEnabled(enabled);
    stepAction.setEnabled(enabled);
    stopAction.setEnabled(enabled);
    cancelAction.setEnabled(enabled);
    nextAction.setEnabled(enabled);
    contAction.setEnabled(enabled);
    breakpointsItem.setEnabled(enabled);

    opsMenu.setEnabled(enabled);
    insertItem.setEnabled(enabled);
    deleteItem.setEnabled(enabled);
    searchItem.setEnabled(enabled);
    executeItem.setEnabled(enabled);

    treeStatsMenu.setEnabled(enabled);
    utilItem.setEnabled(enabled);
    predSzItem.setEnabled(enabled);
    slotCntItem.setEnabled(enabled);

    analysisMenu.setEnabled(enabled);
    newAnalysisItem.setEnabled(enabled);
    openAnalysisItem.setEnabled(enabled);
    completeAnalysisItem.setEnabled(enabled);
    wkldStatsItem.setEnabled(enabled);
    splitStatsItem.setEnabled(enabled);
    penaltyStatsItem.setEnabled(enabled);

    // these are never disabled
    windowsMenu.setEnabled(true);
    showCmdsItem.setEnabled(true);
    showResultsItem.setEnabled(true);
    showTraceItem.setEnabled(true);
    tileItem.setEnabled(true);
  }
Ejemplo n.º 12
0
    public DescPropPopup() {
      super("Descriptor Properties");
      v = new JCheckBoxMenuItem("Valid");
      v.addActionListener(new ValidAction());
      p = new JCheckBoxMenuItem("Propagating");
      p.addActionListener(new PropAction());
      delete = new JMenuItem("Delete");
      delete.addActionListener(new DeleteAction());
      duplicate = new JMenuItem("Duplicate");
      duplicate.addActionListener(new DuplicateAction());
      interp = new JMenuItem("Interpolate...");
      interp.addActionListener(new InterpAction());
      interpToMark = new JMenu("Interpolate to Mark");
      interpToMark.setEnabled(false);
      itmAction = new InterpToMarkAction();
      shift = new JMenuItem("Shift...");
      shift.addActionListener(new ShiftAction());
      shiftToMark = new JMenu("Shift to Mark");
      shiftToMark.setEnabled(false);
      stmAction = new ShiftToMarkAction();

      occlusions = new JMenuItem("Occlusions...");
      occAction = new OccAction();
      occlusions.addActionListener(occAction);
      occSeparator = new JSeparator();

      wrt = new JCheckBoxMenuItem("Display with Respect To", false);
      wrt.addActionListener(new WithRespectToAction());

      add(occlusions);
      add(occSeparator);
      add(v);
      add(p);
      add(occSeparator);
      add(delete);
      add(duplicate);
      add(occSeparator);
      add(interp);
      add(interpToMark);
      add(occSeparator);
      add(shift);
      add(shiftToMark);
      add(occSeparator);
      add(wrt);
    }
Ejemplo n.º 13
0
  public void setFood(Thing fd) {
    this.food = fd;
    ta.setText("                                     " + this.food.getMyName());
    if (((Food) this.food).perishable) {
      typeOfFood.get(1).setSelected(true);
    } else {
      typeOfFood.get(0).setSelected(true);
    }

    hiddenObstacle.setEnabled(true);
    if (food.returnIfWasHidden()) {
      hiddenObstacle.setSelected(true);

    } else {
      hiddenObstacle.setSelected(false);
    }
    setVisible(false);
  }
Ejemplo n.º 14
0
 private JComponent createToolPanel() {
   JComponent box = Box.createVerticalBox();
   JCheckBox button = new JCheckBox(disablingItem.getText());
   button.setModel(disablingItem.getModel());
   box.add(Box.createGlue());
   box.add(button);
   box.add(Box.createGlue());
   JRadioButton blur = new JRadioButton(blurItem.getText());
   blur.setModel(blurItem.getModel());
   box.add(blur);
   JRadioButton emboss = new JRadioButton(embossItem.getText());
   emboss.setModel(embossItem.getModel());
   box.add(emboss);
   JRadioButton translucent = new JRadioButton(busyPainterItem.getText());
   translucent.setModel(busyPainterItem.getModel());
   box.add(translucent);
   box.add(Box.createGlue());
   return box;
 }
Ejemplo n.º 15
0
  /** Create the menu bar for the GUI */
  private void createMenu() {
    // Create menu bar
    menuBar = new JMenuBar();
    clientFrame.setJMenuBar(menuBar);

    // Create menus
    fileMenu = new JMenu("File");
    helpMenu = new JMenu("Help");

    // Add menus to bar
    menuBar.add(fileMenu);
    menuBar.add(helpMenu);

    // Create File Menu Items
    hostItem = new JCheckBoxMenuItem("Allow Uploads", true);
    portItem = new JCheckBoxMenuItem("Use Passive Mode", true);
    exitItem = new JMenuItem("Exit");

    // Add Items to File Menu
    fileMenu.add(hostItem);
    fileMenu.add(portItem);
    fileMenu.addSeparator();
    fileMenu.add(exitItem);

    // Create Help Menu Items
    helpItem = new JMenuItem("Help");
    aboutItem = new JMenuItem("About LeetFTP");

    // Add Items to Help Menu
    helpMenu.add(helpItem);
    helpMenu.addSeparator();
    helpMenu.add(aboutItem);

    // Create menu action handler and set it active
    MenuHandler menuHandler = new MenuHandler();

    hostItem.addActionListener(menuHandler);
    portItem.addActionListener(menuHandler);
    exitItem.addActionListener(menuHandler);
    helpItem.addActionListener(menuHandler);
    aboutItem.addActionListener(menuHandler);
  }
Ejemplo n.º 16
0
 private void createWindowsMenu() {
   windowsMenu = new JMenu("Windows");
   menuBar.add(windowsMenu);
   showCmdsItem = new JCheckBoxMenuItem("Show Commands");
   showCmdsItem.setState(true);
   windowsMenu.add(showCmdsItem);
   showResultsItem = new JCheckBoxMenuItem("Show Results");
   showResultsItem.setState(true);
   windowsMenu.add(showResultsItem);
   showTraceItem = new JCheckBoxMenuItem("Show Trace Output");
   showTraceItem.setState(true);
   windowsMenu.add(showTraceItem);
   tileItem = new JMenuItem("Tile");
   tileItem.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent event) {
           MainWindow.this.tile();
         }
       });
   windowsMenu.add(tileItem);
 }
Ejemplo n.º 17
0
  public void update() {

    newCreatureButton.setEnabled(false);
    newJewelButton.setEnabled(false);

    if (food != null) {

      for (JRadioButton tof : typeOfFood) {
        tof.setEnabled(false);
      }
      group.setSelected(model, false);

      hiddenObstacle.setEnabled(true);
      if (food.returnIfWasHidden()) {
        hiddenObstacle.setSelected(true);

      } else {
        hiddenObstacle.setSelected(false);
      }
    }
  }
Ejemplo n.º 18
0
    public void mabeShowPopup(MouseEvent e) {

      if (e.isPopupTrigger()) {

        final JPopupMenu contextMenu = new JPopupMenu();

        int row = view.getTable().rowAtPoint(e.getPoint());
        ListTableModel<PatientModel> tModel = getTableModel();
        PatientModel obj = tModel.getObject(row);
        int selected = view.getTable().getSelectedRow();

        if (row == selected && obj != null) {
          contextMenu.add(
              new JMenuItem(new ReflectAction("カルテを開く", PatientSearchImpl.this, "openKarte")));
          contextMenu.addSeparator();
          // s.oh^ 2014/08/19 ID権限
          // contextMenu.add(new JMenuItem(copyAction));
          // contextMenu.add(new JMenuItem(new ReflectAction("受付登録", PatientSearchImpl.this,
          // "addAsPvt")));
          // contextMenu.addSeparator();
          if (!Project.isOtherCare()) {
            contextMenu.add(new JMenuItem(copyAction));
            contextMenu.add(
                new JMenuItem(new ReflectAction("受付登録", PatientSearchImpl.this, "addAsPvt")));
            contextMenu.addSeparator();
          }
          // s.oh$
        }

        JCheckBoxMenuItem item = new JCheckBoxMenuItem("年齢表示");
        contextMenu.add(item);
        item.setSelected(ageDisplay);
        item.addActionListener(
            (ActionListener)
                EventHandler.create(
                    ActionListener.class, PatientSearchImpl.this, "switchAgeDisplay"));

        contextMenu.show(e.getComponent(), e.getX(), e.getY());
      }
    }
Ejemplo n.º 19
0
  private JMenuBar createMenuBar() {
    JMenu menu = new JMenu("Menu");

    disablingItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_D, InputEvent.ALT_MASK));

    menu.add(disablingItem);
    menu.addSeparator();

    blurItem.setSelected(true);
    blurItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_1, InputEvent.ALT_MASK));
    menu.add(blurItem);

    embossItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_2, InputEvent.ALT_MASK));
    menu.add(embossItem);

    busyPainterItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_3, InputEvent.ALT_MASK));
    menu.add(busyPainterItem);

    ButtonGroup group = new ButtonGroup();
    group.add(blurItem);
    group.add(embossItem);
    group.add(busyPainterItem);

    ItemListener menuListener =
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            if (blurItem.isSelected()) {
              //                    layer.setUI(blurUI);
            } else if (embossItem.isSelected()) {
              //                    layer.setUI(embossUI);
            } else if (busyPainterItem.isSelected()) {
              layer.setUI(busyPainterUI);
            }
          }
        };

    blurItem.addItemListener(menuListener);
    embossItem.addItemListener(menuListener);
    busyPainterItem.addItemListener(menuListener);

    //        embossUI.getUnlockButton().addActionListener(new ActionListener() {
    //            public void actionPerformed(ActionEvent e) {
    //                disablingItem.doClick();
    //            }
    //        });

    JMenuBar bar = new JMenuBar();
    bar.add(menu);

    bar.add(new LafMenu());
    return bar;
  }
Ejemplo n.º 20
0
 /**
  * Add the correct key listeners to the search text field, depending on whether and autocomplete
  * listener has been set and whether incremental search is selected.
  */
 private void updateKeyListeners() {
   KeyListener[] listeners = searchField.getKeyListeners();
   for (KeyListener listener : listeners) {
     searchField.removeKeyListener(listener);
   }
   if (increment.isSelected()) {
     searchField.addKeyListener(this);
   } else {
     if (searchAutoComplete.isSelected() && (autoCompleteListener != null)) {
       searchField.addKeyListener(autoCompleteListener);
     }
   }
 }
Ejemplo n.º 21
0
 public void updatePrefs() {
   Globals.prefs.putBoolean(JabRefPreferences.SEARCH_REQ, searchReq.isSelected());
   Globals.prefs.putBoolean(JabRefPreferences.SEARCH_OPT, searchOpt.isSelected());
   Globals.prefs.putBoolean(JabRefPreferences.SEARCH_GEN, searchGen.isSelected());
   Globals.prefs.putBoolean(JabRefPreferences.SEARCH_ALL, searchAll.isSelected());
   Globals.prefs.putBoolean(JabRefPreferences.INCREMENT_S, increment.isSelected());
   Globals.prefs.putBoolean(JabRefPreferences.SELECT_S, select.isSelected());
   Globals.prefs.putBoolean(JabRefPreferences.FLOAT_SEARCH, floatSearch.isSelected());
   Globals.prefs.putBoolean(JabRefPreferences.CASE_SENSITIVE_SEARCH, caseSensitive.isSelected());
   Globals.prefs.putBoolean(JabRefPreferences.REG_EXP_SEARCH, regExpSearch.isSelected());
   Globals.prefs.putBoolean(JabRefPreferences.HIGH_LIGHT_WORDS, highLightWords.isSelected());
   Globals.prefs.putBoolean(
       JabRefPreferences.SHOW_SEARCH_IN_DIALOG, showResultsInDialog.isSelected());
   Globals.prefs.putBoolean(JabRefPreferences.SEARCH_ALL_BASES, searchAllBases.isSelected());
 }
Ejemplo n.º 22
0
  /**
   * Create a JFSstat demo.
   *
   * @param jkstat a JKstat object
   * @param standalone if false, indicates that this demo is being called from another application
   */
  public JFSstat(JKstat jkstat, boolean standalone) {
    super("jfsstat", standalone);

    mainPanel = new JFSstatPanel(jkstat, DEFAULT_INTERVAL);

    setContentPane(mainPanel);

    addInfoPanel(mainPanel, sversion);

    displayset = new HashSet<JRadioButtonMenuItem>();
    JMenu displayMenu = new JMenu(SolViewResources.getString("FSSTAT.DISPLAY.TEXT"));
    displayMenu.setMnemonic(KeyEvent.VK_D);
    String curtitle = mainPanel.currentTitle();
    ButtonGroup displayGroup = new ButtonGroup();
    for (String title : mainPanel.titles()) {
      JRadioButtonMenuItem jmis = new JRadioButtonMenuItem(title, title.equals(curtitle));
      displayMenu.add(jmis);
      displayGroup.add(jmis);
      displayset.add(jmis);
      jmis.addActionListener(this);
    }
    addMenu(displayMenu);

    JMenu showMenu = new JMenu(SolViewResources.getString("FSSTAT.SHOW.TEXT"));
    showMenu.setMnemonic(KeyEvent.VK_S);
    hiddenItem = new JCheckBoxMenuItem(SolViewResources.getString("FSSTAT.HIDDEN.TEXT"), false);
    hiddenItem.addActionListener(this);
    showMenu.add(hiddenItem);
    aggrItem = new JCheckBoxMenuItem(SolViewResources.getString("FSSTAT.FSTYPE.TEXT"), false);
    aggrItem.addActionListener(this);
    showMenu.add(aggrItem);
    addMenu(showMenu);

    setSize(620, 250);
    validate();
    setVisible(true);
  }
Ejemplo n.º 23
0
    // {{{ showPopupMenu method
    private void showPopupMenu(MouseEvent evt) {
      TreePath path = resultTree.getSelectionPath();
      DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();

      popupMenu = new JPopupMenu();
      Object userObj = node.getUserObject();
      if (userObj instanceof HyperSearchFileNode || userObj instanceof HyperSearchResult) {
        popupMenu.add(new GoToNodeAction("hypersearch-results.open", M_OPEN));
        popupMenu.add(new GoToNodeAction("hypersearch-results.open-view", M_OPEN_NEW_VIEW));
        popupMenu.add(
            new GoToNodeAction("hypersearch-results.open-plain-view", M_OPEN_NEW_PLAIN_VIEW));
        popupMenu.add(new GoToNodeAction("hypersearch-results.open-split", M_OPEN_NEW_SPLIT));
      }
      if (!(userObj instanceof HyperSearchFolderNode)) popupMenu.add(new RemoveTreeNodeAction());
      popupMenu.add(new ExpandChildTreeNodesAction());
      if (userObj instanceof HyperSearchFolderNode || userObj instanceof HyperSearchOperationNode) {
        popupMenu.add(new CollapseChildTreeNodesAction());
        if (userObj instanceof HyperSearchFolderNode) popupMenu.add(new NewSearchAction());
      }
      if (userObj instanceof HyperSearchOperationNode) {
        popupMenu.add(new JPopupMenu.Separator());
        HyperSearchOperationNode resultNode = (HyperSearchOperationNode) userObj;
        JCheckBoxMenuItem chkItem =
            new JCheckBoxMenuItem(
                jEdit.getProperty("hypersearch-results.tree-view"),
                resultNode.isTreeViewDisplayed());
        chkItem.addActionListener(new TreeDisplayAction());
        popupMenu.add(chkItem);

        popupMenu.add(new RedoSearchAction((HyperSearchOperationNode) userObj));
      }
      popupMenu.add(new CopyToClipboardAction());

      GUIUtilities.showPopupMenu(popupMenu, evt.getComponent(), evt.getX(), evt.getY());
      evt.consume();
    } // }}}
Ejemplo n.º 24
0
  /**
   * Make the view menu
   *
   * @param viewMenu view menu
   * @return The view menu
   */
  public JMenu makeViewMenu(JMenu viewMenu) {
    showAlignmentPointsMI = new JCheckBoxMenuItem("Show Alignment Points", true);
    viewMenu.add(showAlignmentPointsMI);
    showAlignmentPointsMI.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            repaint();
          }
        });

    viewMenu.addSeparator();
    super.makeViewMenu(viewMenu);
    viewMenu.addSeparator();
    viewMenu.add(makeMenuItem("Black background", CMD_BLACKBG));
    viewMenu.add(makeMenuItem("White background", CMD_WHITEBG));
    return viewMenu;
  }
Ejemplo n.º 25
0
    public void show(Component invoker, int x, int y) {
      ViperViewMediator mediator = getMediator();
      Point pnt = new Point(x, y);
      EnhancedTable tab = getTable();
      int row = tab.rowAtPoint(pnt);
      desc = getCurrentModel().getDescriptorAtRow(row);
      int col = tab.columnAtPoint(pnt);
      Object cellValue = tab.getValueAt(row, col);
      if (cellValue instanceof Attribute) {
        attr = (Attribute) cellValue;

        // hide the "Occlusions..." option when we're not dealing with a Textline object
        boolean isTextline = attr.getAttrConfig().getAttrType().endsWith("textline");
        occlusions.setVisible(isTextline);
        occSeparator.setVisible(isTextline);

        Instant now = mediator.getCurrentFrame();
        if (now == null) {
          mediator.getDisplayWRTManager().setAttribute(null, null);
          wrt.setEnabled(false);
          wrt.setSelected(false);
        } else {
          boolean isDwrt = attr == mediator.getDisplayWRTManager().getAttribute();
          boolean dwrtable =
              (attr.getAttrValueAtInstant(now) instanceof HasCentroid
                  && attr.getDescriptor().getValidRange().contains(now));
          wrt.setEnabled(dwrtable);
          wrt.setSelected(isDwrt);
        }
      } else {
        attr = null;
        wrt.setEnabled(false);
        wrt.setSelected(false);
      }
      if (null != desc) {
        PropagateInterpolateModule proper = getMediator().getPropagator();
        p.setSelected(proper.isPropagatingThis(desc));
        v.setSelected(mediator.isThisValidNow(desc));
        resetMarks();
        super.show(invoker, x, y);
      }
    }
Ejemplo n.º 26
0
  /**
   * Handles the <tt>ActionEvent</tt> generated when user presses one of the buttons in this panel.
   */
  public void actionPerformed(ActionEvent evt) {
    JButton button = (JButton) evt.getSource();
    String buttonName = button.getName();

    if (buttonName.equals("call")) {
      Component selectedPanel = mainFrame.getSelectedTab();

      // call button is pressed over an already open call panel
      if (selectedPanel != null
          && selectedPanel instanceof CallPanel
          && ((CallPanel) selectedPanel).getCall().getCallState()
              == CallState.CALL_INITIALIZATION) {

        NotificationManager.stopSound(NotificationManager.BUSY_CALL);
        NotificationManager.stopSound(NotificationManager.INCOMING_CALL);

        CallPanel callPanel = (CallPanel) selectedPanel;

        Iterator participantPanels = callPanel.getParticipantsPanels();

        while (participantPanels.hasNext()) {
          CallParticipantPanel panel = (CallParticipantPanel) participantPanels.next();

          panel.setState("Connecting");
        }

        Call call = callPanel.getCall();

        answerCall(call);
      }
      // call button is pressed over the call list
      else if (selectedPanel != null
          && selectedPanel instanceof CallListPanel
          && ((CallListPanel) selectedPanel).getCallList().getSelectedIndex() != -1) {

        CallListPanel callListPanel = (CallListPanel) selectedPanel;

        GuiCallParticipantRecord callRecord =
            (GuiCallParticipantRecord) callListPanel.getCallList().getSelectedValue();

        String stringContact = callRecord.getParticipantName();

        createCall(stringContact);
      }
      // call button is pressed over the contact list
      else if (selectedPanel != null && selectedPanel instanceof ContactListPanel) {
        // call button is pressed when a meta contact is selected
        if (isCallMetaContact) {
          Object[] selectedContacts =
              mainFrame.getContactListPanel().getContactList().getSelectedValues();

          Vector telephonyContacts = new Vector();

          for (int i = 0; i < selectedContacts.length; i++) {

            Object o = selectedContacts[i];

            if (o instanceof MetaContact) {

              Contact contact =
                  ((MetaContact) o).getDefaultContact(OperationSetBasicTelephony.class);

              if (contact != null) telephonyContacts.add(contact);
              else {
                new ErrorDialog(
                        this.mainFrame,
                        Messages.getI18NString("warning").getText(),
                        Messages.getI18NString(
                                "contactNotSupportingTelephony",
                                new String[] {((MetaContact) o).getDisplayName()})
                            .getText())
                    .showDialog();
              }
            }
          }

          if (telephonyContacts.size() > 0) createCall(telephonyContacts);

        } else if (!phoneNumberCombo.isComboFieldEmpty()) {

          // if no contact is selected checks if the user has chosen
          // or has
          // writen something in the phone combo box

          String stringContact = phoneNumberCombo.getEditor().getItem().toString();

          createCall(stringContact);
        }
      } else if (selectedPanel != null && selectedPanel instanceof DialPanel) {
        String stringContact = phoneNumberCombo.getEditor().getItem().toString();
        createCall(stringContact);
      }
    } else if (buttonName.equalsIgnoreCase("hangup")) {
      Component selectedPanel = this.mainFrame.getSelectedTab();

      if (selectedPanel != null && selectedPanel instanceof CallPanel) {

        NotificationManager.stopSound(NotificationManager.BUSY_CALL);
        NotificationManager.stopSound(NotificationManager.INCOMING_CALL);
        NotificationManager.stopSound(NotificationManager.OUTGOING_CALL);

        CallPanel callPanel = (CallPanel) selectedPanel;

        Call call = callPanel.getCall();

        if (removeCallTimers.containsKey(callPanel)) {
          ((Timer) removeCallTimers.get(callPanel)).stop();
          removeCallTimers.remove(callPanel);
        }

        removeCallPanel(callPanel);

        if (call != null) {
          ProtocolProviderService pps = call.getProtocolProvider();

          OperationSetBasicTelephony telephony = mainFrame.getTelephonyOpSet(pps);

          Iterator participants = call.getCallParticipants();

          while (participants.hasNext()) {
            try {
              // now we hang up the first call participant in the
              // call
              telephony.hangupCallParticipant((CallParticipant) participants.next());
            } catch (OperationFailedException e) {
              logger.error("Hang up was not successful: " + e);
            }
          }
        }
      }
    } else if (buttonName.equalsIgnoreCase("minimize")) {
      JCheckBoxMenuItem hideCallPanelItem =
          mainFrame.getMainMenu().getViewMenu().getHideCallPanelItem();

      if (!hideCallPanelItem.isSelected()) hideCallPanelItem.setSelected(true);

      this.setCallPanelVisible(false);
    } else if (buttonName.equalsIgnoreCase("restore")) {

      JCheckBoxMenuItem hideCallPanelItem =
          mainFrame.getMainMenu().getViewMenu().getHideCallPanelItem();

      if (hideCallPanelItem.isSelected()) hideCallPanelItem.setSelected(false);

      this.setCallPanelVisible(true);
    }
  }
Ejemplo n.º 27
0
    public static void makeMenuBar(JFrame frame, final AirspaceBuilderController controller) {
      JMenuBar menuBar = new JMenuBar();
      final JCheckBoxMenuItem resizeNewShapesItem;
      final JCheckBoxMenuItem enableEditItem;

      JMenu menu = new JMenu("File");
      {
        JMenuItem item = new JMenuItem("Open...");
        item.setAccelerator(
            KeyStroke.getKeyStroke(
                KeyEvent.VK_O, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
        item.setActionCommand(OPEN);
        item.addActionListener(controller);
        menu.add(item);

        item = new JMenuItem("Open URL...");
        item.setActionCommand(OPEN_URL);
        item.addActionListener(controller);
        menu.add(item);

        item = new JMenuItem("Save...");
        item.setAccelerator(
            KeyStroke.getKeyStroke(
                KeyEvent.VK_S, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
        item.setActionCommand(SAVE);
        item.addActionListener(controller);
        menu.add(item);

        menu.addSeparator();

        item = new JMenuItem("Load Demo Shapes");
        item.setActionCommand(OPEN_DEMO_AIRSPACES);
        item.addActionListener(controller);
        menu.add(item);
      }
      menuBar.add(menu);

      menu = new JMenu("Shape");
      {
        JMenu subMenu = new JMenu("New");
        for (final AirspaceFactory factory : defaultAirspaceFactories) {
          JMenuItem item = new JMenuItem(factory.toString());
          item.addActionListener(
              new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                  controller.createNewEntry(factory);
                }
              });
          subMenu.add(item);
        }
        menu.add(subMenu);

        resizeNewShapesItem = new JCheckBoxMenuItem("Fit new shapes to viewport");
        resizeNewShapesItem.setActionCommand(SIZE_NEW_SHAPES_TO_VIEWPORT);
        resizeNewShapesItem.addActionListener(controller);
        resizeNewShapesItem.setState(controller.isResizeNewShapesToViewport());
        menu.add(resizeNewShapesItem);

        enableEditItem = new JCheckBoxMenuItem("Enable shape editing");
        enableEditItem.setActionCommand(ENABLE_EDIT);
        enableEditItem.addActionListener(controller);
        enableEditItem.setState(controller.isEnableEdit());
        menu.add(enableEditItem);
      }
      menuBar.add(menu);

      menu = new JMenu("Selection");
      {
        JMenuItem item = new JMenuItem("Deselect");
        item.setAccelerator(
            KeyStroke.getKeyStroke(
                KeyEvent.VK_D, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
        item.setActionCommand(CLEAR_SELECTION);
        item.addActionListener(controller);
        menu.add(item);

        item = new JMenuItem("Delete");
        item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0));
        item.setActionCommand(REMOVE_SELECTED);
        item.addActionListener(controller);
        menu.add(item);
      }
      menuBar.add(menu);

      frame.setJMenuBar(menuBar);

      controller.addPropertyChangeListener(
          new PropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent e) {
              if (SIZE_NEW_SHAPES_TO_VIEWPORT.equals((e.getPropertyName()))) {
                resizeNewShapesItem.setSelected(controller.isResizeNewShapesToViewport());
              } else if (ENABLE_EDIT.equals(e.getPropertyName())) {
                enableEditItem.setSelected(controller.isEnableEdit());
              }
            }
          });
    }
Ejemplo n.º 28
0
  // Method builds menu action listeners.
  private void buildMenuActionListeners() {
    /*
    || Section adds action listeners to window frame menus:
    || ===================================================
    ||  - Menu file:
    ||    ---------
    ||    - menuItemSend
    ||    - menuItemReceive
    ||    - menuItemExit
    ||
    ||  - Menu edit:
    ||    ---------
    ||    - menuItemHelp
    */

    // ---------------------------------/
    // Menu item listeners to file menu.
    // ---------------------------------/

    menuItemNew.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // New file.
            newFile();
          } // End of actionPerformed method.
        }); // End of menuItemNew action listener.

    menuItemOpen.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // Open file.
            openFile();
          } // End of actionPerformed method.
        }); // End of menuItemOpen action listener.

    menuItemClose.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // Close file.
            closeFile();
          } // End of actionPerformed method.
        }); // End of menuItemClose action listener.

    menuItemSave.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // Save current sender JTextAreaPanel String as current file.
            saveFile();
          } // End of actionPerformed method.
        }); // End of menuItemSave action listener.

    menuItemSaveAs.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // Save current sender JTextAreaPanel String as new file.
            saveAsFile();
          } // End of actionPerformed method.
        }); // End of menuItemSaveAs action listener.

    menuItemExit.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // Exit the system on menu exit.
            System.exit(0);
          } // End of actionPerformed() method.
        }); // End of menuItemExit action listener.

    menuItemSend.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // Send message.
            setMessage(sender, receiver);
          } // End of actionPerformed() method.
        }); // End of menuItemSend action listener.

    menuItemReceive.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // Receive message.
            getMessage(receiver);
          } // End of actionPerformed() method.
        }); // End of menuItemReceive action listener.

    menuItemConnect.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // Functionality to be implemented.
            System.out.println("This is future functionality to Connect to DB.");
          } // End of actionPerformed() method.
        }); // End of menuItemConnect action listener.

    menuItemSubmit.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // Functionality to be implemented.
            System.out.println("This is future functionality to Submit SQL.");
          } // End of actionPerformed() method.
        }); // End of menuItemSubmit action listener.

    // ---------------------------------/
    // Menu item listeners to help menu.
    // ---------------------------------/

    // Add menu item listeners for debug check box menu item.
    menuCheckBoxItemDebug.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            // Set stack trace enablement to opposite state.
            setDebugEnabled(!getDebugEnabled());
          } // End of actionPerformed method.
        }); // End of menuCheckBoxItemDebug item listener.

    // Add menu item action listener for help menu.
    menuItemHelp.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // Call inner class help handler.
            new HelpHandler(JMessagingFrame.this, true);
          } // End of actionPerformed() method.
        }); // End of menuItemHelp action listener.
  } // End of buildMenuActionListeners() method.
Ejemplo n.º 29
0
  // Method builds menu components.
  private JMenuBar buildMenu() {
    // Add menus to the menu bar.
    menuBar.add(file);
    menuBar.add(comm);
    menuBar.add(data);
    menuBar.add(help);

    // Set mnemonics for menu selections.
    file.setMnemonic('F');
    comm.setMnemonic('C');
    data.setMnemonic('D');
    help.setMnemonic('H');

    // Menu items for file menu.
    file.add(menuItemNew);
    file.addSeparator();
    file.add(menuItemOpen);
    file.add(menuItemClose);
    file.addSeparator();
    file.add(menuItemSave);
    file.add(menuItemSaveAs);
    file.addSeparator();
    file.add(menuItemExit);

    // Menu items for comm menu.
    comm.add(menuItemSend);
    comm.add(menuItemReceive);

    // Menu items for comm menu.
    data.add(menuItemConnect);
    data.add(menuItemSubmit);

    // Set mnemonics for menu item selections for file menu.
    menuItemNew.setMnemonic('N');
    menuItemOpen.setMnemonic('O');
    menuItemClose.setMnemonic('C');
    menuItemSave.setMnemonic('S');
    menuItemSaveAs.setMnemonic('A');
    menuItemExit.setMnemonic('X');

    // Set mnemonics for comm item selections for file menu.
    menuItemSend.setMnemonic('S');
    menuItemReceive.setMnemonic('R');

    // Set mnemonics for data item selections for file menu.
    menuItemConnect.setMnemonic('C');
    menuItemSubmit.setMnemonic('R');

    // Menu items to help menu.
    help.add(menuCheckBoxItemDebug);
    help.addSeparator();
    help.add(menuItemHelp);

    // Set mnemonics for menu item selections for edit menu.
    menuCheckBoxItemDebug.setMnemonic('D');
    menuItemHelp.setMnemonic('A');

    // Build menu action listeners.
    buildMenuActionListeners();

    // Set the menu bar in the frame and return menu bar.
    setJMenuBar(menuBar);

    // Return JMenuBar
    return menuBar;
  } // End of buildMenu() method.
Ejemplo n.º 30
0
  public Check() {
    super(
        "Substance test with very very very very very very very very very very very very very very long title");

    final ClassLoader cl = Thread.currentThread().getContextClassLoader();
    if (UIManager.getLookAndFeel() instanceof SubstanceLookAndFeel) {
      setIconImage(
          SubstanceLogo.getLogoImage(
              SubstanceLookAndFeel.getCurrentSkin(this.getRootPane())
                  .getColorScheme(
                      DecorationAreaType.PRIMARY_TITLE_PANE,
                      ColorSchemeAssociationKind.FILL,
                      ComponentState.ENABLED)));
    }
    SubstanceLookAndFeel.registerSkinChangeListener(
        new SkinChangeListener() {
          @Override
          public void skinChanged() {
            SwingUtilities.invokeLater(
                new Runnable() {
                  @Override
                  public void run() {
                    setIconImage(
                        SubstanceLogo.getLogoImage(
                            SubstanceLookAndFeel.getCurrentSkin(Check.this.getRootPane())
                                .getColorScheme(
                                    DecorationAreaType.PRIMARY_TITLE_PANE,
                                    ColorSchemeAssociationKind.FILL,
                                    ComponentState.ENABLED)));
                  }
                });
          }
        });

    setLayout(new BorderLayout());

    jtp = new JTabbedPane();
    try {
      mainTabPreviewPainter = new MyMainTabPreviewPainter();
      jtp.putClientProperty(LafWidget.TABBED_PANE_PREVIEW_PAINTER, mainTabPreviewPainter);
    } catch (Throwable e) {
    }
    jtp.getModel().addChangeListener(new TabSwitchListener());

    final JXPanel jxPanel = new JXPanel(new BorderLayout());
    toolbar = getToolbar("", 22, true);
    jxPanel.add(toolbar, BorderLayout.NORTH);

    JXStatusBar statusBar = getStatusBar(jxPanel, jtp);
    this.add(statusBar, BorderLayout.SOUTH);

    taskPaneContainer =
        new JXTaskPaneContainer() {
          @Override
          public boolean getScrollableTracksViewportWidth() {
            return false;
          }
        };
    taskPaneContainer.setScrollableTracksViewportHeight(false);
    taskPaneContainer.setScrollableTracksViewportWidth(false);

    mainTaskPane = new JXTaskPane();
    mainTaskPane.setLayout(new BorderLayout());
    JPanel mainControlPanel =
        ControlPanelFactory.getMainControlPanel(this, jtp, mainTabPreviewPainter, toolbar);
    // mainControlPanel.setOpaque(false);
    mainTaskPane.add(mainControlPanel, BorderLayout.CENTER);
    mainTaskPane.setTitle("General settings");
    mainTaskPane.setIcon(getIcon("JFrameColor16"));
    mainTaskPane.setCollapsed(true);
    taskPaneContainer.add(mainTaskPane);

    JPanel dialogControlPanel = ControlPanelFactory.getDialogControlPanel(this);
    JXTaskPane dialogTaskPane = new JXTaskPane();
    dialogTaskPane.setLayout(new BorderLayout());
    dialogTaskPane.add(dialogControlPanel, BorderLayout.CENTER);
    dialogTaskPane.setTitle("Frames & Dialogs");
    dialogTaskPane.setIcon(getIcon("JDialogColor16"));
    dialogTaskPane.setCollapsed(true);
    // dialogTaskPane.setOpaque(false);
    taskPaneContainer.add(dialogTaskPane);

    currentSpecificTaskPane = null;

    final JScrollPane scrollPane =
        new JScrollPane(
            taskPaneContainer,
            JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    SubstanceLookAndFeel.setDecorationType(scrollPane, DecorationAreaType.GENERAL);
    // scrollPane.setOpaque(false);
    // scrollPane.getViewport().setOpaque(false);

    JPanel mainPanel = new JPanel();
    mainPanel.add(scrollPane);
    mainPanel.add(jtp);
    mainPanel.setLayout(
        new LayoutManager() {
          @Override
          public void addLayoutComponent(String name, Component comp) {}

          @Override
          public Dimension minimumLayoutSize(Container parent) {
            Dimension min1 = scrollPane.getMinimumSize();
            Dimension min2 = jtp.getMinimumSize();
            return new Dimension(min1.width + min2.width, min1.height + min2.height);
          }

          @Override
          public void layoutContainer(Container parent) {
            // give 30% width to task pane container and
            // 70% width to the tabbed pane with controls.
            int width = parent.getWidth();
            int height = parent.getHeight();
            scrollPane.setBounds(0, 0, (int) (0.3 * width), height);
            jtp.setBounds((int) (0.3 * width), 0, width - (int) (0.3 * width), height);
          }

          @Override
          public Dimension preferredLayoutSize(Container parent) {
            Dimension pref1 = scrollPane.getPreferredSize();
            Dimension pref2 = jtp.getPreferredSize();
            return new Dimension(pref1.width + pref2.width, pref1.height + pref2.height);
          }

          @Override
          public void removeLayoutComponent(Component comp) {}
        });
    jxPanel.add(mainPanel, BorderLayout.CENTER);

    this.add(jxPanel, BorderLayout.CENTER);

    setPreferredSize(new Dimension(400, 400));
    this.setSize(getPreferredSize());
    setMinimumSize(getPreferredSize());

    ButtonsPanel buttonsPanel = new ButtonsPanel();
    jtp.addTab("Buttons", getIcon("JButtonColor16"), buttonsPanel);
    getRootPane().setDefaultButton(buttonsPanel.defaultButton);

    jtp.addTab("Combo box", getIcon("JComboBoxColor16"), new CombosPanel());

    jtp.addTab("Scroll pane", getIcon("JScrollPaneColor16"), new ScrollPanel());

    TabCloseCallback closeCallback =
        new TabCloseCallback() {
          @Override
          public TabCloseKind onAreaClick(
              JTabbedPane tabbedPane, int tabIndex, MouseEvent mouseEvent) {
            if (mouseEvent.getButton() != MouseEvent.BUTTON3) return TabCloseKind.NONE;
            if (mouseEvent.isShiftDown()) {
              return TabCloseKind.ALL;
            }
            return TabCloseKind.THIS;
          }

          @Override
          public TabCloseKind onCloseButtonClick(
              JTabbedPane tabbedPane, int tabIndex, MouseEvent mouseEvent) {
            if (mouseEvent.isAltDown()) {
              return TabCloseKind.ALL_BUT_THIS;
            }
            if (mouseEvent.isShiftDown()) {
              return TabCloseKind.ALL;
            }
            return TabCloseKind.THIS;
          }

          @Override
          public String getAreaTooltip(JTabbedPane tabbedPane, int tabIndex) {
            return null;
          }

          @Override
          public String getCloseButtonTooltip(JTabbedPane tabbedPane, int tabIndex) {
            StringBuffer result = new StringBuffer();
            result.append("<html><body>");
            result.append("Mouse click closes <b>" + tabbedPane.getTitleAt(tabIndex) + "</b> tab");
            result.append(
                "<br><b>Alt</b>-Mouse click closes all tabs but <b>"
                    + tabbedPane.getTitleAt(tabIndex)
                    + "</b> tab");
            result.append("<br><b>Shift</b>-Mouse click closes all tabs");
            result.append("</body></html>");
            return result.toString();
          }
        };

    try {
      TabPanel tp = new TabPanel();
      tp.jtp.putClientProperty(SubstanceLookAndFeel.TABBED_PANE_CLOSE_CALLBACK, closeCallback);
      jtp.addTab("Tabs", getIcon("JTabbedPaneColor16"), tp);
    } catch (NoClassDefFoundError ncdfe) {
    }

    jtp.addTab("Split", new SplitPanel());

    jtp.addTab("Desktop", getIcon("JDesktopPaneColor16"), new DesktopPanel());

    jtp.addTab("Text fields", getIcon("JTextPaneColor16"), new TextFieldsPanel());

    jtp.addTab("Table", getIcon("JTableColor16"), new TablePanel());

    try {
      jtp.addTab("List", getIcon("JListColor16"), new ListPanel());
    } catch (NoClassDefFoundError ncdfe) {
    }

    jtp.addTab("Slider", getIcon("JSliderColor16"), new SliderPanel());

    jtp.addTab("Progress bar", getIcon("JProgressBarColor16"), new ProgressBarPanel());

    jtp.addTab("Spinner", getIcon("JSpinnerColor16"), new SpinnerPanel());

    jtp.addTab("Tree", getIcon("JTreeColor16"), new TreePanel());

    jtp.addTab("File tree", getIcon("JTreeColor16"), new FileTreePanel());

    jtp.addTab("Cards", new CardPanel());

    JPanel verticalButtonPanel = new JPanel();
    verticalButtonPanel.setLayout(new GridLayout(1, 3));
    verticalButtonPanel.add(new JButton("Vert button 1"));
    verticalButtonPanel.add(new JButton("Vert button 2"));
    JPanel smallVerticalButtonPanel = new JPanel();
    smallVerticalButtonPanel.setLayout(new GridLayout(4, 4));
    for (int row = 0; row < 4; row++) {
      for (int col = 0; col < 4; col++) {
        JButton vertButton = new JButton("vert");
        vertButton.setToolTipText("Vertical button " + row + ":" + col);
        smallVerticalButtonPanel.add(vertButton);
      }
    }
    verticalButtonPanel.add(smallVerticalButtonPanel);
    jtp.addTab("V-Buttons", verticalButtonPanel);

    jtp.addTab("Colored", new ColoredControlsPanel());

    jtp.addTab("Colorized", new ColorizedControlsPanel());

    jtp.addTab("Cells", new CellsPanel());

    jtp.addTab("Sizes", new SizesPanel());

    jtp.addTab("H-Align", new HAlignmentPanel());

    jtp.addTab("V-Align", new VAlignmentPanel());

    // sample menu bar
    JMenuBar jmb = new JMenuBar();
    if (UIManager.getLookAndFeel() instanceof SubstanceLookAndFeel) {
      jmb.add(SampleMenuFactory.getSkinMenu());
      jmb.add(SampleMenuFactory.getTransformMenu());
    }
    JMenu coloredMenu = new JMenu("Colors");
    coloredMenu.setMnemonic('0');
    JMenuItem coloredMI = new JMenuItem("Italic red");
    coloredMI.setFont(coloredMI.getFont().deriveFont(Font.ITALIC));
    coloredMI.setForeground(Color.red);
    coloredMenu.add(coloredMI);
    JRadioButtonMenuItem coloredRBMI = new JRadioButtonMenuItem("Bold green");
    coloredRBMI.setFont(coloredRBMI.getFont().deriveFont(Font.BOLD));
    coloredRBMI.setForeground(Color.green);
    coloredMenu.add(coloredRBMI);
    JCheckBoxMenuItem coloredCBMI = new JCheckBoxMenuItem("Big blue");
    coloredCBMI.setFont(coloredCBMI.getFont().deriveFont(32f));
    coloredCBMI.setForeground(Color.blue);
    coloredMenu.add(coloredCBMI);
    JMenu coloredM = new JMenu("Always big magenta");
    coloredM.setForeground(Color.magenta);
    coloredM.setFont(coloredM.getFont().deriveFont(24f));
    coloredMenu.add(coloredM);
    jmb.add(coloredMenu);

    JMenu testMenu = SampleMenuFactory.getTestMenu();
    jmb.add(testMenu);

    JMenu jm4 = new JMenu("Disabled");
    jm4.add(new JMenuItem("dummy4"));
    jm4.setMnemonic('4');
    jmb.add(jm4);
    jm4.setEnabled(false);

    // LAF changing
    jmb.add(SampleMenuFactory.getLookAndFeelMenu(this));
    setJMenuBar(jmb);

    TabCloseCallback closeCallbackMain =
        new TabCloseCallback() {
          @Override
          public TabCloseKind onAreaClick(
              JTabbedPane tabbedPane, int tabIndex, MouseEvent mouseEvent) {
            if (mouseEvent.getButton() != MouseEvent.BUTTON2) return TabCloseKind.NONE;
            if (mouseEvent.isShiftDown()) {
              return TabCloseKind.ALL;
            }
            return TabCloseKind.THIS;
          }

          @Override
          public TabCloseKind onCloseButtonClick(
              JTabbedPane tabbedPane, int tabIndex, MouseEvent mouseEvent) {
            if (mouseEvent.isAltDown()) {
              return TabCloseKind.ALL_BUT_THIS;
            }
            if (mouseEvent.isShiftDown()) {
              return TabCloseKind.ALL;
            }
            return TabCloseKind.THIS;
          }

          @Override
          public String getAreaTooltip(JTabbedPane tabbedPane, int tabIndex) {
            return null;
          }

          @Override
          public String getCloseButtonTooltip(JTabbedPane tabbedPane, int tabIndex) {
            StringBuffer result = new StringBuffer();
            result.append("<html><body>");
            result.append("Mouse click closes <b>" + tabbedPane.getTitleAt(tabIndex) + "</b> tab");
            result.append(
                "<br><b>Alt</b>-Mouse click closes all tabs but <b>"
                    + tabbedPane.getTitleAt(tabIndex)
                    + "</b> tab");
            result.append("<br><b>Shift</b>-Mouse click closes all tabs");
            result.append("</body></html>");
            return result.toString();
          }
        };

    jtp.putClientProperty(SubstanceLookAndFeel.TABBED_PANE_CLOSE_CALLBACK, closeCallbackMain);
    SubstanceLookAndFeel.registerTabCloseChangeListener(
        new TabCloseListener() {
          @Override
          public void tabClosed(JTabbedPane tabbedPane, Component tabComponent) {
            out("Closed tab");
          }

          @Override
          public void tabClosing(JTabbedPane tabbedPane, Component tabComponent) {
            out("Closing tab");
          }
        });

    SubstanceLookAndFeel.registerTabCloseChangeListener(
        jtp,
        new VetoableTabCloseListener() {
          @Override
          public void tabClosed(JTabbedPane tabbedPane, Component tabComponent) {
            out("Closed tab - specific");
          }

          @Override
          public void tabClosing(JTabbedPane tabbedPane, Component tabComponent) {
            out("Closing tab - specific");
          }

          @Override
          public boolean vetoTabClosing(JTabbedPane tabbedPane, Component tabComponent) {
            int userCloseAnswer =
                JOptionPane.showConfirmDialog(
                    Check.this,
                    "Are you sure you want to close '"
                        + tabbedPane.getTitleAt(tabbedPane.indexOfComponent(tabComponent))
                        + "' tab?",
                    "Confirm dialog",
                    JOptionPane.YES_NO_OPTION);
            return (userCloseAnswer == JOptionPane.NO_OPTION);
          }
        });

    SubstanceLookAndFeel.registerTabCloseChangeListener(
        jtp,
        new VetoableMultipleTabCloseListener() {
          @Override
          public void tabsClosed(JTabbedPane tabbedPane, Set<Component> tabComponents) {
            out("Closed " + tabComponents.size() + " tabs - specific");
          }

          @Override
          public void tabsClosing(JTabbedPane tabbedPane, Set<Component> tabComponents) {
            out("Closing " + tabComponents.size() + " tabs - specific");
          }

          @Override
          public boolean vetoTabsClosing(JTabbedPane tabbedPane, Set<Component> tabComponents) {
            int userCloseAnswer =
                JOptionPane.showConfirmDialog(
                    Check.this,
                    "Are you sure you want to close " + tabComponents.size() + " tabs?",
                    "Confirm dialog",
                    JOptionPane.YES_NO_OPTION);
            return (userCloseAnswer == JOptionPane.NO_OPTION);
          }
        });

    addComponentListener(
        new ComponentAdapter() {
          @Override
          public void componentResized(ComponentEvent e) {
            System.out.println("Size " + getSize());
          }
        });
  }