Пример #1
0
  private WebButton getRemoveButton() {
    if (remove == null) {
      remove =
          WebButton.createIconWebButton(CROSS_ICON, StyleConstants.smallRound, 3, 2, true, false);
      remove.setFocusable(false);
      remove.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(final ActionEvent ae) {
              if (animator != null && animator.isRunning()) {
                animator.stop();
              }
              if (animate) {
                animator =
                    new WebTimer(
                        "WebFilePlate.fadeOutTimer",
                        StyleConstants.animationDelay,
                        new ActionListener() {
                          @Override
                          public void actionPerformed(ActionEvent e) {
                            opacity -= 0.1f;
                            if (opacity > 0f) {
                              WebFilePlate.this.repaint();
                            } else {
                              // Remove file plate
                              removeFromParent();

                              // Firing final close listeners
                              fireActionPerformed(ae);

                              // Stopping animation
                              animator.stop();
                            }
                          }
                        });
                animator.start();
              } else {
                // Remove file plate
                removeFromParent();
              }
            }
          });
    }
    return remove;
  }
Пример #2
0
  private static Component createSourceButton(final WebLookAndFeelDemo owner, Example example) {
    final Class classType = example.getClass();

    WebButton sourceButton = WebButton.createIconWebButton(JarEntry.javaIcon);
    TooltipManager.setTooltip(
        sourceButton, JarEntry.javaIcon, ReflectUtils.getJavaClassName(classType), TooltipWay.up);
    sourceButton.setRolloverDecoratedOnly(true);
    sourceButton.setFocusable(false);

    sourceButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            owner.showSource(classType);
          }
        });

    return new CenterPanel(sourceButton, false, true);
  }
Пример #3
0
  public WebColorChooserField(final Color color) {
    super();

    // Pipette color picker
    updatePipette();

    // Trailing color choose button
    colorButton = new WebButton(ImageUtils.createColorChooserIcon(color));
    colorButton.setFocusable(false);
    colorButton.setShadeWidth(0);
    colorButton.setMoveIconOnPress(false);
    colorButton.setRolloverDecoratedOnly(true);
    colorButton.setCursor(Cursor.getDefaultCursor());
    colorButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent e) {
            showColorChooserPopup();
          }
        });
    setTrailingComponent(colorButton);

    // Actions
    addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent e) {
            updateColorFromField();
          }
        });
    addMouseListener(
        new MouseAdapter() {
          @Override
          public void mousePressed(final MouseEvent e) {
            if (isEnabled() && SwingUtilities.isRightMouseButton(e)) {
              showColorChooserPopup();
            }
          }
        });
    addFocusListener(
        new FocusAdapter() {
          @Override
          public void focusLost(final FocusEvent e) {
            updateColorFromField();
          }
        });
    addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyReleased(final KeyEvent e) {
            if (isEnabled()) {
              if (Hotkey.ESCAPE.isTriggered(e)) {
                updateViewFromColor();
              } else if (Hotkey.DOWN.isTriggered(e)) {
                showColorChooserPopup();
              }
            }
          }
        });

    // Initial data
    setFieldType(ColorChooserFieldType.rgb);
    setColor(color);

    // Initial styling settings
    updateMargin();
    setHorizontalAlignment(CENTER);
  }