Пример #1
0
  public void paint(final Graphics g, final JComponent c) {
    JComponent component = tooltip.getComponent();
    if (component != null && component.isEnabled() || backgroundInactiveColor == null) {
      g.setColor(tooltip.getBackground());
      LookAndFeel.installBorder(c, "ToolTip.border");
    } else {
      g.setColor(backgroundInactiveColor);
      LookAndFeel.installBorder(c, "ToolTip.borderInactive");
    }
    g.fillRect(0, 0, tooltip.getWidth(), tooltip.getHeight());

    String tipText = tooltip.getTipText();
    FontMetrics fm = Utilities.getFontMetrics(tooltip);
    Dimension stringSize = Utilities.getStringSize(tipText, fm);
    int textX =
        component instanceof AbstractButton && ((AbstractButton) component).getMnemonic() != 0
            ? 4
            : (tooltip.getWidth() - stringSize.width) / 2;
    int textY = fm.getAscent();
    Color foreground =
        component != null && component.isEnabled() || foregroundInactiveColor == null
            ? tooltip.getForeground()
            : foregroundInactiveColor;
    Utilities.drawString(g, tipText, textX, textY, fm, foreground, -1);
  }
  @Override
  protected void paintIcon(JComponent c, Graphics2D g, Rectangle viewRect, Rectangle iconRect) {
    int rad = JBUI.scale(4);

    // Paint the radio button
    final int x = iconRect.x + (rad - (rad % 2 == 1 ? 1 : 0)) / 2;
    final int y = iconRect.y + (rad - (rad % 2 == 1 ? 1 : 0)) / 2;
    final int w = iconRect.width - rad;
    final int h = iconRect.height - rad;
    final boolean enabled = c.isEnabled();
    Color color = enabled ? Gray.x50 : Gray.xD3;
    g.translate(x, y);
    // setup AA for lines
    final GraphicsConfig config = GraphicsUtil.setupAAPainting(g);
    g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
    final boolean selected = ((AbstractButton) c).isSelected();
    g.setPaint(color);
    g.drawOval(0, 0, w, h);

    if (selected) {
      g.setColor(color);
      g.fillOval(JBUI.scale(3), JBUI.scale(3), w - 2 * JBUI.scale(3), h - 2 * JBUI.scale(3));
    }
    config.restore();
    g.translate(-x, -y);
  }
Пример #3
0
  /** Returns the current state of the passed in <code>AbstractButton</code>. */
  private int getComponentState(JComponent c) {
    int state = ENABLED;

    if (!c.isEnabled()) {
      state = DISABLED;
    }

    AbstractButton button = (AbstractButton) c;
    ButtonModel model = button.getModel();

    if (model.isPressed()) {
      if (model.isArmed()) {
        state = PRESSED;
      } else {
        state = MOUSE_OVER;
      }
    }
    if (model.isRollover()) {
      state |= MOUSE_OVER;
    }
    if (model.isSelected()) {
      state |= SELECTED;
    }
    if (c.isFocusOwner() && button.isFocusPainted()) {
      state |= FOCUSED;
    }
    if ((c instanceof JButton) && ((JButton) c).isDefaultButton()) {
      state |= DEFAULT;
    }
    return state;
  }
  /**
   * Paints the track for a vertical scrollbar.
   *
   * @param g the graphics device.
   * @param c the component.
   * @param x the x-coordinate for the track bounds.
   * @param y the y-coordinate for the track bounds.
   * @param w the width for the track bounds.
   * @param h the height for the track bounds.
   */
  private void paintTrackVertical(Graphics g, JComponent c, int x, int y, int w, int h) {
    if (c.isEnabled()) {
      g.setColor(MetalLookAndFeel.getControlDarkShadow());
      g.drawLine(x, y, x, y + h - 1);
      g.drawLine(x, y, x + w - 1, y);
      g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);

      g.setColor(scrollBarShadowColor);
      g.drawLine(x + 1, y + 1, x + w - 1, y + 1);
      g.drawLine(x + 1, y + 1, x + 1, y + h - 2);

      if (isFreeStanding) {
        g.setColor(MetalLookAndFeel.getControlDarkShadow());
        g.drawLine(x + w - 2, y, x + w - 2, y + h - 1);
        g.setColor(MetalLookAndFeel.getControlHighlight());
        g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);
      }
    } else {
      g.setColor(MetalLookAndFeel.getControlDisabled());
      if (isFreeStanding) g.drawRect(x, y, w - 1, h - 1);
      else {
        g.drawLine(x, y, x + w - 1, y);
        g.drawLine(x, y, x, y + h - 1);
        g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);
      }
    }
  }
