Insets parentInsets = this.parent.getInsets();
JButton btn = (JButton) e.getComponent(); Dimension size = btn.getSize(); Insets insets = btn.getInsets(); size.width -= insets.left + insets.right; size.height -= insets.top + insets.bottom;
/** * Returns the start offset (including char ascend). * * @return the start offset */ private int getStartOffset() { return textComponent.getInsets().top + charAscent; } }
private void resetRects(JComponent c, int height) { Insets insets = c.getInsets(); viewRect.x = insets.left; viewRect.y = insets.top; viewRect.width = c.getWidth() - (insets.right + viewRect.x); viewRect.height = height - (insets.bottom + viewRect.y); textRect.x = textRect.y = textRect.width = textRect.height = 0; iconRect.x = iconRect.y = iconRect.width = iconRect.height = 0; }
/** * Returns the Insets of this component. This method works like {@code super.getInsets(insets)}, * but accepts a null argument. This method can be redefined if it is necessary to perform zooms * on a part of the graphic rather than the whole thing. */ public Insets getInsets(final Insets insets) { return super.getInsets((insets != null) ? insets : new Insets(0, 0, 0, 0)); }
private static void resetRects(JComponent c, int height) { Insets insets = c.getInsets(); viewRect.x = insets.left; viewRect.y = insets.top; viewRect.width = c.getWidth() - (insets.right + viewRect.x); viewRect.height = height - (insets.bottom + viewRect.y); textRect.x = textRect.y = textRect.width = textRect.height = 0; iconRect.x = iconRect.y = iconRect.width = iconRect.height = 0; }
public void paintComponent(Graphics g) { final Graphics2D g2d = (Graphics2D) g; insets = super.getInsets(insets); g2d.translate(insets.left, insets.top); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.setColor(pressed ? PRESSED_COLOR : COLOR); g2d.fill(opened ? OPENED_TRIANGLE : CLOSED_TRIANGLE); }
public void paint(Graphics g, JComponent c) { GradientPaint gp = new GradientPaint (0f, 0f, UIManager.getColor("controlHighlight"), //NOI18N 0f, c.getHeight(), UIManager.getColor("control")); //NOI18N ((Graphics2D) g).setPaint (gp); Insets ins = c.getInsets(); g.fillRect (ins.left, ins.top, c.getWidth() - (ins.left + ins.top), c.getHeight() - (ins.top + ins.bottom)); }
/** * Returns the insets that should be used to calculate the resize area. Unless you have used setResizeInsets or * overridden this method, it'll return the insets of the component. * * @return the insets that should be used to calculate the resize area. */ public Insets getResizeInsets() { if (_resizeInsets != null) { return _resizeInsets; } return getComponent().getInsets(); }
@Override protected JDialog createDialog(Component parent) throws HeadlessException { dialog = super.createDialog(parent); Component c = dialog.getContentPane().getComponent(0); if (c != null && c instanceof JComponent) { Insets insets = ((JComponent) c).getInsets(); southPanel.setBorder(BorderFactory.createEmptyBorder(insets.top, insets.left, insets.bottom, insets.right)); } dialog.getContentPane().add(southPanel, BorderLayout.SOUTH); return dialog; }
public static Rectangle2D getImageScaleForComponent(Image image, JComponent component, boolean upscale) { Insets insets = component.getInsets(); return getImageScale(image, insets.left, insets.top, component .getWidth() - (insets.right + insets.left), component.getHeight() - (insets.top + insets.bottom), upscale); }
public Dimension getPreferredSize( JComponent c ) { Dimension dim = super.getPreferredSize( c ); Insets insets = c.getInsets(); // Invert the border dim.width -= (insets.left + insets.right); dim.height -= (insets.top + insets.bottom); dim.width += (insets.top + insets.bottom); dim.height += (insets.left + insets.right); return new Dimension( dim.height, dim.width ); }
public synchronized Insets getInsets() { if( _border == null ) { return super.getInsets(); } return _border.getBorderInsets( this ); }
@Override public Insets getInsets( final Insets insets ) { final Insets result = super.getInsets( insets ); if ( _image == null ) { result.set( 0, 0, 0, 0 ); } return result; }
public Dimension getPreferredSize( JComponent c ) { Dimension dim = super.getPreferredSize( c ); Insets insets = c.getInsets(); // Invert the border dim.width -= (insets.left + insets.right); dim.height -= (insets.top + insets.bottom); dim.width += (insets.top + insets.bottom); dim.height += (insets.left + insets.right); return new Dimension( dim.height, dim.width ); }
@Override protected JDialog createDialog(Component parent) throws HeadlessException { dialog = super.createDialog(parent); dialog.setSize(640, 480); dialog.setResizable(true); Component c = dialog.getContentPane().getComponent(0); if (c != null && c instanceof JComponent) { Insets insets = ((JComponent) c).getInsets(); southPanel.setBorder(BorderFactory.createEmptyBorder(insets.top, insets.left, insets.bottom, insets.right)); } dialog.getContentPane().add(southPanel, BorderLayout.SOUTH); return dialog; }
private int getTopLevelYInset() { int yOffset = 0; Component topParent = getTopLevelParent(getMainCanvas()); if (topParent instanceof JComponent) { JComponent c = (JComponent) topParent; yOffset = c.getInsets().top; } return yOffset; }
public void setBoundsForFrame(JComponent f, int newX, int newY, int newWidth, int newHeight) { super.setBoundsForFrame(f, newX, newY, newWidth, newHeight); if (taskBar != null && newY >= taskBar.getY()) { f.setLocation(f.getX(), taskBar.getY() - f.getInsets().top); } } }