Пример #1
0
  public FilterBar() {
    setLayout(new BorderLayout());
    add(filterPanel, BorderLayout.CENTER);

    final ArrowButton arrowbutton = new ArrowButton();
    arrowbutton.addMouseListener(
        new MouseAdapter() {

          @Override
          public void mousePressed(MouseEvent e) {
            boolean closed = !arrowbutton.isOpen();
            arrowbutton.setOpen(closed);
            filterPanel.setVisible(closed);
          }
        });
    add(arrowbutton, BorderLayout.SOUTH);
  }
Пример #2
0
  /**
   * Create a component that will replace the spinner models value with the object returned by
   * <code>spinner.getNextValue</code>. By default the <code>nextButton</code> is a JButton who's
   * <code>ActionListener</code> updates it's <code>JSpinner</code> ancestors model. If a nextButton
   * isn't needed (in a subclass) then override this method to return null.
   *
   * @return a component that will replace the spinners model with the next value in the sequence,
   *     or null
   * @see #installUI
   * @see #createPreviousButton
   */
  protected Component createNextButton() {
    Component tmpButton = super.createNextButton();

    if (tmpButton instanceof JButton) {
      JButton result = new ArrowButton(SwingConstants.NORTH);
      ((ArrowButton) result).setDrawBottomBorder(false);

      result.setBorder(
          BorderFactory.createMatteBorder(1, 1, 0, 1, UIManager.getColor("Button.borderColor")));
      ActionListener al[] = ((JButton) tmpButton).getActionListeners();
      for (int i = 0; i < al.length; i++) result.addActionListener(al[i]);

      MouseListener ml[] = ((JButton) tmpButton).getMouseListeners();
      for (int i = 0; i < ml.length; i++) result.addMouseListener(ml[i]);

      return result;
    } else return tmpButton;
  }