Exemple #1
0
    public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {

      JScrollPane scroll = (JScrollPane) c;
      JComponent colHeader = scroll.getColumnHeader();
      int colHeaderHeight = 0;
      if (colHeader != null) colHeaderHeight = colHeader.getHeight();

      JComponent rowHeader = scroll.getRowHeader();
      int rowHeaderWidth = 0;
      if (rowHeader != null) rowHeaderWidth = rowHeader.getWidth();

      g.translate(x, y);

      g.setColor(MetalLookAndFeel.getControlDarkShadow());
      g.drawRect(0, 0, w - 2, h - 2);
      g.setColor(MetalLookAndFeel.getControlHighlight());

      g.drawLine(w - 1, 1, w - 1, h - 1);
      g.drawLine(1, h - 1, w - 1, h - 1);

      g.setColor(MetalLookAndFeel.getControl());
      g.drawLine(w - 2, 2 + colHeaderHeight, w - 2, 2 + colHeaderHeight);
      g.drawLine(1 + rowHeaderWidth, h - 2, 1 + rowHeaderWidth, h - 2);

      g.translate(-x, -y);
    }
  /**
   * 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);
      }
    }
  }
Exemple #3
0
 /** This draws the "Flush 3D Border" which is used throughout the Metal L&F */
 static void drawFlush3DBorder(Graphics g, int x, int y, int w, int h) {
   g.translate(x, y);
   g.setColor(MetalLookAndFeel.getControlDarkShadow());
   g.drawRect(0, 0, w - 2, h - 2);
   g.setColor(MetalLookAndFeel.getControlHighlight());
   g.drawRect(1, 1, w - 2, h - 2);
   g.setColor(MetalLookAndFeel.getControl());
   g.drawLine(0, h - 1, 1, h - 2);
   g.drawLine(w - 1, 0, w - 2, 1);
   g.translate(-x, -y);
 }
Exemple #4
0
    public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
      g.translate(x, y);

      g.setColor(MetalLookAndFeel.getControlDarkShadow());
      g.drawLine(w - 1, 0, w - 1, h - 1);
      g.drawLine(1, h - 1, w - 1, h - 1);
      g.setColor(MetalLookAndFeel.getControlHighlight());
      g.drawLine(0, 0, w - 2, 0);
      g.drawLine(0, 0, 0, h - 2);

      g.translate(-x, -y);
    }
    public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
      g.translate(x, y);

      if (MetalLookAndFeel.usingOcean()) {
        g.setColor(MetalLookAndFeel.getControlDarkShadow());
        g.drawRect(0, 0, w, h - 1);
        g.setColor(MetalLookAndFeel.getControlShadow());
        g.drawRect(1, 1, w - 2, h - 3);
      } else {
        g.setColor(MetalLookAndFeel.getControlDarkShadow());
        g.drawLine(0, 0, w - 1, 0);
        g.drawLine(0, 0, 0, h - 2);
        g.drawLine(0, h - 2, w - 1, h - 2);
        g.setColor(MetalLookAndFeel.getControlHighlight());
        g.drawLine(1, 1, w - 1, 1);
        g.drawLine(1, 1, 1, h - 1);
        g.drawLine(1, h - 1, w - 1, h - 1);
        g.setColor(MetalLookAndFeel.getControl());
        g.drawLine(1, h - 2, 1, h - 2);
      }

      g.translate(-x, -y);
    }
/**
 * Class that manages a JLF title bar
 *
 * @author Steve Wilson
 * @author Brian Beck
 * @since 1.3
 */
public class MetalInternalFrameTitlePane extends BasicInternalFrameTitlePane {

  protected boolean isPalette = false;
  protected Icon paletteCloseIcon;
  protected int paletteTitleHeight;

  private static final Border handyEmptyBorder = new EmptyBorder(0, 0, 0, 0);

  /**
   * Key used to lookup Color from UIManager. If this is null, <code>getWindowTitleBackground</code>
   * is used.
   */
  private String selectedBackgroundKey;
  /**
   * Key used to lookup Color from UIManager. If this is null, <code>getWindowTitleForeground</code>
   * is used.
   */
  private String selectedForegroundKey;
  /**
   * Key used to lookup shadow color from UIManager. If this is null, <code>
   * getPrimaryControlDarkShadow</code> is used.
   */
  private String selectedShadowKey;
  /**
   * Boolean indicating the state of the <code>JInternalFrame</code>s closable property at <code>
   * updateUI</code> time.
   */
  private boolean wasClosable;

  int buttonsWidth = 0;

  MetalBumps activeBumps =
      new MetalBumps(
          0,
          0,
          MetalLookAndFeel.getPrimaryControlHighlight(),
          MetalLookAndFeel.getPrimaryControlDarkShadow(),
          (UIManager.get("InternalFrame.activeTitleGradient") != null)
              ? null
              : MetalLookAndFeel.getPrimaryControl());
  MetalBumps inactiveBumps =
      new MetalBumps(
          0,
          0,
          MetalLookAndFeel.getControlHighlight(),
          MetalLookAndFeel.getControlDarkShadow(),
          (UIManager.get("InternalFrame.inactiveTitleGradient") != null)
              ? null
              : MetalLookAndFeel.getControl());
  MetalBumps paletteBumps;

  private Color activeBumpsHighlight = MetalLookAndFeel.getPrimaryControlHighlight();
  private Color activeBumpsShadow = MetalLookAndFeel.getPrimaryControlDarkShadow();

  public MetalInternalFrameTitlePane(JInternalFrame f) {
    super(f);
  }

  public void addNotify() {
    super.addNotify();
    // This is done here instead of in installDefaults as I was worried
    // that the BasicInternalFrameUI might not be fully initialized, and
    // that if this resets the closable state the BasicInternalFrameUI
    // Listeners that get notified might be in an odd/uninitialized state.
    updateOptionPaneState();
  }

  protected void installDefaults() {
    super.installDefaults();
    setFont(UIManager.getFont("InternalFrame.titleFont"));
    paletteTitleHeight = UIManager.getInt("InternalFrame.paletteTitleHeight");
    paletteCloseIcon = UIManager.getIcon("InternalFrame.paletteCloseIcon");
    wasClosable = frame.isClosable();
    selectedForegroundKey = selectedBackgroundKey = null;
    if (MetalLookAndFeel.usingOcean()) {
      setOpaque(true);
    }
  }

  protected void uninstallDefaults() {
    super.uninstallDefaults();
    if (wasClosable != frame.isClosable()) {
      frame.setClosable(wasClosable);
    }
  }

  protected void createButtons() {
    super.createButtons();

    Boolean paintActive = frame.isSelected() ? Boolean.TRUE : Boolean.FALSE;
    iconButton.putClientProperty("paintActive", paintActive);
    iconButton.setBorder(handyEmptyBorder);

    maxButton.putClientProperty("paintActive", paintActive);
    maxButton.setBorder(handyEmptyBorder);

    closeButton.putClientProperty("paintActive", paintActive);
    closeButton.setBorder(handyEmptyBorder);

    // The palette close icon isn't opaque while the regular close icon is.
    // This makes sure palette close buttons have the right background.
    closeButton.setBackground(MetalLookAndFeel.getPrimaryControlShadow());

    if (MetalLookAndFeel.usingOcean()) {
      iconButton.setContentAreaFilled(false);
      maxButton.setContentAreaFilled(false);
      closeButton.setContentAreaFilled(false);
    }
  }

  /** Override the parent's method to do nothing. Metal frames do not have system menus. */
  protected void assembleSystemMenu() {}

  /** Override the parent's method to do nothing. Metal frames do not have system menus. */
  protected void addSystemMenuItems(JMenu systemMenu) {}

  /** Override the parent's method to do nothing. Metal frames do not have system menus. */
  protected void showSystemMenu() {}

  /**
   * Override the parent's method avoid creating a menu bar. Metal frames do not have system menus.
   */
  protected void addSubComponents() {
    add(iconButton);
    add(maxButton);
    add(closeButton);
  }

  protected PropertyChangeListener createPropertyChangeListener() {
    return new MetalPropertyChangeHandler();
  }

  protected LayoutManager createLayout() {
    return new MetalTitlePaneLayout();
  }

  class MetalPropertyChangeHandler extends BasicInternalFrameTitlePane.PropertyChangeHandler {
    public void propertyChange(PropertyChangeEvent evt) {
      String prop = (String) evt.getPropertyName();
      if (prop.equals(JInternalFrame.IS_SELECTED_PROPERTY)) {
        Boolean b = (Boolean) evt.getNewValue();
        iconButton.putClientProperty("paintActive", b);
        closeButton.putClientProperty("paintActive", b);
        maxButton.putClientProperty("paintActive", b);
      } else if ("JInternalFrame.messageType".equals(prop)) {
        updateOptionPaneState();
        frame.repaint();
      }
      super.propertyChange(evt);
    }
  }

  class MetalTitlePaneLayout extends TitlePaneLayout {
    public void addLayoutComponent(String name, Component c) {}