Пример #5
0
  protected void paintIndeterminate(Graphics g, JComponent c) {
    if (!(g instanceof Graphics2D)) {
      return;
    }
    Graphics2D g2D = (Graphics2D) g;

    Insets b = progressBar.getInsets(); // area for border
    int barRectWidth = progressBar.getWidth() - (b.right + b.left);
    int barRectHeight = progressBar.getHeight() - (b.top + b.bottom);

    Color colors[];
    if (progressBar.getForeground() instanceof UIResource) {
      if (!Utilities.isActive(c)) {
        colors = BaseLookAndFeel.getTheme().getInActiveColors();
      } else if (c.isEnabled()) {
        colors = BaseLookAndFeel.getTheme().getProgressBarColors();
      } else {
        colors = BaseLookAndFeel.getTheme().getDisabledColors();
      }
    } else {
      Color hiColor = ColorHelper.brighter(progressBar.getForeground(), 40);
      Color loColor = ColorHelper.darker(progressBar.getForeground(), 20);
      colors = ColorHelper.createColorArr(hiColor, loColor, 20);
    }

    Color cHi = ColorHelper.darker(colors[colors.length - 1], 5);
    Color cLo = ColorHelper.darker(colors[colors.length - 1], 10);

    // Paint the bouncing box.
    Rectangle box = getBox(null);
    if (box != null) {
      g2D.setColor(progressBar.getForeground());
      Utilities.draw3DBorder(g, cHi, cLo, box.x + 1, box.y + 1, box.width - 2, box.height - 2);
      if (progressBar.getOrientation() == JProgressBar.HORIZONTAL) {
        Utilities.fillHorGradient(g, colors, box.x + 2, box.y + 2, box.width - 4, box.height - 4);
      } else {
        Utilities.fillVerGradient(g, colors, box.x + 2, box.y + 2, box.width - 4, box.height - 4);
      }

      // Deal with possible text painting
      if (progressBar.isStringPainted()) {
        Object savedRenderingHint = null;
        if (BaseLookAndFeel.getTheme().isTextAntiAliasingOn()) {
          savedRenderingHint = g2D.getRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING);
          g2D.setRenderingHint(
              RenderingHints.KEY_TEXT_ANTIALIASING,
              BaseLookAndFeel.getTheme().getTextAntiAliasingHint());
        }
        if (progressBar.getOrientation() == JProgressBar.HORIZONTAL) {
          paintString(g2D, b.left, b.top, barRectWidth, barRectHeight, box.width, b);
        } else {
          paintString(g2D, b.left, b.top, barRectWidth, barRectHeight, box.height, b);
        }
        if (BaseLookAndFeel.getTheme().isTextAntiAliasingOn()) {
          g2D.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, savedRenderingHint);
        }
      }
    }
  }
Пример #6
0
 /** Enable or disable the components in the compsThatNeedServer list */
 private void enableComps() {
   synchronized (WIDGET_MUTEX) {
     boolean newEnabledState = (state == STATE_CONNECTED);
     for (int i = 0; i < compsThatNeedServer.size(); i++) {
       JComponent comp = (JComponent) compsThatNeedServer.get(i);
       if (comp.isEnabled() != newEnabledState) {
         GuiUtils.enableTree(comp, newEnabledState);
       }
     }
   }
 }
