private boolean checkRightMargin(int w) { // Make sure rightMargin has at least 2 pixels over if (w + 2 > rightMargin) { rightMargin = (w + 2); // Repaint from top (above any cell renderers) SwingUtilities.getWindowAncestor(this).repaint(); return true; } return false; }
private boolean checkLeftMargin(int x) { // Make sure leftMargin has at least 2 pixels over if (x < 2) { leftMargin += (2 - x); // Repaint from top (above any cell renderers) SwingUtilities.getWindowAncestor(this).repaint(); return true; } return false; }
/** * Installs the necessary Listeners on the parent <code>Window</code>, if there is one. * * <p>This takes the parent so that cleanup can be done from <code>removeNotify</code>, at which * point the parent hasn't been reset yet. * * @param parent The parent of the JRootPane */ private void installWindowListeners(JRootPane root, Component parent) { if (parent instanceof Window) { window = (Window) parent; } else { window = SwingUtilities.getWindowAncestor(parent); } if (window != null) { if (mouseInputListener == null) { mouseInputListener = createWindowMouseInputListener(root); } window.addMouseListener(mouseInputListener); window.addMouseMotionListener(mouseInputListener); } }
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) { Color background; Color highlight; Color shadow; Window window = SwingUtilities.getWindowAncestor(c); if (window != null && window.isActive()) { background = MetalLookAndFeel.getPrimaryControlDarkShadow(); highlight = MetalLookAndFeel.getPrimaryControlShadow(); shadow = MetalLookAndFeel.getPrimaryControlInfo(); } else { background = MetalLookAndFeel.getControlDarkShadow(); highlight = MetalLookAndFeel.getControlShadow(); shadow = MetalLookAndFeel.getControlInfo(); } g.setColor(background); // Draw outermost lines g.drawLine(x + 1, y + 0, x + w - 2, y + 0); g.drawLine(x + 0, y + 1, x + 0, y + h - 2); g.drawLine(x + w - 1, y + 1, x + w - 1, y + h - 2); g.drawLine(x + 1, y + h - 1, x + w - 2, y + h - 1); // Draw the bulk of the border for (int i = 1; i < 5; i++) { g.drawRect(x + i, y + i, w - (i * 2) - 1, h - (i * 2) - 1); } if ((window instanceof Frame) && ((Frame) window).isResizable()) { g.setColor(highlight); // Draw the Long highlight lines g.drawLine(corner + 1, 3, w - corner, 3); g.drawLine(3, corner + 1, 3, h - corner); g.drawLine(w - 2, corner + 1, w - 2, h - corner); g.drawLine(corner + 1, h - 2, w - corner, h - 2); g.setColor(shadow); // Draw the Long shadow lines g.drawLine(corner, 2, w - corner - 1, 2); g.drawLine(2, corner, 2, h - corner - 1); g.drawLine(w - 3, corner, w - 3, h - corner - 1); g.drawLine(corner, h - 3, w - corner - 1, h - 3); } }