    public void removeLayoutComponent(Component c) {}

    public Dimension preferredLayoutSize(Container c) {
      return minimumLayoutSize(c);
    }

    public Dimension minimumLayoutSize(Container c) {
      // Compute width.
      int width = 30;
      if (frame.isClosable()) {
        width += 21;
      }
      if (frame.isMaximizable()) {
        width += 16 + (frame.isClosable() ? 10 : 4);
      }
      if (frame.isIconifiable()) {
        width += 16 + (frame.isMaximizable() ? 2 : (frame.isClosable() ? 10 : 4));
      }
      FontMetrics fm = frame.getFontMetrics(getFont());
      String frameTitle = frame.getTitle();
      int title_w = frameTitle != null ? SwingUtilities2.stringWidth(frame, fm, frameTitle) : 0;
      int title_length = frameTitle != null ? frameTitle.length() : 0;

      if (title_length > 2) {
        int subtitle_w =
            SwingUtilities2.stringWidth(frame, fm, frame.getTitle().substring(0, 2) + "...");
        width += (title_w < subtitle_w) ? title_w : subtitle_w;
      } else {
        width += title_w;
      }

      // Compute height.
      int height = 0;
      if (isPalette) {
        height = paletteTitleHeight;
      } else {
        int fontHeight = fm.getHeight();
        fontHeight += 7;
        Icon icon = frame.getFrameIcon();
        int iconHeight = 0;
        if (icon != null) {
          // SystemMenuBar forces the icon to be 16x16 or less.
          iconHeight = Math.min(icon.getIconHeight(), 16);
        }
        iconHeight += 5;
        height = Math.max(fontHeight, iconHeight);
      }

      return new Dimension(width, height);
    }

    public void layoutContainer(Container c) {
      boolean leftToRight = MetalUtils.isLeftToRight(frame);

      int w = getWidth();
      int x = leftToRight ? w : 0;
      int y = 2;
      int spacing;

      // assumes all buttons have the same dimensions
      // these dimensions include the borders
      int buttonHeight = closeButton.getIcon().getIconHeight();
      int buttonWidth = closeButton.getIcon().getIconWidth();

      if (frame.isClosable()) {
        if (isPalette) {
          spacing = 3;
          x += leftToRight ? -spacing - (buttonWidth + 2) : spacing;
          closeButton.setBounds(x, y, buttonWidth + 2, getHeight() - 4);
          if (!leftToRight) x += (buttonWidth + 2);
        } else {
          spacing = 4;
          x += leftToRight ? -spacing - buttonWidth : spacing;
          closeButton.setBounds(x, y, buttonWidth, buttonHeight);
          if (!leftToRight) x += buttonWidth;
        }
      }

      if (frame.isMaximizable() && !isPalette) {
        spacing = frame.isClosable() ? 10 : 4;
        x += leftToRight ? -spacing - buttonWidth : spacing;
        maxButton.setBounds(x, y, buttonWidth, buttonHeight);
        if (!leftToRight) x += buttonWidth;
      }

      if (frame.isIconifiable() && !isPalette) {
        spacing = frame.isMaximizable() ? 2 : (frame.isClosable() ? 10 : 4);
        x += leftToRight ? -spacing - buttonWidth : spacing;
        iconButton.setBounds(x, y, buttonWidth, buttonHeight);
        if (!leftToRight) x += buttonWidth;
      }

      buttonsWidth = leftToRight ? w - x : x;
    }
  }

  public void paintPalette(Graphics g) {
    boolean leftToRight = MetalUtils.isLeftToRight(frame);

    int width = getWidth();
    int height = getHeight();

    if (paletteBumps == null) {
      paletteBumps =
          new MetalBumps(
              0,
              0,
              MetalLookAndFeel.getPrimaryControlHighlight(),
              MetalLookAndFeel.getPrimaryControlInfo(),
              MetalLookAndFeel.getPrimaryControlShadow());
    }

    Color background = MetalLookAndFeel.getPrimaryControlShadow();
    Color darkShadow = MetalLookAndFeel.getPrimaryControlDarkShadow();

    g.setColor(background);
    g.fillRect(0, 0, width, height);

    g.setColor(darkShadow);
    g.drawLine(0, height - 1, width, height - 1);

    int xOffset = leftToRight ? 4 : buttonsWidth + 4;
    int bumpLength = width - buttonsWidth - 2 * 4;
    int bumpHeight = getHeight() - 4;
    paletteBumps.setBumpArea(bumpLength, bumpHeight);
    paletteBumps.paintIcon(this, g, xOffset, 2);
  }

  public void paintComponent(Graphics g) {
    if (isPalette) {
      paintPalette(g);
      return;
    }

    boolean leftToRight = MetalUtils.isLeftToRight(frame);
    boolean isSelected = frame.isSelected();

    int width = getWidth();
    int height = getHeight();

    Color background = null;
    Color foreground = null;
    Color shadow = null;

    MetalBumps bumps;
    String gradientKey;

    if (isSelected) {
      if (!MetalLookAndFeel.usingOcean()) {
        closeButton.setContentAreaFilled(true);
        maxButton.setContentAreaFilled(true);
        iconButton.setContentAreaFilled(true);
      }
      if (selectedBackgroundKey != null) {
        background = UIManager.getColor(selectedBackgroundKey);
      }
      if (background == null) {
        background = MetalLookAndFeel.getWindowTitleBackground();
      }
      if (selectedForegroundKey != null) {
        foreground = UIManager.getColor(selectedForegroundKey);
      }
      if (selectedShadowKey != null) {
        shadow = UIManager.getColor(selectedShadowKey);
      }
      if (shadow == null) {
        shadow = MetalLookAndFeel.getPrimaryControlDarkShadow();
      }
      if (foreground == null) {
        foreground = MetalLookAndFeel.getWindowTitleForeground();
      }
      activeBumps.setBumpColors(
          activeBumpsHighlight,
          activeBumpsShadow,
          UIManager.get("InternalFrame.activeTitleGradient") != null ? null : background);
      bumps = activeBumps;
      gradientKey = "InternalFrame.activeTitleGradient";
    } else {
      if (!MetalLookAndFeel.usingOcean()) {
        closeButton.setContentAreaFilled(false);
        maxButton.setContentAreaFilled(false);
        iconButton.setContentAreaFilled(false);
      }
      background = MetalLookAndFeel.getWindowTitleInactiveBackground();
      foreground = MetalLookAndFeel.getWindowTitleInactiveForeground();
      shadow = MetalLookAndFeel.getControlDarkShadow();
      bumps = inactiveBumps;
      gradientKey = "InternalFrame.inactiveTitleGradient";
    }

    if (!MetalUtils.drawGradient(this, g, gradientKey, 0, 0, width, height, true)) {
      g.setColor(background);
      g.fillRect(0, 0, width, height);
    }

    g.setColor(shadow);
    g.drawLine(0, height - 1, width, height - 1);
    g.drawLine(0, 0, 0, 0);
    g.drawLine(width - 1, 0, width - 1, 0);

    int titleLength = 0;
    int xOffset = leftToRight ? 5 : width - 5;
    String frameTitle = frame.getTitle();

    Icon icon = frame.getFrameIcon();
    if (icon != null) {
      if (!leftToRight) xOffset -= icon.getIconWidth();
      int iconY = ((height / 2) - (icon.getIconHeight() / 2));
      icon.paintIcon(frame, g, xOffset, iconY);
      xOffset += leftToRight ? icon.getIconWidth() + 5 : -5;
    }

    if (frameTitle != null) {
      Font f = getFont();
      g.setFont(f);
      FontMetrics fm = SwingUtilities2.getFontMetrics(frame, g, f);
      int fHeight = fm.getHeight();

      g.setColor(foreground);

      int yOffset = ((height - fm.getHeight()) / 2) + fm.getAscent();

      Rectangle rect = new Rectangle(0, 0, 0, 0);
      if (frame.isIconifiable()) {
        rect = iconButton.getBounds();
      } else if (frame.isMaximizable()) {
        rect = maxButton.getBounds();
      } else if (frame.isClosable()) {
        rect = closeButton.getBounds();
      }
      int titleW;

      if (leftToRight) {
        if (rect.x == 0) {
          rect.x = frame.getWidth() - frame.getInsets().right - 2;
        }
        titleW = rect.x - xOffset - 4;
        frameTitle = getTitle(frameTitle, fm, titleW);
      } else {
        titleW = xOffset - rect.x - rect.width - 4;
        frameTitle = getTitle(frameTitle, fm, titleW);
        xOffset -= SwingUtilities2.stringWidth(frame, fm, frameTitle);
      }

      titleLength = SwingUtilities2.stringWidth(frame, fm, frameTitle);
      SwingUtilities2.drawString(frame, g, frameTitle, xOffset, yOffset);
      xOffset += leftToRight ? titleLength + 5 : -5;
    }

    int bumpXOffset;
    int bumpLength;
    if (leftToRight) {
      bumpLength = width - buttonsWidth - xOffset - 5;
      bumpXOffset = xOffset;
    } else {
      bumpLength = xOffset - buttonsWidth - 5;
      bumpXOffset = buttonsWidth + 5;
    }
    int bumpYOffset = 3;
    int bumpHeight = getHeight() - (2 * bumpYOffset);
    bumps.setBumpArea(bumpLength, bumpHeight);
    bumps.paintIcon(this, g, bumpXOffset, bumpYOffset);
  }