Пример #7
0
  /**
   * Guarda el estado de un componente. Este proceso es recursivo. El estado se guarda en un array y
   * este array no es vaciado inicialmente. La idea es guardar en un disabled y recuperar en un
   * enabled y asegurarse que no puede ocurrir un disabled o un enabled dos veces.
   *
   * @param component
   */
  private void saveComponentsStatus(JComponent component) {
    // Guardar estado
    StatusComponentStruct auxStatus = new StatusComponentStruct();
    auxStatus.setEnabled(component.isEnabled());
    auxStatus.setObject(component);
    statusList.add(auxStatus);

    for (int i = 0; i < component.getComponentCount(); i++)
      if (component.getComponent(i) instanceof JComponent)
        saveComponentsStatus((JComponent) component.getComponent(i));
  }
Пример #8
0
  /**
   * DOCUMENT ME!
   *
   * @param c DOCUMENT ME!
   * @param region DOCUMENT ME!
   * @return DOCUMENT ME!
   */
  private int getComponentState(JComponent c, Region region) {
    if (region == SeaGlassRegion.SEARCH_FIELD_CANCEL_BUTTON && c.isEnabled()) {
      if (((JTextComponent) c).getText().length() == 0) {
        return DISABLED;
      } else if (isCancelArmed) {
        return PRESSED;
      }

      return ENABLED;
    }

    return SeaGlassLookAndFeel.getComponentState(c);
  }
Пример #9
0
  /**
   * Show the window.
   *
   * @param container - Window of JFrame to show
   */
  private void showPopup(Window container) {
    if (visibleComponent.isEnabled()) {
      Point pt = visibleComponent.getLocationOnScreen();
      pt.translate(0, visibleComponent.getHeight());
      container.setLocation(pt);
      container.toFront();

      ApplicationManager.setCurrentlySelectedField(fieldName);
      if (container instanceof OntologySelector) {
        ((OntologySelector) container).makeVisible();
      } else {
        container.setVisible(true);
        container.requestFocusInWindow();
      }
    }
  }
Пример #10
0
  /** Paints the horizontal bars for the */
  public void paintIcon(Component c, Graphics g, int x, int y) {
    JComponent component = (JComponent) c;
    int iconWidth = getIconWidth();

    g.translate(x, y);

    g.setColor(
        component.isEnabled()
            ? MetalLookAndFeel.getControlInfo()
            : MetalLookAndFeel.getControlShadow());
    g.drawLine(0, 0, iconWidth - 1, 0);
    g.drawLine(1, 1, 1 + (iconWidth - 3), 1);
    g.drawLine(2, 2, 2 + (iconWidth - 5), 2);
    g.drawLine(3, 3, 3 + (iconWidth - 7), 3);
    g.drawLine(4, 4, 4 + (iconWidth - 9), 4);

    g.translate(-x, -y);
  }
  /**
   * Paints the slider button of the ScrollBar.
   *
   * @param g the Graphics context to use
   * @param c the JComponent on which we paint
   * @param thumbBounds the rectangle that is the slider button
   */
  protected void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds) {
    // a disabled scrollbar has no thumb in the metal look and feel
    if (!c.isEnabled()) return;
    if (scrollbar.getOrientation() == HORIZONTAL) paintThumbHorizontal(g, c, thumbBounds);
    else paintThumbVertical(g, c, thumbBounds);

    // Draw the pattern when the theme is not Ocean.
    if (!(MetalLookAndFeel.getCurrentTheme() instanceof OceanTheme)) {
      MetalUtils.fillMetalPattern(
          c,
          g,
          thumbBounds.x + 3,
          thumbBounds.y + 3,
          thumbBounds.width - 6,
          thumbBounds.height - 6,
          thumbHighlightColor,
          thumbLightShadowColor);
    }
  }
 @Override
 public void actionPerformed(ActionEvent evt) {
   JComponent c = target;
   if (c == null
       && (KeyboardFocusManager.getCurrentKeyboardFocusManager().getPermanentFocusOwner()
           instanceof JComponent)) {
     c =
         (JComponent)
             KeyboardFocusManager.getCurrentKeyboardFocusManager().getPermanentFocusOwner();
   }
   if (c != null && c.isEnabled()) {
     if (c instanceof EditableComponent) {
       ((EditableComponent) c).clearSelection();
     } else if (c instanceof JTextComponent) {
       JTextComponent tc = ((JTextComponent) c);
       tc.select(tc.getSelectionStart(), tc.getSelectionStart());
     } else {
       c.getToolkit().beep();
     }
   }
 }
