예제 #1
0
    public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {

      JInternalFrame jif = null;
      if (c instanceof JInternalFrame) {
        jif = (JInternalFrame) c;
      } else if (c instanceof JInternalFrame.JDesktopIcon) {
        jif = ((JInternalFrame.JDesktopIcon) c).getInternalFrame();
      } else {
        return;
      }

      if (jif.isSelected()) {
        // Set the line color so the line border gets the correct
        // color.
        lineColor = activeColor;
        super.paintBorder(c, g, x, y, width, height);
      } else {
        lineColor = inactiveColor;
        super.paintBorder(c, g, x, y, width, height);
      }
    }
예제 #2
0
    /** Draws the InternalFrameBorder's top border. */
    protected boolean drawTopBorder(Component c, Graphics g, int x, int y, int width, int height) {
      if (super.drawTopBorder(c, g, x, y, width, height) && frame.isResizable()) {
        g.setColor(getFrameShadow());
        g.drawLine(CORNER_SIZE - 1, y + 1, CORNER_SIZE - 1, y + 4);
        g.drawLine(width - CORNER_SIZE - 1, y + 1, width - CORNER_SIZE - 1, y + 4);

        g.setColor(getFrameHighlight());
        g.drawLine(CORNER_SIZE, y, CORNER_SIZE, y + 4);
        g.drawLine(width - CORNER_SIZE, y, width - CORNER_SIZE, y + 4);
        return true;
      }
      return false;
    }
예제 #3
0
 /** Draws the InternalFrameBorder's left border. */
 protected boolean drawLeftBorder(Component c, Graphics g, int x, int y, int width, int height) {
   if (super.drawLeftBorder(c, g, x, y, width, height) && frame.isResizable()) {
     g.setColor(getFrameHighlight());
     int topY = y + CORNER_SIZE;
     g.drawLine(x, topY, x + 4, topY);
     int bottomY = height - CORNER_SIZE;
     g.drawLine(x + 1, bottomY, x + 5, bottomY);
     g.setColor(getFrameShadow());
     g.drawLine(x + 1, topY - 1, x + 5, topY - 1);
     g.drawLine(x + 1, bottomY - 1, x + 5, bottomY - 1);
     return true;
   }
   return false;
 }
예제 #4
0
    /** Draws the InternalFrameBorder's bottom border. */
    protected boolean drawBottomBorder(
        Component c, Graphics g, int x, int y, int width, int height) {
      if (super.drawBottomBorder(c, g, x, y, width, height) && frame.isResizable()) {
        int startY = height - getBorderInsets(c).bottom;

        g.setColor(getFrameShadow());
        g.drawLine(CORNER_SIZE - 1, startY + 1, CORNER_SIZE - 1, height - 1);
        g.drawLine(width - CORNER_SIZE, startY + 1, width - CORNER_SIZE, height - 1);

        g.setColor(getFrameHighlight());
        g.drawLine(CORNER_SIZE, startY, CORNER_SIZE, height - 2);
        g.drawLine(width - CORNER_SIZE + 1, startY, width - CORNER_SIZE + 1, height - 2);
        return true;
      }
      return false;
    }
예제 #5
0
 /** Draws the InternalFrameBorder's right border. */
 protected boolean drawRightBorder(
     Component c, Graphics g, int x, int y, int width, int height) {
   if (super.drawRightBorder(c, g, x, y, width, height) && frame.isResizable()) {
     int startX = width - getBorderInsets(c).right;
     g.setColor(getFrameHighlight());
     int topY = y + CORNER_SIZE;
     g.drawLine(startX, topY, width - 2, topY);
     int bottomY = height - CORNER_SIZE;
     g.drawLine(startX + 1, bottomY, startX + 3, bottomY);
     g.setColor(getFrameShadow());
     g.drawLine(startX + 1, topY - 1, width - 2, topY - 1);
     g.drawLine(startX + 1, bottomY - 1, startX + 3, bottomY - 1);
     return true;
   }
   return false;
 }