  public void setPalette(boolean b) {
    isPalette = b;

    if (isPalette) {
      closeButton.setIcon(paletteCloseIcon);
      if (frame.isMaximizable()) remove(maxButton);
      if (frame.isIconifiable()) remove(iconButton);
    } else {
      closeButton.setIcon(closeIcon);
      if (frame.isMaximizable()) add(maxButton);
      if (frame.isIconifiable()) add(iconButton);
    }
    revalidate();
    repaint();
  }

  /**
   * Updates any state dependant upon the JInternalFrame being shown in a <code>JOptionPane</code>.
   */
  private void updateOptionPaneState() {
    int type = -2;
    boolean closable = wasClosable;
    Object obj = frame.getClientProperty("JInternalFrame.messageType");

    if (obj == null) {
      // Don't change the closable state unless in an JOptionPane.
      return;
    }
    if (obj instanceof Integer) {
      type = ((Integer) obj).intValue();
    }
    switch (type) {
      case JOptionPane.ERROR_MESSAGE:
        selectedBackgroundKey = "OptionPane.errorDialog.titlePane.background";
        selectedForegroundKey = "OptionPane.errorDialog.titlePane.foreground";
        selectedShadowKey = "OptionPane.errorDialog.titlePane.shadow";
        closable = false;
        break;
      case JOptionPane.QUESTION_MESSAGE:
        selectedBackgroundKey = "OptionPane.questionDialog.titlePane.background";
        selectedForegroundKey = "OptionPane.questionDialog.titlePane.foreground";
        selectedShadowKey = "OptionPane.questionDialog.titlePane.shadow";
        closable = false;
        break;
      case JOptionPane.WARNING_MESSAGE:
        selectedBackgroundKey = "OptionPane.warningDialog.titlePane.background";
        selectedForegroundKey = "OptionPane.warningDialog.titlePane.foreground";
        selectedShadowKey = "OptionPane.warningDialog.titlePane.shadow";
        closable = false;
        break;
      case JOptionPane.INFORMATION_MESSAGE:
      case JOptionPane.PLAIN_MESSAGE:
        selectedBackgroundKey = selectedForegroundKey = selectedShadowKey = null;
        closable = false;
        break;
      default:
        selectedBackgroundKey = selectedForegroundKey = selectedShadowKey = null;
        break;
    }
    if (closable != frame.isClosable()) {
      frame.setClosable(closable);
    }
  }
}
/**
 * Metal's split pane divider
 *
 * <p><strong>Warning:</strong> Serialized objects of this class will not be compatible with future
 * Swing releases. The current serialization support is appropriate for short term storage or RMI
 * between applications running the same version of Swing. As of 1.4, support for long term storage
 * of all JavaBeans<sup><font size="-2">TM</font></sup> has been added to the <code>java.beans
 * </code> package. Please see {@link java.beans.XMLEncoder}.
 *
 * @author Steve Wilson
 * @author Ralph kar
 */
class MetalSplitPaneDivider extends BasicSplitPaneDivider {
  private MetalBumps bumps =
      new MetalBumps(
          10,
          10,
          MetalLookAndFeel.getControlHighlight(),
          MetalLookAndFeel.getControlDarkShadow(),
          MetalLookAndFeel.getControl());

  private MetalBumps focusBumps =
      new MetalBumps(
          10,
          10,
          MetalLookAndFeel.getPrimaryControlHighlight(),
          MetalLookAndFeel.getPrimaryControlDarkShadow(),
          UIManager.getColor("SplitPane.dividerFocusColor"));

  private int inset = 2;

  private Color controlColor = MetalLookAndFeel.getControl();
  private Color primaryControlColor = UIManager.getColor("SplitPane.dividerFocusColor");

  public MetalSplitPaneDivider(BasicSplitPaneUI ui) {
    super(ui);
  }

  public void paint(Graphics g) {
    MetalBumps usedBumps;
    if (splitPane.hasFocus()) {
      usedBumps = focusBumps;
      g.setColor(primaryControlColor);
    } else {
      usedBumps = bumps;
      g.setColor(controlColor);
    }
    Rectangle clip = g.getClipBounds();
    Insets insets = getInsets();
    g.fillRect(clip.x, clip.y, clip.width, clip.height);
    Dimension size = getSize();
    size.width -= inset * 2;
    size.height -= inset * 2;
    int drawX = inset;
    int drawY = inset;
    if (insets != null) {
      size.width -= (insets.left + insets.right);
      size.height -= (insets.top + insets.bottom);
      drawX += insets.left;
      drawY += insets.top;
    }
    usedBumps.setBumpArea(size);
    usedBumps.paintIcon(this, g, drawX, drawY);
    super.paint(g);
  }

  /**
   * Creates and return an instance of JButton that can be used to collapse the left component in
   * the metal split pane.
   */
  protected JButton createLeftOneTouchButton() {
    JButton b =
        new JButton() {
          // Sprite buffer for the arrow image of the left button
          int[][] buffer = {
            {0, 0, 0, 2, 2, 0, 0, 0, 0},
            {0, 0, 2, 1, 1, 1, 0, 0, 0},
            {0, 2, 1, 1, 1, 1, 1, 0, 0},
            {2, 1, 1, 1, 1, 1, 1, 1, 0},
            {0, 3, 3, 3, 3, 3, 3, 3, 3}
          };

          public void setBorder(Border b) {}

          public void paint(Graphics g) {
            JSplitPane splitPane = getSplitPaneFromSuper();
            if (splitPane != null) {
              int oneTouchSize = getOneTouchSizeFromSuper();
              int orientation = getOrientationFromSuper();
              int blockSize = Math.min(getDividerSize(), oneTouchSize);

              // Initialize the color array
              Color[] colors = {
                this.getBackground(),
                MetalLookAndFeel.getPrimaryControlDarkShadow(),
                MetalLookAndFeel.getPrimaryControlInfo(),
                MetalLookAndFeel.getPrimaryControlHighlight()
              };

              // Fill the background first ...
              g.setColor(this.getBackground());
              if (isOpaque()) {
                g.fillRect(0, 0, this.getWidth(), this.getHeight());
              }

              // ... then draw the arrow.
              if (getModel().isPressed()) {
                // Adjust color mapping for pressed button state
                colors[1] = colors[2];
              }
              if (orientation == JSplitPane.VERTICAL_SPLIT) {
                // Draw the image for a vertical split
                for (int i = 1; i <= buffer[0].length; i++) {
                  for (int j = 1; j < blockSize; j++) {
                    if (buffer[j - 1][i - 1] == 0) {
                      continue;
                    } else {
                      g.setColor(colors[buffer[j - 1][i - 1]]);
                    }
                    g.drawLine(i, j, i, j);
                  }
                }
              } else {
                // Draw the image for a horizontal split
                // by simply swaping the i and j axis.
                // Except the drawLine() call this code is
                // identical to the code block above. This was done
                // in order to remove the additional orientation
                // check for each pixel.
                for (int i = 1; i <= buffer[0].length; i++) {
                  for (int j = 1; j < blockSize; j++) {
                    if (buffer[j - 1][i - 1] == 0) {
                      // Nothing needs
                      // to be drawn
                      continue;
                    } else {
                      // Set the color from the
                      // color map
                      g.setColor(colors[buffer[j - 1][i - 1]]);
                    }
                    // Draw a pixel
                    g.drawLine(j, i, j, i);
                  }
                }
              }
            }
          }

          // Don't want the button to participate in focus traversable.
          public boolean isFocusTraversable() {
            return false;
          }
        };
    b.setRequestFocusEnabled(false);
    b.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    b.setFocusPainted(false);
    b.setBorderPainted(false);
    maybeMakeButtonOpaque(b);
    return b;
  }

  /** If necessary <code>c</code> is made opaque. */
  private void maybeMakeButtonOpaque(JComponent c) {
    Object opaque = UIManager.get("SplitPane.oneTouchButtonsOpaque");
    if (opaque != null) {
      c.setOpaque(((Boolean) opaque).booleanValue());
    }
  }