Пример #13
0
  // {{{ _preprocessKeyEvent() method
  private KeyEvent _preprocessKeyEvent(KeyEvent evt) {
    if (view.isClosed()) return null;
    Component focusOwner = view.getFocusOwner();
    if (focusOwner instanceof JComponent) {
      JComponent comp = (JComponent) focusOwner;
      InputMap map = comp.getInputMap();
      ActionMap am = comp.getActionMap();

      if (map != null && am != null && comp.isEnabled()) {
        KeyStroke keyStroke = KeyStroke.getKeyStrokeForEvent(evt);
        Object binding = map.get(keyStroke);
        if (binding != null && am.get(binding) != null) {
          return null;
        }
      }
    }

    if (focusOwner instanceof JTextComponent) {
      // fix for the bug where key events in JTextComponents
      // inside views are also handled by the input handler
      if (evt.getID() == KeyEvent.KEY_PRESSED) {
        switch (evt.getKeyCode()) {
          case KeyEvent.VK_ENTER:
          case KeyEvent.VK_TAB:
          case KeyEvent.VK_BACK_SPACE:
          case KeyEvent.VK_SPACE:
            return null;
        }
      }
    }

    if (evt.isConsumed()) return null;

    if (Debug.DUMP_KEY_EVENTS) {
      Log.log(Log.DEBUG, this, "Key event (preprocessing) : " + AbstractInputHandler.toString(evt));
    }

    return KeyEventWorkaround.processKeyEvent(evt);
  } // }}}
Пример #14
0
 /**
  * If necessary paints the background of the component, then invokes <code>paint</code>.
  *
  * @param g Graphics to paint to
  * @param c JComponent painting on
  * @throws NullPointerException if <code>g</code> or <code>c</code> is null
  * @see javax.swing.plaf.ComponentUI#update
  * @see javax.swing.plaf.ComponentUI#paint
  * @since 1.5
  */
 public void update(Graphics g, JComponent c) {
   AbstractButton button = (AbstractButton) c;
   if ((c.getBackground() instanceof UIResource)
       && button.isContentAreaFilled()
       && c.isEnabled()) {
     ButtonModel model = button.getModel();
     if (!MetalUtils.isToolBarButton(c)) {
       if (!model.isArmed()
           && !model.isPressed()
           && MetalUtils.drawGradient(
               c, g, "Button.gradient", 0, 0, c.getWidth(), c.getHeight(), true)) {
         paint(g, c);
         return;
       }
     } else if (model.isRollover()
         && MetalUtils.drawGradient(
             c, g, "Button.gradient", 0, 0, c.getWidth(), c.getHeight(), true)) {
       paint(g, c);
       return;
     }
   }
   super.update(g, c);
 }