예제 #6
0
    public void paintIcon(Component c, Graphics g, int x0, int y0) {
      int width = getIconWidth();
      int height = getIconHeight();

      XPStyle xp = XPStyle.getXP();
      if (xp != null) {
        Skin skin = xp.getSkin(c, part);
        AbstractButton b = (AbstractButton) c;
        ButtonModel model = b.getModel();

        // Find out if frame is inactive
        JInternalFrame jif =
            (JInternalFrame) SwingUtilities.getAncestorOfClass(JInternalFrame.class, b);
        boolean jifSelected = (jif != null && jif.isSelected());

        State state;
        if (jifSelected) {
          if (!model.isEnabled()) {
            state = State.DISABLED;
          } else if (model.isArmed() && model.isPressed()) {
            state = State.PUSHED;
          } else if (model.isRollover()) {
            state = State.HOT;
          } else {
            state = State.NORMAL;
          }
        } else {
          if (!model.isEnabled()) {
            state = State.INACTIVEDISABLED;
          } else if (model.isArmed() && model.isPressed()) {
            state = State.INACTIVEPUSHED;
          } else if (model.isRollover()) {
            state = State.INACTIVEHOT;
          } else {
            state = State.INACTIVENORMAL;
          }
        }
        skin.paintSkin(g, 0, 0, width, height, state);
      } else {
        g.setColor(Color.black);
        int x = width / 12 + 2;
        int y = height / 5;
        int h = height - y * 2 - 1;
        int w = width * 3 / 4 - 3;
        int thickness2 = Math.max(height / 8, 2);
        int thickness = Math.max(width / 15, 1);
        if (part == Part.WP_CLOSEBUTTON) {
          int lineWidth;
          if (width > 47) lineWidth = 6;
          else if (width > 37) lineWidth = 5;
          else if (width > 26) lineWidth = 4;
          else if (width > 16) lineWidth = 3;
          else if (width > 12) lineWidth = 2;
          else lineWidth = 1;
          y = height / 12 + 2;
          if (lineWidth == 1) {
            if (w % 2 == 1) {
              x++;
              w++;
            }
            g.drawLine(x, y, x + w - 2, y + w - 2);
            g.drawLine(x + w - 2, y, x, y + w - 2);
          } else if (lineWidth == 2) {
            if (w > 6) {
              x++;
              w--;
            }
            g.drawLine(x, y, x + w - 2, y + w - 2);
            g.drawLine(x + w - 2, y, x, y + w - 2);
            g.drawLine(x + 1, y, x + w - 1, y + w - 2);
            g.drawLine(x + w - 1, y, x + 1, y + w - 2);
          } else {
            x += 2;
            y++;
            w -= 2;
            g.drawLine(x, y, x + w - 1, y + w - 1);
            g.drawLine(x + w - 1, y, x, y + w - 1);
            g.drawLine(x + 1, y, x + w - 1, y + w - 2);
            g.drawLine(x + w - 2, y, x, y + w - 2);
            g.drawLine(x, y + 1, x + w - 2, y + w - 1);
            g.drawLine(x + w - 1, y + 1, x + 1, y + w - 1);
            for (int i = 4; i <= lineWidth; i++) {
              g.drawLine(x + i - 2, y, x + w - 1, y + w - i + 1);
              g.drawLine(x, y + i - 2, x + w - i + 1, y + w - 1);
              g.drawLine(x + w - i + 1, y, x, y + w - i + 1);
              g.drawLine(x + w - 1, y + i - 2, x + i - 2, y + w - 1);
            }
          }
        } else if (part == Part.WP_MINBUTTON) {
          g.fillRect(x, y + h - thickness2, w - w / 3, thickness2);
        } else if (part == Part.WP_MAXBUTTON) {
          g.fillRect(x, y, w, thickness2);
          g.fillRect(x, y, thickness, h);
          g.fillRect(x + w - thickness, y, thickness, h);
          g.fillRect(x, y + h - thickness, w, thickness);
        } else if (part == Part.WP_RESTOREBUTTON) {
          g.fillRect(x + w / 3, y, w - w / 3, thickness2);
          g.fillRect(x + w / 3, y, thickness, h / 3);
          g.fillRect(x + w - thickness, y, thickness, h - h / 3);
          g.fillRect(x + w - w / 3, y + h - h / 3 - thickness, w / 3, thickness);

          g.fillRect(x, y + h / 3, w - w / 3, thickness2);
          g.fillRect(x, y + h / 3, thickness, h - h / 3);
          g.fillRect(x + w - w / 3 - thickness, y + h / 3, thickness, h - h / 3);
          g.fillRect(x, y + h - thickness, w - w / 3, thickness);
        }
      }
    }
예제 #7
0
 // Returns true if the associated internal frame has focus.
 protected boolean isActiveFrame() {
   return frame.isSelected();
 }
예제 #8
0
 /**
  * Returns the width of the InternalFrameBorder's resize controls, appearing along the
  * InternalFrameBorder's bottom border. Clicking and dragging within these controls lets the
  * user change both the InternalFrame's width and height, while dragging between the controls
  * constrains resizing to just the vertical dimension. Override this method if you implement
  * your own bottom border painting and use a resize control with a different size.
  */
 public int resizePartWidth() {
   if (!frame.isResizable()) {
     return 0;
   }
   return FrameBorder.BORDER_SIZE;
 }