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); }
static Border getToolBarNonrolloverBorder() { if (MetalLookAndFeel.usingOcean()) { new CompoundBorder(new MetalBorders.ButtonBorder(), new MetalBorders.RolloverMarginBorder()); } return new CompoundBorder( new MetalBorders.ButtonBorder(), new MetalBorders.RolloverMarginBorder()); }
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; }
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) { if (MetalLookAndFeel.usingOcean()) { paintOceanBorder(c, g, x, y, w, h); return; } AbstractButton button = (AbstractButton) c; ButtonModel model = button.getModel(); if (model.isEnabled()) { boolean isPressed = model.isPressed() && model.isArmed(); boolean isDefault = (button instanceof JButton && ((JButton) button).isDefaultButton()); if (isPressed && isDefault) { MetalUtils.drawDefaultButtonPressedBorder(g, x, y, w, h); } else if (isPressed) { MetalUtils.drawPressed3DBorder(g, x, y, w, h); } else if (isDefault) { MetalUtils.drawDefaultButtonBorder(g, x, y, w, h, false); } else { MetalUtils.drawButtonBorder(g, x, y, w, h, false); } } else { // disabled state MetalUtils.drawDisabledBorder(g, x, y, w - 1, h - 1); } }
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); } }
public Insets getBorderInsets(Component c, Insets newInsets) { if (MetalLookAndFeel.usingOcean()) { newInsets.set(0, 0, 2, 0); } else { newInsets.top = 1; newInsets.left = 0; newInsets.bottom = 1; newInsets.right = 0; } return newInsets; }
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) { g.translate(x, y); if (MetalLookAndFeel.usingOcean()) { // Only paint a border if we're not next to a horizontal // toolbar if (!MetalToolBarUI.doesMenuBarBorderToolBar((JMenuBar) c)) { g.setColor(MetalLookAndFeel.getControl()); g.drawLine(0, h - 2, w, h - 2); g.setColor(UIManager.getColor("MenuBar.borderColor")); g.drawLine(0, h - 1, w, h - 1); } } else { g.setColor(MetalLookAndFeel.getControlShadow()); g.drawLine(0, h - 1, w, h - 1); } g.translate(-x, -y); }
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); } }
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); }
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) { AbstractButton button = (AbstractButton) c; ButtonModel model = button.getModel(); if (MetalLookAndFeel.usingOcean()) { if (model.isArmed() || !button.isEnabled()) { super.paintBorder(c, g, x, y, w, h); } else { g.setColor(MetalLookAndFeel.getControlDarkShadow()); g.drawRect(0, 0, w - 1, h - 1); } return; } if (!c.isEnabled()) { MetalUtils.drawDisabledBorder(g, x, y, w - 1, h - 1); } else { if (model.isPressed() && model.isArmed()) { MetalUtils.drawPressed3DBorder(g, x, y, w, h); } else if (model.isSelected()) { MetalUtils.drawDark3DBorder(g, x, y, w, h); } else { MetalUtils.drawFlush3DBorder(g, x, y, w, h); } } }
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); }