Пример #15
0
 @Override
 public void paint(Graphics g, JComponent c) {
   final Border border = c.getBorder();
   final GraphicsConfig config = GraphicsUtil.setupAAPainting(g);
   final boolean square = isSquare(c);
   if (c.isEnabled() && border != null) {
     final Insets ins = border.getBorderInsets(c);
     final int yOff = (ins.top + ins.bottom) / 4;
     if (!square) {
       if (((JButton) c).isDefaultButton()) {
         ((Graphics2D) g)
             .setPaint(
                 UIUtil.getGradientPaint(
                     0,
                     0,
                     getSelectedButtonColor1(),
                     0,
                     c.getHeight(),
                     getSelectedButtonColor2()));
       } else {
         ((Graphics2D) g)
             .setPaint(
                 UIUtil.getGradientPaint(
                     0, 0, getButtonColor1(), 0, c.getHeight(), getButtonColor2()));
       }
     }
     g.fillRoundRect(
         square ? 2 : 4,
         yOff,
         c.getWidth() - 2 * 4,
         c.getHeight() - 2 * yOff,
         square ? 3 : 5,
         square ? 3 : 5);
   }
   config.restore();
   super.paint(g, c);
 }
Пример #16
0
 public static boolean shouldIgnore(MouseEvent mouseEvent, JComponent component) {
   return ((component == null)
       || (!(component.isEnabled()))
       || (!(SwingUtilities.isLeftMouseButton(mouseEvent)))
       || (mouseEvent.isConsumed()));
 }
Пример #17
0
  public static void main(String args[]) {
    JComponent ch = new JComponent() {};
    ch.getAccessibleContext();
    ch.isFocusTraversable();
    ch.setEnabled(false);
    ch.setEnabled(true);
    ch.requestFocus();
    ch.requestFocusInWindow();
    ch.getPreferredSize();
    ch.getMaximumSize();
    ch.getMinimumSize();
    ch.contains(1, 2);
    Component c1 = ch.add(new Component() {});
    Component c2 = ch.add(new Component() {});
    Component c3 = ch.add(new Component() {});
    Insets ins = ch.getInsets();
    ch.getAlignmentY();
    ch.getAlignmentX();
    ch.getGraphics();
    ch.setVisible(false);
    ch.setVisible(true);
    ch.setForeground(Color.red);
    ch.setBackground(Color.red);
    for (String font : Toolkit.getDefaultToolkit().getFontList()) {
      for (int j = 8; j < 17; j++) {
        Font f1 = new Font(font, Font.PLAIN, j);
        Font f2 = new Font(font, Font.BOLD, j);
        Font f3 = new Font(font, Font.ITALIC, j);
        Font f4 = new Font(font, Font.BOLD | Font.ITALIC, j);

        ch.setFont(f1);
        ch.setFont(f2);
        ch.setFont(f3);
        ch.setFont(f4);

        ch.getFontMetrics(f1);
        ch.getFontMetrics(f2);
        ch.getFontMetrics(f3);
        ch.getFontMetrics(f4);
      }
    }
    ch.enable();
    ch.disable();
    ch.reshape(10, 10, 10, 10);
    ch.getBounds(new Rectangle(1, 1, 1, 1));
    ch.getSize(new Dimension(1, 2));
    ch.getLocation(new Point(1, 2));
    ch.getX();
    ch.getY();
    ch.getWidth();
    ch.getHeight();
    ch.isOpaque();
    ch.isValidateRoot();
    ch.isOptimizedDrawingEnabled();
    ch.isDoubleBuffered();
    ch.getComponentCount();
    ch.countComponents();
    ch.getComponent(1);
    ch.getComponent(2);
    Component[] cs = ch.getComponents();
    ch.getLayout();
    ch.setLayout(new FlowLayout());
    ch.doLayout();
    ch.layout();
    ch.invalidate();
    ch.validate();
    ch.remove(0);
    ch.remove(c2);
    ch.removeAll();
    ch.preferredSize();
    ch.minimumSize();
    ch.getComponentAt(1, 2);
    ch.locate(1, 2);
    ch.getComponentAt(new Point(1, 2));
    ch.isFocusCycleRoot(new Container());
    ch.transferFocusBackward();
    ch.setName("goober");
    ch.getName();
    ch.getParent();
    ch.getGraphicsConfiguration();
    ch.getTreeLock();
    ch.getToolkit();
    ch.isValid();
    ch.isDisplayable();
    ch.isVisible();
    ch.isShowing();
    ch.isEnabled();
    ch.enable(false);
    ch.enable(true);
    ch.enableInputMethods(false);
    ch.enableInputMethods(true);
    ch.show();
    ch.show(false);
    ch.show(true);
    ch.hide();
    ch.getForeground();
    ch.isForegroundSet();
    ch.getBackground();
    ch.isBackgroundSet();
    ch.getFont();
    ch.isFontSet();
    Container c = new Container();
    c.add(ch);
    ch.getLocale();
    for (Locale locale : Locale.getAvailableLocales()) ch.setLocale(locale);

    ch.getColorModel();
    ch.getLocation();

    boolean exceptions = false;
    try {
      ch.getLocationOnScreen();
    } catch (IllegalComponentStateException e) {
      exceptions = true;
    }
    if (!exceptions)
      throw new RuntimeException("IllegalComponentStateException did not occur when expected");

    ch.location();
    ch.setLocation(1, 2);
    ch.move(1, 2);
    ch.setLocation(new Point(1, 2));
    ch.getSize();
    ch.size();
    ch.setSize(1, 32);
    ch.resize(1, 32);
    ch.setSize(new Dimension(1, 32));
    ch.resize(new Dimension(1, 32));
    ch.getBounds();
    ch.bounds();
    ch.setBounds(10, 10, 10, 10);
    ch.setBounds(new Rectangle(10, 10, 10, 10));
    ch.isLightweight();
    ch.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));
    ch.getCursor();
    ch.isCursorSet();
    ch.inside(1, 2);
    ch.contains(new Point(1, 2));
    ch.isFocusable();
    ch.setFocusable(true);
    ch.setFocusable(false);
    ch.transferFocus();
    ch.getFocusCycleRootAncestor();
    ch.nextFocus();
    ch.transferFocusUpCycle();
    ch.hasFocus();
    ch.isFocusOwner();
    ch.toString();
    ch.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
    ch.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
    ch.setComponentOrientation(ComponentOrientation.UNKNOWN);
    ch.getComponentOrientation();
  }
