/** 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; }
/** 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; }
/** 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; }
/** 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; }
public boolean isResizable(Component c) { boolean resizable = true; if (c instanceof JDialog) { JDialog dialog = (JDialog) c; resizable = dialog.isResizable(); } else if (c instanceof JInternalFrame) { JInternalFrame frame = (JInternalFrame) c; resizable = frame.isResizable(); } else if (c instanceof JRootPane) { JRootPane jp = (JRootPane) c; if (jp.getParent() instanceof JFrame) { JFrame frame = (JFrame) c.getParent(); resizable = frame.isResizable(); } else if (jp.getParent() instanceof JDialog) { JDialog dialog = (JDialog) c.getParent(); resizable = dialog.isResizable(); } } return resizable; }
public Component add(JInternalFrame frame) { JInternalFrame[] array = getAllFrames(); Point p; int w; int h; Component retval = super.add(frame); checkDesktopSize(); if (array.length > 0) { p = array[0].getLocation(); p.x = p.x + FRAME_OFFSET; p.y = p.y + FRAME_OFFSET; } else { p = new Point(0, 0); } frame.setLocation(p.x, p.y); if (frame.isResizable()) { w = getWidth() - (getWidth() / 3); h = getHeight() - (getHeight() / 3); if (w < frame.getMinimumSize().getWidth()) { w = (int) frame.getMinimumSize().getWidth(); } if (h < frame.getMinimumSize().getHeight()) { h = (int) frame.getMinimumSize().getHeight(); } frame.setSize(w, h); } moveToFront(frame); frame.setVisible(true); try { frame.setSelected(true); } catch (PropertyVetoException e) { frame.toBack(); } return retval; }
/** * 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; }