  /**
   * Creates and return an instance of JButton that can be used to collapse the right component in
   * the metal split pane.
   */
  protected JButton createRightOneTouchButton() {
    JButton b =
        new JButton() {
          // Sprite buffer for the arrow image of the right button
          int[][] buffer = {
            {2, 2, 2, 2, 2, 2, 2, 2},
            {0, 1, 1, 1, 1, 1, 1, 3},
            {0, 0, 1, 1, 1, 1, 3, 0},
            {0, 0, 0, 1, 1, 3, 0, 0},
            {0, 0, 0, 0, 3, 0, 0, 0}
          };

          public void setBorder(Border border) {}

          public void paint(Graphics g) {
            JSplitPane splitPane = getSplitPaneFromSuper();
            if (splitPane != null) {
              int oneTouchSize = getOneTouchSizeFromSuper();
              int orientation = getOrientationFromSuper();
              int blockSize = Math.min(getDividerSize(), oneTouchSize);

              // Initialize the color array
              Color[] colors = {
                this.getBackground(),
                MetalLookAndFeel.getPrimaryControlDarkShadow(),
                MetalLookAndFeel.getPrimaryControlInfo(),
                MetalLookAndFeel.getPrimaryControlHighlight()
              };

              // Fill the background first ...
              g.setColor(this.getBackground());
              if (isOpaque()) {
                g.fillRect(0, 0, this.getWidth(), this.getHeight());
              }

              // ... then draw the arrow.
              if (getModel().isPressed()) {
                // Adjust color mapping for pressed button state
                colors[1] = colors[2];
              }
              if (orientation == JSplitPane.VERTICAL_SPLIT) {
                // Draw the image for a vertical split
                for (int i = 1; i <= buffer[0].length; i++) {
                  for (int j = 1; j < blockSize; j++) {
                    if (buffer[j - 1][i - 1] == 0) {
                      continue;
                    } else {
                      g.setColor(colors[buffer[j - 1][i - 1]]);
                    }
                    g.drawLine(i, j, i, j);
                  }
                }
              } else {
                // Draw the image for a horizontal split
                // by simply swaping the i and j axis.
                // Except the drawLine() call this code is
                // identical to the code block above. This was done
                // in order to remove the additional orientation
                // check for each pixel.
                for (int i = 1; i <= buffer[0].length; i++) {
                  for (int j = 1; j < blockSize; j++) {
                    if (buffer[j - 1][i - 1] == 0) {
                      // Nothing needs
                      // to be drawn
                      continue;
                    } else {
                      // Set the color from the
                      // color map
                      g.setColor(colors[buffer[j - 1][i - 1]]);
                    }
                    // Draw a pixel
                    g.drawLine(j, i, j, i);
                  }
                }
              }
            }
          }

          // Don't want the button to participate in focus traversable.
          public boolean isFocusTraversable() {
            return false;
          }
        };
    b.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    b.setFocusPainted(false);
    b.setBorderPainted(false);
    b.setRequestFocusEnabled(false);
    maybeMakeButtonOpaque(b);
    return b;
  }

  /**
   * Used to layout a MetalSplitPaneDivider. Layout for the divider involves appropriately moving
   * the left/right buttons around.
   *
   * <p>This class should be treated as a &quot;protected&quot; inner class. Instantiate it only
   * within subclasses of MetalSplitPaneDivider.
   */
  public class MetalDividerLayout implements LayoutManager {

    // NOTE NOTE NOTE NOTE NOTE
    // This class is no longer used, the functionality has
    // been rolled into BasicSplitPaneDivider.DividerLayout as a
    // defaults property

    public void layoutContainer(Container c) {
      JButton leftButton = getLeftButtonFromSuper();
      JButton rightButton = getRightButtonFromSuper();
      JSplitPane splitPane = getSplitPaneFromSuper();
      int orientation = getOrientationFromSuper();
      int oneTouchSize = getOneTouchSizeFromSuper();
      int oneTouchOffset = getOneTouchOffsetFromSuper();
      Insets insets = getInsets();

      // This layout differs from the one used in BasicSplitPaneDivider.
      // It does not center justify the oneTouchExpadable buttons.
      // This was necessary in order to meet the spec of the Metal
      // splitpane divider.
      if (leftButton != null && rightButton != null && c == MetalSplitPaneDivider.this) {
        if (splitPane.isOneTouchExpandable()) {
          if (orientation == JSplitPane.VERTICAL_SPLIT) {
            int extraY = (insets != null) ? insets.top : 0;
            int blockSize = getDividerSize();

            if (insets != null) {
              blockSize -= (insets.top + insets.bottom);
            }
            blockSize = Math.min(blockSize, oneTouchSize);
            leftButton.setBounds(oneTouchOffset, extraY, blockSize * 2, blockSize);
            rightButton.setBounds(
                oneTouchOffset + oneTouchSize * 2, extraY, blockSize * 2, blockSize);
          } else {
            int blockSize = getDividerSize();
            int extraX = (insets != null) ? insets.left : 0;

            if (insets != null) {
              blockSize -= (insets.left + insets.right);
            }
            blockSize = Math.min(blockSize, oneTouchSize);
            leftButton.setBounds(extraX, oneTouchOffset, blockSize, blockSize * 2);
            rightButton.setBounds(
                extraX, oneTouchOffset + oneTouchSize * 2, blockSize, blockSize * 2);
          }
        } else {
          leftButton.setBounds(-5, -5, 1, 1);
          rightButton.setBounds(-5, -5, 1, 1);
        }
      }
    }

    public Dimension minimumLayoutSize(Container c) {
      return new Dimension(0, 0);
    }

    public Dimension preferredLayoutSize(Container c) {
      return new Dimension(0, 0);
    }

    public void removeLayoutComponent(Component c) {}

    public void addLayoutComponent(String string, Component c) {}
  }

  /*
   * The following methods only exist in order to be able to access protected
   * members in the superclass, because these are otherwise not available
   * in any inner class.
   */

  int getOneTouchSizeFromSuper() {
    return super.ONE_TOUCH_SIZE;
  }

  int getOneTouchOffsetFromSuper() {
    return super.ONE_TOUCH_OFFSET;
  }

  int getOrientationFromSuper() {
    return super.orientation;
  }

  JSplitPane getSplitPaneFromSuper() {
    return super.splitPane;
  }

  JButton getLeftButtonFromSuper() {
    return super.leftButton;
  }

  JButton getRightButtonFromSuper() {
    return super.rightButton;
  }
}
Exemple #8
0
 /** Constructs a new instance. */
 public MetalSliderUI() {
   super(null);
   filledSlider = UIManager.getBoolean(SLIDER_FILL);
   darkShadowColor = MetalLookAndFeel.getControlDarkShadow();
   highlightColor = MetalLookAndFeel.getControlHighlight();
 }
Exemple #9
0
  public static class ToolBarBorder extends AbstractBorder implements UIResource, SwingConstants {
    protected MetalBumps bumps =
        new MetalBumps(
            10,
            10,
            MetalLookAndFeel.getControlHighlight(),
            MetalLookAndFeel.getControlDarkShadow(),
            UIManager.getColor("ToolBar.background"));

    public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
      g.translate(x, y);

      if (((JToolBar) c).isFloatable()) {
        if (((JToolBar) c).getOrientation() == HORIZONTAL) {
          int shift = MetalLookAndFeel.usingOcean() ? -1 : 0;
          bumps.setBumpArea(10, h - 4);
          if (MetalUtils.isLeftToRight(c)) {
            bumps.paintIcon(c, g, 2, 2 + shift);
          } else {
            bumps.paintIcon(c, g, w - 12, 2 + shift);
          }
        } else // vertical
        {
          bumps.setBumpArea(w - 4, 10);
          bumps.paintIcon(c, g, 2, 2);
        }
      }

      if (((JToolBar) c).getOrientation() == HORIZONTAL && MetalLookAndFeel.usingOcean()) {
        g.setColor(MetalLookAndFeel.getControl());
        g.drawLine(0, h - 2, w, h - 2);
        g.setColor(UIManager.getColor("ToolBar.borderColor"));
        g.drawLine(0, h - 1, w, h - 1);
      }

      g.translate(-x, -y);
    }

    public Insets getBorderInsets(Component c) {
      return getBorderInsets(c, new Insets(0, 0, 0, 0));
    }

    public Insets getBorderInsets(Component c, Insets newInsets) {
      if (MetalLookAndFeel.usingOcean()) {
        newInsets.set(1, 2, 3, 2);
      } else {
        newInsets.top = newInsets.left = newInsets.bottom = newInsets.right = 2;
      }

      if (((JToolBar) c).isFloatable()) {
        if (((JToolBar) c).getOrientation() == HORIZONTAL) {
          if (c.getComponentOrientation().isLeftToRight()) {
            newInsets.left = 16;
          } else {
            newInsets.right = 16;
          }
        } else { // vertical
          newInsets.top = 16;
        }
      }

      Insets margin = ((JToolBar) c).getMargin();

      if (margin != null) {
        newInsets.left += margin.left;
        newInsets.top += margin.top;
        newInsets.right += margin.right;
        newInsets.bottom += margin.bottom;
      }

      return newInsets;
    }
  }