Пример #18
0
  protected void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds) {
    if (!c.isEnabled()) {
      return;
    }

    g.translate(thumbBounds.x, thumbBounds.y);

    Color colors[] = getThumbColors();

    Color frameColorHi = ColorHelper.brighter(colors[1], 20);
    Color frameColorLo = ColorHelper.darker(colors[colors.length - 1], 10);

    Graphics2D g2D = (Graphics2D) g;
    Composite savedComposite = g2D.getComposite();
    if (scrollbar.getOrientation() == JScrollBar.VERTICAL) {
      JTattooUtilities.fillVerGradient(
          g, colors, 1, 1, thumbBounds.width - 1, thumbBounds.height - 1);
      JTattooUtilities.draw3DBorder(
          g,
          frameColorLo,
          ColorHelper.darker(frameColorLo, 15),
          0,
          0,
          thumbBounds.width,
          thumbBounds.height);

      g2D.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.4f));
      g.setColor(frameColorHi);
      g.drawLine(1, 1, thumbBounds.width - 2, 1);
      g.drawLine(1, 1, 1, thumbBounds.height - 2);

      int dx = 5;
      int dy = thumbBounds.height / 2 - 3;
      int dw = thumbBounds.width - 11;

      Color c1 = Color.white;
      Color c2 = Color.darkGray;

      for (int i = 0; i < 4; i++) {
        g.setColor(c1);
        g.drawLine(dx, dy, dx + dw, dy);
        dy++;
        g.setColor(c2);
        g.drawLine(dx, dy, dx + dw, dy);
        dy++;
      }
      g2D.setComposite(savedComposite);
    } else { // HORIZONTAL
      JTattooUtilities.fillHorGradient(
          g, colors, 1, 1, thumbBounds.width - 1, thumbBounds.height - 1);
      JTattooUtilities.draw3DBorder(
          g,
          frameColorLo,
          ColorHelper.darker(frameColorLo, 10),
          0,
          0,
          thumbBounds.width,
          thumbBounds.height);

      g2D.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.4f));
      g.setColor(frameColorHi);
      g.drawLine(1, 1, thumbBounds.width - 2, 1);
      g.drawLine(1, 1, 1, thumbBounds.height - 2);

      int dx = thumbBounds.width / 2 - 3;
      int dy = 5;
      int dh = thumbBounds.height - 11;

      Color c1 = Color.white;
      Color c2 = Color.darkGray;

      for (int i = 0; i < 4; i++) {
        g.setColor(c1);
        g.drawLine(dx, dy, dx, dy + dh);
        dx++;
        g.setColor(c2);
        g.drawLine(dx, dy, dx, dy + dh);
        dx++;
      }
    }
    g2D.setComposite(savedComposite);

    g.translate(-thumbBounds.x, -thumbBounds.y);
  }
