Exemplo n.º 1
0
  public void addButton(JToggleButton b) {
    imagePanel.add(b);

    b.setForeground(Color.black);
    b.setBackground(Color.white);
    b.setFocusable(false);
    b.addMouseListener(new PopupMouseListener(b));
    b.addActionListener(new PopupActionListener(b));
  }
  public void addColorChooserPanel(final AbstractColorChooserPanel ccp) {
    final String displayName = ccp.getDisplayName();
    if (displayName == null) {
      // Return if we haven't initialized yet
      return;
    }

    if (ccp.getClass()
        .getName()
        .equals("ch.randelshofer.quaqua.colorchooser.Quaqua15ColorPicker")) {
      northPanel.add(ccp, BorderLayout.WEST);
    } else {
      Icon displayIcon = ccp.getLargeDisplayIcon();
      JToggleButton tb = new JToggleButton(null, displayIcon);
      tb.setToolTipText(displayName);
      tb.setFocusable(false);
      tb.setHorizontalTextPosition(SwingConstants.CENTER);
      tb.setVerticalTextPosition(SwingConstants.BOTTOM);
      tb.setFont(UIManager.getFont("ColorChooser.font"));
      tb.putClientProperty("Quaqua.Button.style", "toolBarTab");
      JPanel centerView = new JPanel(new BorderLayout());
      centerView.add(ccp);
      chooserPanelHolder.add(centerView, displayName);
      toolBarButtonGroup.add(tb);
      toolBar.add(tb);

      if (toolBar.getComponentCount() == 1
          || lastSelectedChooserName != null && lastSelectedChooserName.equals(displayName)) {
        tb.setSelected(true);
        CardLayout cl = (CardLayout) chooserPanelHolder.getLayout();
        cl.show(chooserPanelHolder, displayName);
      }

      tb.addItemListener(
          new ItemListener() {
            public void itemStateChanged(ItemEvent evt) {
              if (evt.getStateChange() == ItemEvent.SELECTED) {
                CardLayout cl = (CardLayout) chooserPanelHolder.getLayout();
                cl.show(chooserPanelHolder, displayName);
                lastSelectedChooserName = displayName;
              }
            }
          });
    }
  }
Exemplo n.º 3
0
  private void initToolbar() {
    JToolBar tbTraceFilters = new JToolBar();
    tbTraceFilters.setFloatable(false);
    tbTraceFilters.setRollover(true);

    tbTraceFilters.add(new JLabel("Min time:"));
    txtMinTime = new JTextField(4);
    tbTraceFilters.add(txtMinTime);

    JButton btnFilterByTime = new JButton(new FilterByTimeAction());
    btnFilterByTime.setFocusable(false);
    btnFilterByTime.setToolTipText("Filter by trace execution time");
    tbTraceFilters.add(btnFilterByTime);

    tbTraceFilters.addSeparator();

    btnFilterErrors = new JToggleButton(new FilterByErrorAction());
    btnFilterErrors.setFocusable(false);
    btnFilterErrors.setToolTipText("Show only traces with errors");
    tbTraceFilters.add(btnFilterErrors);

    tbTraceFilters.addSeparator();

    cmbTraceType = new JComboBox();
    cmbTraceType.addItem("*");

    cmbTraceType.addItemListener(
        new ItemListener() {
          @Override
          public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
              String item = (String) e.getItem();
              traceLabel = "*".equals(item) ? null : item;
              tbmTraces.setDataSet(dataSet, traceFilter);
            }
          }
        });

    tbTraceFilters.add(cmbTraceType);

    add(tbTraceFilters, BorderLayout.NORTH);
  }