javax.swing.JComponent.getInsets()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(6.4k)|赞(0)|评价(0)|浏览(153)

本文整理了Java中javax.swing.JComponent.getInsets()方法的一些代码示例,展示了JComponent.getInsets()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JComponent.getInsets()方法的具体详情如下:
包路径:javax.swing.JComponent
类名称:JComponent
方法名:getInsets

JComponent.getInsets介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

Insets insets = getInsets();
g.clipRect(insets.left, insets.top, getWidth(), getHeight() - insets.top - insets.bottom);
super.paintChildren(g);
  Insets insets = getInsets();
  int widthMargin = insets.left + insets.right;
  int heightMargin = insets.top + insets.bottom;

代码示例来源:origin: ron190/jsql-injection

Insets parentInsets = this.parent.getInsets();

代码示例来源:origin: stackoverflow.com

RenderingHints.VALUE_ANTIALIAS_ON);
g.setColor(getDisabledTextColor());
g.drawString(placeholder, getInsets().left, pG.getFontMetrics()
  .getMaxAscent() + getInsets().top);

代码示例来源:origin: stackoverflow.com

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;

代码示例来源:origin: eu.mihosoft.vrl/vrl

/**
   * Returns the start offset (including char ascend).
   *
   * @return the start offset
   */
  private int getStartOffset() {
    return textComponent.getInsets().top + charAscent;
  }
}

代码示例来源:origin: net.java.dev.swing-layout/swing-layout

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;
}

代码示例来源:origin: org.geotools/gt2-widgets-swing

/**
 * 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));
}

代码示例来源:origin: net.java.dev.swing-layout/swing-layout

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;
}

代码示例来源:origin: org.cytoscape/work-swing-impl

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);
}

代码示例来源:origin: org.netbeans.api/org-netbeans-swing-plaf

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));
}

代码示例来源:origin: com.jidesoft/jide-oss

/**
 * 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();
}

代码示例来源:origin: org.gephi/desktop-io-export

@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;
}

代码示例来源:origin: com.synaptix/SynaptixSwing

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);
}

代码示例来源:origin: org.gosu-lang.gosu/gosu-lab

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 );
}

代码示例来源:origin: org.gosu-lang.gosu/gosu-lab

public synchronized Insets getInsets()
{
 if( _border == null )
 {
  return super.getInsets();
 }
 return _border.getBorderInsets( this );
}

代码示例来源:origin: com.numdata/numdata-swing

@Override
public Insets getInsets( final Insets insets )
{
  final Insets result = super.getInsets( insets );
  if ( _image == null )
  {
    result.set( 0, 0, 0, 0 );
  }
  return result;
}

代码示例来源:origin: org.gosu-lang.gosu/gosu-editor

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 );
}

代码示例来源:origin: org.gephi/desktop-io-export

@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;
}

代码示例来源:origin: eu.mihosoft.vrl/vrl

private int getTopLevelYInset() {
  int yOffset = 0;
  Component topParent = getTopLevelParent(getMainCanvas());
  if (topParent instanceof JComponent) {
    JComponent c = (JComponent) topParent;
    yOffset = c.getInsets().top;
  }
  return yOffset;
}

代码示例来源:origin: khuxtable/seaglass

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);
    }
  }
}

相关文章

JComponent类方法