Пример #19
0
  protected void paintDeterminate(Graphics g, JComponent c) {
    if (!(g instanceof Graphics2D)) {
      return;
    }

    Graphics2D g2D = (Graphics2D) g;
    Insets b = progressBar.getInsets(); // area for border
    int w = progressBar.getWidth() - (b.right + b.left);
    int h = progressBar.getHeight() - (b.top + b.bottom);

    // amount of progress to draw
    int amountFull = getAmountFull(b, w, h);
    Color colors[];
    if (progressBar.getForeground() instanceof UIResource) {
      if (!Utilities.isActive(c)) {
        colors = BaseLookAndFeel.getTheme().getInActiveColors();
      } else if (c.isEnabled()) {
        colors = BaseLookAndFeel.getTheme().getProgressBarColors();
      } else {
        colors = BaseLookAndFeel.getTheme().getDisabledColors();
      }
    } else {
      Color hiColor = ColorHelper.brighter(progressBar.getForeground(), 40);
      Color loColor = ColorHelper.darker(progressBar.getForeground(), 20);
      colors = ColorHelper.createColorArr(hiColor, loColor, 20);
    }
    Color cHi = ColorHelper.darker(colors[colors.length - 1], 5);
    Color cLo = ColorHelper.darker(colors[colors.length - 1], 10);
    if (progressBar.getOrientation() == JProgressBar.HORIZONTAL) {
      if (Utilities.isLeftToRight(progressBar)) {
        Utilities.draw3DBorder(g, cHi, cLo, 1 + b.left, 2, amountFull - 2, h - 2);
        Utilities.fillHorGradient(g, colors, 2 + b.left, 3, amountFull - 4, h - 4);
      } else {
        Utilities.draw3DBorder(
            g,
            cHi,
            cLo,
            progressBar.getWidth() - amountFull - b.right + 2,
            2,
            amountFull - 2,
            h - 2);
        Utilities.fillHorGradient(
            g, colors, progressBar.getWidth() - amountFull - b.right + 3, 3, amountFull - 4, h - 4);
      }
    } else { // VERTICAL
      Utilities.draw3DBorder(g, cHi, cLo, 2, h - amountFull + 2, w - 2, amountFull - 2);
      Utilities.fillVerGradient(g, colors, 3, h - amountFull + 3, w - 4, amountFull - 4);
    }

    // Deal with possible text painting
    if (progressBar.isStringPainted()) {
      Object savedRenderingHint = null;
      if (BaseLookAndFeel.getTheme().isTextAntiAliasingOn()) {
        savedRenderingHint = g2D.getRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING);
        g2D.setRenderingHint(
            RenderingHints.KEY_TEXT_ANTIALIASING,
            BaseLookAndFeel.getTheme().getTextAntiAliasingHint());
      }
      paintString(g, b.left, b.top, w, h, amountFull, b);
      if (BaseLookAndFeel.getTheme().isTextAntiAliasingOn()) {
        g2D.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, savedRenderingHint);
      }
    }
  }