Example #1
0
 @Override
 public void addNotify() {
   super.addNotify();
   if (UIManager.getBoolean("Sheet.showAsSheet") && !isExperimentalSheet()) {
     QuaquaUtilities.setWindowAlpha(this, 240);
   }
 }
  public void focusGained(FocusEvent event) {
    QuaquaUtilities.repaintBorder((JComponent) event.getComponent());

    final JTextComponent tc = (JTextComponent) event.getSource();
    if (tc.isEditable() && tc.isEnabled()) {

      String uiProperty;
      if (tc instanceof JPasswordField) {
        uiProperty = "PasswordField.autoSelect";
      } else if (tc instanceof JFormattedTextField) {
        uiProperty = "FormattedTextField.autoSelect";
      } else {
        uiProperty = "TextField.autoSelect";
      }

      if (tc.getClientProperty("Quaqua.TextComponent.autoSelect") == Boolean.TRUE
          || tc.getClientProperty("Quaqua.TextComponent.autoSelect") == null
              && UIManager.getBoolean(uiProperty)) {
        if (event instanceof CausedFocusEvent) {
          CausedFocusEvent cfEvent = (CausedFocusEvent) event;
          if (cfEvent.getCause() == Cause.TRAVERSAL_FORWARD
              || cfEvent.getCause() == Cause.TRAVERSAL_BACKWARD) {
            tc.selectAll();
          }
        }
      }
    }
    if (KeyboardFocusManager.getCurrentKeyboardFocusManager()
        instanceof QuaquaKeyboardFocusManager) {
      QuaquaKeyboardFocusManager kfm =
          (QuaquaKeyboardFocusManager) KeyboardFocusManager.getCurrentKeyboardFocusManager();
      kfm.setLastKeyboardTraversingComponent(null);
    }
  }
  public void paintComponent(Graphics gr) {
    Graphics2D g = (Graphics2D) gr;
    Object oldHints = QuaquaUtilities.beginGraphics((Graphics2D) g);

    g.drawImage(crayonsImage, 0, 0, this);

    if (selectedCrayon != null) {
      /*
      g.setColor(new Color(0x60ffffff & selectedCrayon.color.getRGB(),true));
      g.fill(selectedCrayon.shape);
       */
      g.setColor(getForeground());
      FontMetrics fm = g.getFontMetrics();
      int nameWidth = fm.stringWidth(selectedCrayon.name);
      g.drawString(
          selectedCrayon.name, (crayonsImage.getWidth(this) - nameWidth) / 2, fm.getAscent() + 1);
    }
    QuaquaUtilities.endGraphics((Graphics2D) g, oldHints);
  }
 public void focusLost(FocusEvent event) {
   QuaquaUtilities.repaintBorder((JComponent) event.getComponent());
 }