Exemplo n.º 1
0
  /** Additional initializtion of WebWindow settings. */
  protected void initialize() {
    setFocusable(true);
    SwingUtils.setOrientation(this);

    // Adding focus tracker for this window
    // It is stored into a separate field to avoid its disposal from memory
    focusTracker =
        new DefaultFocusTracker(true) {
          @Override
          public boolean isTrackingEnabled() {
            return closeOnFocusLoss;
          }

          @Override
          public void focusChanged(final boolean focused) {
            if (closeOnFocusLoss && WebWindow.this.isShowing() && !focused && !isChildFocused()) {
              setVisible(false);
            }
          }
        };
    FocusManager.addFocusTracker(this, focusTracker);
  }
Exemplo n.º 2
0
  /**
   * Installs UI in the specified component.
   *
   * @param c component for this UI
   */
  @Override
  public void installUI(final JComponent c) {
    super.installUI(c);

    // Default settings
    SwingUtils.setOrientation(splitPane);
    splitPane.setOpaque(false);
    splitPane.setBorder(null);
    splitPane.setDividerSize(6);

    // Updating border
    updateBorder();

    // Orientation change listener
    propertyChangeListener =
        new PropertyChangeListener() {
          @Override
          public void propertyChange(final PropertyChangeEvent evt) {
            updateBorder();
          }
        };
    splitPane.addPropertyChangeListener(
        WebLookAndFeel.ORIENTATION_PROPERTY, propertyChangeListener);
  }
Exemplo n.º 3
0
  @Override
  public void installUI(final JComponent c) {
    super.installUI(c);

    radioButton = (JRadioButton) c;

    // Default settings
    SwingUtils.setOrientation(c);
    radioButton.setOpaque(false);

    // Initial check state
    checkIcon = radioButton.isSelected() ? CHECK_STATES.size() - 1 : 0;

    // Updating border and icon
    updateBorder();
    updateIcon(radioButton);

    // Background fade animation
    bgTimer =
        new WebTimer(
            "WebRadioButtonUI.bgUpdater",
            40,
            new ActionListener() {
              @Override
              public void actionPerformed(final ActionEvent e) {
                if (rollover && bgDarkness < MAX_DARKNESS) {
                  bgDarkness++;
                  c.repaint();
                } else if (!rollover && bgDarkness > 0) {
                  bgDarkness--;
                  c.repaint();
                } else {
                  bgTimer.stop();
                }
              }
            });
    mouseAdapter =
        new MouseAdapter() {
          @Override
          public void mouseEntered(final MouseEvent e) {
            rollover = true;
            if (isAnimated()) {
              bgTimer.start();
            } else {
              bgDarkness = MAX_DARKNESS;
              c.repaint();
            }
          }

          @Override
          public void mouseExited(final MouseEvent e) {
            rollover = false;
            if (isAnimated()) {
              bgTimer.start();
            } else {
              bgDarkness = 0;
              c.repaint();
            }
          }
        };
    radioButton.addMouseListener(mouseAdapter);

    // Selection changes animation
    checkTimer =
        new WebTimer(
            "WebRadioButtonUI.iconUpdater",
            40,
            new ActionListener() {
              @Override
              public void actionPerformed(final ActionEvent e) {
                if (checking && checkIcon < CHECK_STATES.size() - 1) {
                  checkIcon++;
                  c.repaint();
                } else if (!checking && checkIcon > 0) {
                  checkIcon--;
                  c.repaint();
                } else {
                  checkTimer.stop();
                }
              }
            });
    itemListener =
        new ItemListener() {
          @Override
          public void itemStateChanged(final ItemEvent e) {
            if (animated) {
              if (radioButton.isSelected()) {
                checking = true;
                checkTimer.start();
              } else {
                checking = false;
                checkTimer.start();
              }
            } else {
              checkTimer.stop();
              checkIcon = radioButton.isSelected() ? CHECK_STATES.size() - 1 : 0;
              c.repaint();
            }
          }
        };
    radioButton.addItemListener(itemListener);
  }