Exemple #10
0
/*      */ class MetalTitlePane extends JComponent
/*      */ {
  /*   53 */ private static final Border handyEmptyBorder = new EmptyBorder(0, 0, 0, 0);
  /*      */ private static final int IMAGE_HEIGHT = 16;
  /*      */ private static final int IMAGE_WIDTH = 16;
  /*      */ private PropertyChangeListener propertyChangeListener;
  /*      */ private JMenuBar menuBar;
  /*      */ private Action closeAction;
  /*      */ private Action iconifyAction;
  /*      */ private Action restoreAction;
  /*      */ private Action maximizeAction;
  /*      */ private JButton toggleButton;
  /*      */ private JButton iconifyButton;
  /*      */ private JButton closeButton;
  /*      */ private Icon maximizeIcon;
  /*      */ private Icon minimizeIcon;
  /*      */ private Image systemIcon;
  /*      */ private WindowListener windowListener;
  /*      */ private Window window;
  /*      */ private JRootPane rootPane;
  /*      */ private int buttonsWidth;
  /*      */ private int state;
  /*      */ private MetalRootPaneUI rootPaneUI;
  /*  150 */ private Color inactiveBackground = UIManager.getColor("inactiveCaption");
  /*  151 */ private Color inactiveForeground = UIManager.getColor("inactiveCaptionText");
  /*  152 */ private Color inactiveShadow = UIManager.getColor("inactiveCaptionBorder");
  /*  153 */ private Color activeBumpsHighlight = MetalLookAndFeel.getPrimaryControlHighlight();
  /*  154 */ private Color activeBumpsShadow = MetalLookAndFeel.getPrimaryControlDarkShadow();
  /*  155 */ private Color activeBackground = null;
  /*  156 */ private Color activeForeground = null;
  /*  157 */ private Color activeShadow = null;
  /*      */
  /*  160 */ private MetalBumps activeBumps =
      new MetalBumps(
          0,
          0,
          this.activeBumpsHighlight,
          this.activeBumpsShadow,
          MetalLookAndFeel.getPrimaryControl());
  /*      */
  /*  165 */ private MetalBumps inactiveBumps =
      new MetalBumps(
          0,
          0,
          MetalLookAndFeel.getControlHighlight(),
          MetalLookAndFeel.getControlDarkShadow(),
          MetalLookAndFeel.getControl());
  /*      */
  /*      */ public MetalTitlePane(JRootPane paramJRootPane, MetalRootPaneUI paramMetalRootPaneUI)
        /*      */ {
    /*  173 */ this.rootPane = paramJRootPane;
    /*  174 */ this.rootPaneUI = paramMetalRootPaneUI;
    /*      */
    /*  176 */ this.state = -1;
    /*      */
    /*  178 */ installSubcomponents();
    /*  179 */ determineColors();
    /*  180 */ installDefaults();
    /*      */
    /*  182 */ setLayout(createLayout());
    /*      */ }
  /*      */
  /*      */ private void uninstall() /*      */ {
    /*  189 */ uninstallListeners();
    /*  190 */ this.window = null;
    /*  191 */ removeAll();
    /*      */ }
  /*      */
  /*      */ private void installListeners() /*      */ {
    /*  198 */ if (this.window != null) {
      /*  199 */ this.windowListener = createWindowListener();
      /*  200 */ this.window.addWindowListener(this.windowListener);
      /*  201 */ this.propertyChangeListener = createWindowPropertyChangeListener();
      /*  202 */ this.window.addPropertyChangeListener(this.propertyChangeListener);
      /*      */ }
    /*      */ }
  /*      */
  /*      */ private void uninstallListeners() /*      */ {
    /*  210 */ if (this.window != null) {
      /*  211 */ this.window.removeWindowListener(this.windowListener);
      /*  212 */ this.window.removePropertyChangeListener(this.propertyChangeListener);
      /*      */ }
    /*      */ }
  /*      */
  /*      */ private WindowListener createWindowListener() /*      */ {
    /*  221 */ return new WindowHandler(null);
    /*      */ }
  /*      */
  /*      */ private PropertyChangeListener createWindowPropertyChangeListener() /*      */ {
    /*  229 */ return new PropertyChangeHandler(null);
    /*      */ }
  /*      */
  /*      */ public JRootPane getRootPane() /*      */ {
    /*  236 */ return this.rootPane;
    /*      */ }
  /*      */
  /*      */ private int getWindowDecorationStyle() /*      */ {
    /*  243 */ return getRootPane().getWindowDecorationStyle();
    /*      */ }
  /*      */
  /*      */ public void addNotify() {
    /*  247 */ super.addNotify();
    /*      */
    /*  249 */ uninstallListeners();
    /*      */
    /*  251 */ this.window = SwingUtilities.getWindowAncestor(this);
    /*  252 */ if (this.window != null) {
      /*  253 */ if ((this.window instanceof Frame)) {
        /*  254 */ setState(((Frame) this.window).getExtendedState());
        /*      */ }
      /*      */ else {
        /*  257 */ setState(0);
        /*      */ }
      /*  259 */ setActive(this.window.isActive());
      /*  260 */ installListeners();
      /*  261 */ updateSystemIcon();
      /*      */ }
    /*      */ }
  /*      */
  /*      */ public void removeNotify() {
    /*  266 */ super.removeNotify();
    /*      */
    /*  268 */ uninstallListeners();
    /*  269 */ this.window = null;
    /*      */ }
  /*      */
  /*      */ private void installSubcomponents() /*      */ {
    /*  276 */ int i = getWindowDecorationStyle();
    /*  277 */ if (i == 1) {
      /*  278 */ createActions();
      /*  279 */ this.menuBar = createMenuBar();
      /*  280 */ add(this.menuBar);
      /*  281 */ createButtons();
      /*  282 */ add(this.iconifyButton);
      /*  283 */ add(this.toggleButton);
      /*  284 */ add(this.closeButton);
      /*  285 */ } else if ((i == 2) || (i == 3) || (i == 4) || (i == 5) || (i == 6) || (i == 7)
        || (i == 8))
    /*      */ {
      /*  292 */ createActions();
      /*  293 */ createButtons();
      /*  294 */ add(this.closeButton);
      /*      */ }
    /*      */ }
  /*      */
  /*      */ private void determineColors() /*      */ {
    /*  302 */ switch (getWindowDecorationStyle()) {
        /*      */ case 1:
        /*  304 */ this.activeBackground = UIManager.getColor("activeCaption");
        /*  305 */ this.activeForeground = UIManager.getColor("activeCaptionText");
        /*  306 */ this.activeShadow = UIManager.getColor("activeCaptionBorder");
        /*  307 */ break;
        /*      */ case 4:
        /*  309 */ this.activeBackground =
            UIManager.getColor("OptionPane.errorDialog.titlePane.background");
        /*      */
        /*  311 */ this.activeForeground =
            UIManager.getColor("OptionPane.errorDialog.titlePane.foreground");
        /*      */
        /*  313 */ this.activeShadow =
            UIManager.getColor("OptionPane.errorDialog.titlePane.shadow");
        /*      */
        /*  315 */ break;
        /*      */ case 5:
        /*      */ case 6:
        /*      */ case 7:
        /*  319 */ this.activeBackground =
            UIManager.getColor("OptionPane.questionDialog.titlePane.background");
        /*      */
        /*  321 */ this.activeForeground =
            UIManager.getColor("OptionPane.questionDialog.titlePane.foreground");
        /*      */
        /*  323 */ this.activeShadow =
            UIManager.getColor("OptionPane.questionDialog.titlePane.shadow");
        /*      */
        /*  325 */ break;
        /*      */ case 8:
        /*  327 */ this.activeBackground =
            UIManager.getColor("OptionPane.warningDialog.titlePane.background");
        /*      */
        /*  329 */ this.activeForeground =
            UIManager.getColor("OptionPane.warningDialog.titlePane.foreground");
        /*      */
        /*  331 */ this.activeShadow =
            UIManager.getColor("OptionPane.warningDialog.titlePane.shadow");
        /*      */
        /*  333 */ break;
        /*      */ case 2:
        /*      */ case 3:
        /*      */ default:
        /*  337 */ this.activeBackground = UIManager.getColor("activeCaption");
        /*  338 */ this.activeForeground = UIManager.getColor("activeCaptionText");
        /*  339 */ this.activeShadow = UIManager.getColor("activeCaptionBorder");
        /*      */ }
    /*      */
    /*  342 */ this.activeBumps.setBumpColors(
        this.activeBumpsHighlight, this.activeBumpsShadow, this.activeBackground);
    /*      */ }
  /*      */
  /*      */ private void installDefaults() /*      */ {
    /*  350 */ setFont(UIManager.getFont("InternalFrame.titleFont", getLocale()));
    /*      */ }
  /*      */
  /*      */ private void uninstallDefaults() /*      */ {
    /*      */ }
  /*      */
  /*      */ protected JMenuBar createMenuBar() /*      */ {
    /*  364 */ this.menuBar = new SystemMenuBar(null);
    /*  365 */ this.menuBar.setFocusable(false);
    /*  366 */ this.menuBar.setBorderPainted(true);
    /*  367 */ this.menuBar.add(createMenu());
    /*  368 */ return this.menuBar;
    /*      */ }
  /*      */
  /*      */ private void close() /*      */ {
    /*  375 */ Window localWindow = getWindow();
    /*      */
    /*  377 */ if (localWindow != null)
      /*  378 */ localWindow.dispatchEvent(new WindowEvent(localWindow, 201));
    /*      */ }
  /*      */
  /*      */ private void iconify() /*      */ {
    /*  387 */ Frame localFrame = getFrame();
    /*  388 */ if (localFrame != null) /*  389 */ localFrame.setExtendedState(this.state | 0x1);
    /*      */ }
  /*      */
  /*      */ private void maximize() /*      */ {
    /*  397 */ Frame localFrame = getFrame();
    /*  398 */ if (localFrame != null) /*  399 */ localFrame.setExtendedState(this.state | 0x6);
    /*      */ }
  /*      */
  /*      */ private void restore() /*      */ {
    /*  407 */ Frame localFrame = getFrame();
    /*      */
    /*  409 */ if (localFrame == null) {
      /*  410 */ return;
      /*      */ }
    /*      */
    /*  413 */ if ((this.state & 0x1) != 0)
      /*  414 */ localFrame.setExtendedState(this.state & 0xFFFFFFFE);
    /*      */ else /*  416 */ localFrame.setExtendedState(this.state & 0xFFFFFFF9);
    /*      */ }
  /*      */
  /*      */ private void createActions() /*      */ {
    /*  425 */ this.closeAction = new CloseAction();
    /*  426 */ if (getWindowDecorationStyle() == 1) {
      /*  427 */ this.iconifyAction = new IconifyAction();
      /*  428 */ this.restoreAction = new RestoreAction();
      /*  429 */ this.maximizeAction = new MaximizeAction();
      /*      */ }
    /*      */ }
  /*      */
  /*      */ private JMenu createMenu() /*      */ {
    /*  438 */ JMenu localJMenu = new JMenu("");
    /*  439 */ if (getWindowDecorationStyle() == 1) {
      /*  440 */ addMenuItems(localJMenu);
      /*      */ }
    /*  442 */ return localJMenu;
    /*      */ }
  /*      */
  /*      */ private void addMenuItems(JMenu paramJMenu) /*      */ {
    /*  449 */ Locale localLocale = getRootPane().getLocale();
    /*  450 */ JMenuItem localJMenuItem = paramJMenu.add(this.restoreAction);
    /*  451 */ int i = MetalUtils.getInt("MetalTitlePane.restoreMnemonic", -1);
    /*      */
    /*  453 */ if (i != -1) {
      /*  454 */ localJMenuItem.setMnemonic(i);
      /*      */ }
    /*      */
    /*  457 */ localJMenuItem = paramJMenu.add(this.iconifyAction);
    /*  458 */ i = MetalUtils.getInt("MetalTitlePane.iconifyMnemonic", -1);
    /*  459 */ if (i != -1) {
      /*  460 */ localJMenuItem.setMnemonic(i);
      /*      */ }
    /*      */
    /*  463 */ if (Toolkit.getDefaultToolkit().isFrameStateSupported(6))
    /*      */ {
      /*  465 */ localJMenuItem = paramJMenu.add(this.maximizeAction);
      /*  466 */ i = MetalUtils.getInt("MetalTitlePane.maximizeMnemonic", -1);
      /*      */
      /*  468 */ if (i != -1) {
        /*  469 */ localJMenuItem.setMnemonic(i);
        /*      */ }
      /*      */ }
    /*      */
    /*  473 */ paramJMenu.add(new JSeparator());
    /*      */
    /*  475 */ localJMenuItem = paramJMenu.add(this.closeAction);
    /*  476 */ i = MetalUtils.getInt("MetalTitlePane.closeMnemonic", -1);
    /*  477 */ if (i != -1) /*  478 */ localJMenuItem.setMnemonic(i);
    /*      */ }
  /*      */
  /*      */ private JButton createTitleButton() /*      */ {
    /*  487 */ JButton localJButton = new JButton();
    /*      */
    /*  489 */ localJButton.setFocusPainted(false);
    /*  490 */ localJButton.setFocusable(false);
    /*  491 */ localJButton.setOpaque(true);
    /*  492 */ return localJButton;
    /*      */ }
  /*      */
  /*      */ private void createButtons() /*      */ {
    /*  499 */ this.closeButton = createTitleButton();
    /*  500 */ this.closeButton.setAction(this.closeAction);
    /*  501 */ this.closeButton.setText(null);
    /*  502 */ this.closeButton.putClientProperty("paintActive", Boolean.TRUE);
    /*  503 */ this.closeButton.setBorder(handyEmptyBorder);
    /*  504 */ this.closeButton.putClientProperty("AccessibleName", "Close");
    /*      */
    /*  506 */ this.closeButton.setIcon(UIManager.getIcon("InternalFrame.closeIcon"));
    /*      */
    /*  508 */ if (getWindowDecorationStyle() == 1) {
      /*  509 */ this.maximizeIcon = UIManager.getIcon("InternalFrame.maximizeIcon");
      /*  510 */ this.minimizeIcon = UIManager.getIcon("InternalFrame.minimizeIcon");
      /*      */
      /*  512 */ this.iconifyButton = createTitleButton();
      /*  513 */ this.iconifyButton.setAction(this.iconifyAction);
      /*  514 */ this.iconifyButton.setText(null);
      /*  515 */ this.iconifyButton.putClientProperty("paintActive", Boolean.TRUE);
      /*  516 */ this.iconifyButton.setBorder(handyEmptyBorder);
      /*  517 */ this.iconifyButton.putClientProperty("AccessibleName", "Iconify");
      /*      */
      /*  519 */ this.iconifyButton.setIcon(UIManager.getIcon("InternalFrame.iconifyIcon"));
      /*      */
      /*  521 */ this.toggleButton = createTitleButton();
      /*  522 */ this.toggleButton.setAction(this.restoreAction);
      /*  523 */ this.toggleButton.putClientProperty("paintActive", Boolean.TRUE);
      /*  524 */ this.toggleButton.setBorder(handyEmptyBorder);
      /*  525 */ this.toggleButton.putClientProperty("AccessibleName", "Maximize");
      /*      */
      /*  527 */ this.toggleButton.setIcon(this.maximizeIcon);
      /*      */ }
    /*      */ }
  /*      */
  /*      */ private LayoutManager createLayout() /*      */ {
    /*  536 */ return new TitlePaneLayout(null);
    /*      */ }
  /*      */
  /*      */ private void setActive(boolean paramBoolean) /*      */ {
    /*  543 */ Boolean localBoolean = paramBoolean ? Boolean.TRUE : Boolean.FALSE;
    /*      */
    /*  545 */ this.closeButton.putClientProperty("paintActive", localBoolean);
    /*  546 */ if (getWindowDecorationStyle() == 1) {
      /*  547 */ this.iconifyButton.putClientProperty("paintActive", localBoolean);
      /*  548 */ this.toggleButton.putClientProperty("paintActive", localBoolean);
      /*      */ }
    /*      */
    /*  552 */ getRootPane().repaint();
    /*      */ }
  /*      */
  /*      */ private void setState(int paramInt) /*      */ {
    /*  559 */ setState(paramInt, false);
    /*      */ }
  /*      */
  /*      */ private void setState(int paramInt, boolean paramBoolean) /*      */ {
    /*  567 */ Window localWindow = getWindow();
    /*      */
    /*  569 */ if ((localWindow != null) && (getWindowDecorationStyle() == 1)) {
      /*  570 */ if ((this.state == paramInt) && (!paramBoolean)) {
        /*  571 */ return;
        /*      */ }
      /*  573 */ Frame localFrame = getFrame();
      /*      */
      /*  575 */ if (localFrame != null) {
        /*  576 */ JRootPane localJRootPane = getRootPane();
        /*      */
        /*  578 */ if (((paramInt & 0x6) != 0)
            && ((localJRootPane.getBorder() == null)
                || ((localJRootPane.getBorder() instanceof UIResource)))
            && (localFrame.isShowing()))
        /*      */ {
          /*  582 */ localJRootPane.setBorder(null);
          /*      */ }
        /*  584 */ else if ((paramInt & 0x6) == 0)
        /*      */ {
          /*  587 */ this.rootPaneUI.installBorder(localJRootPane);
          /*      */ }
        /*  589 */ if (localFrame.isResizable()) {
          /*  590 */ if ((paramInt & 0x6) != 0) {
            /*  591 */ updateToggleButton(this.restoreAction, this.minimizeIcon);
            /*  592 */ this.maximizeAction.setEnabled(false);
            /*  593 */ this.restoreAction.setEnabled(true);
            /*      */ }
          /*      */ else {
            /*  596 */ updateToggleButton(this.maximizeAction, this.maximizeIcon);
            /*  597 */ this.maximizeAction.setEnabled(true);
            /*  598 */ this.restoreAction.setEnabled(false);
            /*      */ }
          /*  600 */ if ((this.toggleButton.getParent() == null)
              || (this.iconifyButton.getParent() == null))
          /*      */ {
            /*  602 */ add(this.toggleButton);
            /*  603 */ add(this.iconifyButton);
            /*  604 */ revalidate();
            /*  605 */ repaint();
            /*      */ }
          /*  607 */ this.toggleButton.setText(null);
          /*      */ }
        /*      */ else {
          /*  610 */ this.maximizeAction.setEnabled(false);
          /*  611 */ this.restoreAction.setEnabled(false);
          /*  612 */ if (this.toggleButton.getParent() != null) {
            /*  613 */ remove(this.toggleButton);
            /*  614 */ revalidate();
            /*  615 */ repaint();
            /*      */ }
          /*      */ }
        /*      */ }
      /*      */ else
      /*      */ {
        /*  621 */ this.maximizeAction.setEnabled(false);
        /*  622 */ this.restoreAction.setEnabled(false);
        /*  623 */ this.iconifyAction.setEnabled(false);
        /*  624 */ remove(this.toggleButton);
        /*  625 */ remove(this.iconifyButton);
        /*  626 */ revalidate();
        /*  627 */ repaint();
        /*      */ }
      /*  629 */ this.closeAction.setEnabled(true);
      /*  630 */ this.state = paramInt;
      /*      */ }
    /*      */ }
  /*      */
  /*      */ private void updateToggleButton(Action paramAction, Icon paramIcon) /*      */ {
    /*  639 */ this.toggleButton.setAction(paramAction);
    /*  640 */ this.toggleButton.setIcon(paramIcon);
    /*  641 */ this.toggleButton.setText(null);
    /*      */ }
  /*      */
  /*      */ private Frame getFrame() /*      */ {
    /*  649 */ Window localWindow = getWindow();
    /*      */
    /*  651 */ if ((localWindow instanceof Frame)) {
      /*  652 */ return (Frame) localWindow;
      /*      */ }
    /*  654 */ return null;
    /*      */ }
  /*      */
  /*      */ private Window getWindow() /*      */ {
    /*  663 */ return this.window;
    /*      */ }
  /*      */
  /*      */ private String getTitle() /*      */ {
    /*  670 */ Window localWindow = getWindow();
    /*      */
    /*  672 */ if ((localWindow instanceof Frame)) {
      /*  673 */ return ((Frame) localWindow).getTitle();
      /*      */ }
    /*  675 */ if ((localWindow instanceof Dialog)) {
      /*  676 */ return ((Dialog) localWindow).getTitle();
      /*      */ }
    /*  678 */ return null;
    /*      */ }
  /*      */
  /*      */ public void paintComponent(Graphics paramGraphics) /*      */ {
    /*  687 */ if (getFrame() != null) {
      /*  688 */ setState(getFrame().getExtendedState());
      /*      */ }
    /*  690 */ JRootPane localJRootPane = getRootPane();
    /*  691 */ Window localWindow = getWindow();
    /*  692 */ boolean bool1 =
        localWindow == null
            ? localJRootPane.getComponentOrientation().isLeftToRight()
            : localWindow.getComponentOrientation().isLeftToRight();
    /*      */
    /*  695 */ boolean bool2 = localWindow == null ? true : localWindow.isActive();
    /*  696 */ int i = getWidth();
    /*  697 */ int j = getHeight();
    /*      */ Color localColor1;
    /*      */ Color localColor2;
    /*      */ Color localColor3;
    /*      */ MetalBumps localMetalBumps;
    /*  705 */ if (bool2) {
      /*  706 */ localColor1 = this.activeBackground;
      /*  707 */ localColor2 = this.activeForeground;
      /*  708 */ localColor3 = this.activeShadow;
      /*  709 */ localMetalBumps = this.activeBumps;
      /*      */ } else {
      /*  711 */ localColor1 = this.inactiveBackground;
      /*  712 */ localColor2 = this.inactiveForeground;
      /*  713 */ localColor3 = this.inactiveShadow;
      /*  714 */ localMetalBumps = this.inactiveBumps;
      /*      */ }
    /*      */
    /*  717 */ paramGraphics.setColor(localColor1);
    /*  718 */ paramGraphics.fillRect(0, 0, i, j);
    /*      */
    /*  720 */ paramGraphics.setColor(localColor3);
    /*  721 */ paramGraphics.drawLine(0, j - 1, i, j - 1);
    /*  722 */ paramGraphics.drawLine(0, 0, 0, 0);
    /*  723 */ paramGraphics.drawLine(i - 1, 0, i - 1, 0);
    /*      */
    /*  725 */ FontMetrics localFontMetrics1 = bool1 ? 5 : i - 5;
    /*      */
    /*  727 */ if (getWindowDecorationStyle() == 1) {
      /*  728 */ localFontMetrics1 += (bool1 ? 21 : -21);
      /*      */ }
    /*      */
    /*  731 */ String str = getTitle();
    /*      */ FontMetrics localFontMetrics2;
    /*      */ int m;
    /*  732 */ if (str != null) {
      /*  733 */ localFontMetrics2 = SwingUtilities2.getFontMetrics(localJRootPane, paramGraphics);
      /*      */
      /*  735 */ paramGraphics.setColor(localColor2);
      /*      */
      /*  737 */ m = (j - localFontMetrics2.getHeight()) / 2 + localFontMetrics2.getAscent();
      /*      */
      /*  739 */ Rectangle localRectangle = new Rectangle(0, 0, 0, 0);
      /*  740 */ if ((this.iconifyButton != null) && (this.iconifyButton.getParent() != null)) {
        /*  741 */ localRectangle = this.iconifyButton.getBounds();
        /*      */ }
      /*      */
      /*  745 */ if (bool1) {
        /*  746 */ if (localRectangle.x == 0) {
          /*  747 */ localRectangle.x =
              (localWindow.getWidth() - localWindow.getInsets().right - 2);
          /*      */ }
        /*  749 */ i1 = localRectangle.x - localFontMetrics1 - 4;
        /*  750 */ str =
            SwingUtilities2.clipStringIfNecessary(localJRootPane, localFontMetrics2, str, i1);
        /*      */ }
      /*      */ else {
        /*  753 */ i1 = localFontMetrics1 - localRectangle.x - localRectangle.width - 4;
        /*  754 */ str =
            SwingUtilities2.clipStringIfNecessary(localJRootPane, localFontMetrics2, str, i1);
        /*      */
        /*  756 */ localFontMetrics1 -=
            SwingUtilities2.stringWidth(localJRootPane, localFontMetrics2, str);
        /*      */ }
      /*      */
      /*  759 */ int i2 = SwingUtilities2.stringWidth(localJRootPane, localFontMetrics2, str);
      /*      */
      /*  761 */ SwingUtilities2.drawString(
          localJRootPane, paramGraphics, str, localFontMetrics1, m);
      /*      */
      /*  763 */ localFontMetrics1 += (bool1 ? i2 + 5 : -5);
      /*      */ }
    /*      */ int k;
    /*  768 */ if (bool1) {
      /*  769 */ m = i - this.buttonsWidth - localFontMetrics1 - 5;
      /*  770 */ localFontMetrics2 = localFontMetrics1;
      /*      */ } else {
      /*  772 */ m = localFontMetrics1 - this.buttonsWidth - 5;
      /*  773 */ k = this.buttonsWidth + 5;
      /*      */ }
    /*  775 */ int n = 3;
    /*  776 */ int i1 = getHeight() - 2 * n;
    /*  777 */ localMetalBumps.setBumpArea(m, i1);
    /*  778 */ localMetalBumps.paintIcon(this, paramGraphics, k, n);
    /*      */ }
  /*      */
  /*      */ private void updateSystemIcon() /*      */ {
    /* 1006 */ Window localWindow = getWindow();
    /* 1007 */ if (localWindow == null) {
      /* 1008 */ this.systemIcon = null;
      /* 1009 */ return;
      /*      */ }
    /* 1011 */ List localList = localWindow.getIconImages();
    /* 1012 */ assert (localList != null);
    /*      */
    /* 1014 */ if (localList.size() == 0) {
      /* 1015 */ this.systemIcon = null;
      /*      */ }
    /* 1017 */ else if (localList.size() == 1) {
      /* 1018 */ this.systemIcon = ((Image) localList.get(0));
      /*      */ }
    /*      */ else /* 1021 */ this.systemIcon = SunToolkit.getScaledIconImage(localList, 16, 16);
    /*      */ }
  /*      */
  /*      */ private class CloseAction extends AbstractAction
  /*      */ {
    /*      */ public CloseAction() /*      */ {
      /*  786 */ super();
      /*      */ }
    /*      */
    /*      */ public void actionPerformed(ActionEvent paramActionEvent) /*      */ {
      /*  791 */ MetalTitlePane.this.close();
      /*      */ }
    /*      */ }
  /*      */
  /*      */ private class IconifyAction extends AbstractAction
  /*      */ {
    /*      */ public IconifyAction() /*      */ {
      /*  801 */ super();
      /*      */ }
    /*      */
    /*      */ public void actionPerformed(ActionEvent paramActionEvent) /*      */ {
      /*  806 */ MetalTitlePane.this.iconify();
      /*      */ }
    /*      */ }
  /*      */
  /*      */ private class MaximizeAction extends AbstractAction
  /*      */ {
    /*      */ public MaximizeAction() /*      */ {
      /*  831 */ super();
      /*      */ }
    /*      */
    /*      */ public void actionPerformed(ActionEvent paramActionEvent) /*      */ {
      /*  836 */ MetalTitlePane.this.maximize();
      /*      */ }
    /*      */ }
  /*      */
  /*      */ private class PropertyChangeHandler /*      */ implements PropertyChangeListener
  /*      */ {
    /*      */ private PropertyChangeHandler() /*      */ {
      /*      */ }
    /*      */
    /*      */ public void propertyChange(PropertyChangeEvent paramPropertyChangeEvent) /*      */ {
      /*  974 */ String str = paramPropertyChangeEvent.getPropertyName();
      /*      */
      /*  977 */ if (("resizable".equals(str)) || ("state".equals(str))) {
        /*  978 */ Frame localFrame = MetalTitlePane.this.getFrame();
        /*      */
        /*  980 */ if (localFrame != null) {
          /*  981 */ MetalTitlePane.this.setState(localFrame.getExtendedState(), true);
          /*      */ }
        /*  983 */ if ("resizable".equals(str)) {
          /*  984 */ MetalTitlePane.this.getRootPane().repaint();
          /*      */ }
        /*      */ }
      /*  987 */ else if ("title".equals(str)) {
        /*  988 */ MetalTitlePane.this.repaint();
        /*      */ }
      /*  990 */ else if ("componentOrientation" == str) {
        /*  991 */ MetalTitlePane.this.revalidate();
        /*  992 */ MetalTitlePane.this.repaint();
        /*      */ }
      /*  994 */ else if ("iconImage" == str) {
        /*  995 */ MetalTitlePane.this.updateSystemIcon();
        /*  996 */ MetalTitlePane.this.revalidate();
        /*  997 */ MetalTitlePane.this.repaint();
        /*      */ }
      /*      */ }
    /*      */ }
  /*      */
  /*      */ private class RestoreAction extends AbstractAction
  /*      */ {
    /*      */ public RestoreAction() /*      */ {
      /*  816 */ super();
      /*      */ }
    /*      */
    /*      */ public void actionPerformed(ActionEvent paramActionEvent) /*      */ {
      /*  821 */ MetalTitlePane.this.restore();
      /*      */ }
    /*      */ }
  /*      */
  /*      */ private class SystemMenuBar extends JMenuBar
  /*      */ {
    /*      */ private SystemMenuBar() /*      */ {
      /*      */ }
    /*      */
    /*      */ public void paint(Graphics paramGraphics) /*      */ {
      /*  848 */ if (isOpaque()) {
        /*  849 */ paramGraphics.setColor(getBackground());
        /*  850 */ paramGraphics.fillRect(0, 0, getWidth(), getHeight());
        /*      */ }
      /*      */
      /*  853 */ if (MetalTitlePane.this.systemIcon != null) {
        /*  854 */ paramGraphics.drawImage(MetalTitlePane.this.systemIcon, 0, 0, 16, 16, null);
        /*      */ } else {
        /*  856 */ Icon localIcon = UIManager.getIcon("InternalFrame.icon");
        /*      */
        /*  858 */ if (localIcon != null) /*  859 */ localIcon.paintIcon(this, paramGraphics, 0, 0);
        /*      */ }
      /*      */ }
    /*      */
    /*      */ public Dimension getMinimumSize() {
      /*  864 */ return getPreferredSize();
      /*      */ }
    /*      */ public Dimension getPreferredSize() {
      /*  867 */ Dimension localDimension = super.getPreferredSize();
      /*      */
      /*  869 */ return new Dimension(
          Math.max(16, localDimension.width), Math.max(localDimension.height, 16));
      /*      */ }
    /*      */ }
  /*      */ private class TitlePaneLayout implements LayoutManager {
    /*      */ private TitlePaneLayout() {
      /*      */ }
    /*      */ public void addLayoutComponent(String paramString, Component paramComponent) {
      /*      */ }
    /*      */ public void removeLayoutComponent(Component paramComponent) {}
    /*      */
    /*  878 */ public Dimension preferredLayoutSize(Container paramContainer) {
      int i = computeHeight();
      /*  879 */ return new Dimension(i, i);
    }
    /*      */
    /*      */ public Dimension minimumLayoutSize(Container paramContainer) /*      */ {
      /*  883 */ return preferredLayoutSize(paramContainer);
      /*      */ }
    /*      */
    /*      */ private int computeHeight() {
      /*  887 */ FontMetrics localFontMetrics =
          MetalTitlePane.this.rootPane.getFontMetrics(MetalTitlePane.this.getFont());
      /*  888 */ int i = localFontMetrics.getHeight();
      /*  889 */ i += 7;
      /*  890 */ int j = 0;
      /*  891 */ if (MetalTitlePane.this.getWindowDecorationStyle() == 1) {
        /*  892 */ j = 16;
        /*      */ }
      /*      */
      /*  895 */ int k = Math.max(i, j);
      /*  896 */ return k;
      /*      */ }
    /*      */
    /*      */ public void layoutContainer(Container paramContainer) {
      /*  900 */ boolean bool =
          MetalTitlePane.this.window == null
              ? MetalTitlePane.this.getRootPane().getComponentOrientation().isLeftToRight()
              : MetalTitlePane.this.window.getComponentOrientation().isLeftToRight();
      /*      */
      /*  904 */ int i = MetalTitlePane.this.getWidth();
      /*      */
      /*  906 */ int k = 3;
      /*      */ int n;
      /*      */ int i1;
      /*  911 */ if ((MetalTitlePane.this.closeButton != null)
          && (MetalTitlePane.this.closeButton.getIcon() != null)) {
        /*  912 */ n = MetalTitlePane.this.closeButton.getIcon().getIconHeight();
        /*  913 */ i1 = MetalTitlePane.this.closeButton.getIcon().getIconWidth();
        /*      */ }
      /*      */ else {
        /*  916 */ n = 16;
        /*  917 */ i1 = 16;
        /*      */ }
      /*      */
      /*  923 */ int j = bool ? i : 0;
      /*      */
      /*  925 */ int m = 5;
      /*  926 */ j = bool ? m : i - i1 - m;
      /*  927 */ if (MetalTitlePane.this.menuBar != null) {
        /*  928 */ MetalTitlePane.this.menuBar.setBounds(j, k, i1, n);
        /*      */ }
      /*      */
      /*  931 */ j = bool ? i : 0;
      /*  932 */ m = 4;
      /*  933 */ j += (bool ? -m - i1 : m);
      /*  934 */ if (MetalTitlePane.this.closeButton != null) {
        /*  935 */ MetalTitlePane.this.closeButton.setBounds(j, k, i1, n);
        /*      */ }
      /*      */
      /*  938 */ if (!bool) j += i1;
      /*      */
      /*  940 */ if (MetalTitlePane.this.getWindowDecorationStyle() == 1) {
        /*  941 */ if (Toolkit.getDefaultToolkit().isFrameStateSupported(6))
        /*      */ {
          /*  943 */ if (MetalTitlePane.this.toggleButton.getParent() != null) {
            /*  944 */ m = 10;
            /*  945 */ j += (bool ? -m - i1 : m);
            /*  946 */ MetalTitlePane.this.toggleButton.setBounds(j, k, i1, n);
            /*  947 */ if (!bool) {
              /*  948 */ j += i1;
              /*      */ }
            /*      */ }
          /*      */ }
        /*      */
        /*  953 */ if ((MetalTitlePane.this.iconifyButton != null)
            && (MetalTitlePane.this.iconifyButton.getParent() != null)) {
          /*  954 */ m = 2;
          /*  955 */ j += (bool ? -m - i1 : m);
          /*  956 */ MetalTitlePane.this.iconifyButton.setBounds(j, k, i1, n);
          /*  957 */ if (!bool) {
            /*  958 */ j += i1;
            /*      */ }
          /*      */ }
        /*      */ }
      /*  962 */ MetalTitlePane.this.buttonsWidth = (bool ? i - j : j);
      /*      */ }
    /*      */ }
  /*      */
  /*      */ private class WindowHandler extends WindowAdapter
  /*      */ {
    /*      */ private WindowHandler() /*      */ {
      /*      */ }
    /*      */
    /*      */ public void windowActivated(WindowEvent paramWindowEvent) /*      */ {
      /* 1033 */ MetalTitlePane.this.setActive(true);
      /*      */ }
    /*      */
    /*      */ public void windowDeactivated(WindowEvent paramWindowEvent) {
      /* 1037 */ MetalTitlePane.this.setActive(false);
      /*      */ }
    /*      */ }
  /*      */ }