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

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

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

JComponent.getSize介绍

暂无

代码示例

代码示例来源:origin: JetBrains/ideavim

@Nullable
 private static Rectangle getEditorWindowRectangle(@NotNull EditorWindow window) {
  final EditorWithProviderComposite editor = window.getSelectedEditor();
  if (editor != null) {
   final Point point = editor.getComponent().getLocationOnScreen();
   final Dimension dimension = editor.getComponent().getSize();
   return new Rectangle(point, dimension);
  }
  return null;
 }
}

代码示例来源:origin: tomighty/tomighty

@Override
public void paint(Graphics g, JComponent component) {
  Canvas canvas = new Canvas(component.getSize());
  Theme theme = look.theme();
  theme.paint(canvas);
  canvas.drawBorder(look.colors().shadow());
  g.drawImage(canvas.image(), 0, 0, null);
}

代码示例来源:origin: nz.ac.waikato.cms.weka.thirdparty/bounce

/**
 * Paints button's background.
 *
 * @param g the graphics.
 * @param c the button component.
 */
protected void paintBackground( Graphics g, JComponent c) {
  Dimension size = c.getSize();
  g.fillRect( 0, 0, size.width, size.height);
}

代码示例来源:origin: mikaelhg/openblocks

/**
 * @return the dimension of the sole block widget in this block.
 *            May NOT return null.
 */
public Dimension getBlockWidgetDimension() {
  if (this.blockWidget == null) {
    return new Dimension(0, 0);
  } else {
    return this.blockWidget.getSize();
  }
}

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

public void captureComponent(JComponent component, File imageFile) throws IOException {
  BufferedImage bufImage = new BufferedImage(component.getSize().width, component.getSize().height, BufferedImage.TYPE_INT_RGB);  
  component.paint(bufImage.createGraphics());   
  imageFile.createNewFile();  
  ImageIO.write(bufImage, "jpeg", imageFile);
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib

protected int getHeightDimension() {
  if (editorUI == null)
    return 0;
  JComponent comp = editorUI.getComponent();
  if (comp == null)
    return 0;
  return highestLineNumber * lineHeight + (int)comp.getSize().getHeight();
}

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

public void paint( Graphics g, JComponent c ) {
  Dimension s = c.getSize();
  if (((JSeparator) c).getOrientation() == JSeparator.HORIZONTAL) {
    g.setColor(lineColorHorizontal);
    g.drawLine(1, 5, s.width - 2, 5);
  } else {
    g.setColor(lineColorVertical);
    g.drawLine(0, 1, 0, s.height - 2);
  }
}

代码示例来源:origin: net.java.abeille/abeille

protected int getHeightDimension() {
  JComponent comp = editorUI.getComponent();
  if (comp == null)
    return 0;
  return highestLineNumber * lineHeight + (int) comp.getSize().getHeight();
}

代码示例来源:origin: info.aduna.commons/aduna-commons-swing

public void mouseDragged(MouseEvent e) {
  // determine the preferred width
  int preferredWidth = component.getPreferredSize().width;
  // determine the new preferred height
  int dy = e.getY() - clickedY;
  int preferredHeight = component.getSize().height + dy;
  preferredHeight = Math.max(preferredHeight, 0);
  // adapt the preferred size
  component.setPreferredSize(new Dimension(preferredWidth, preferredHeight));
  component.revalidate();
}

代码示例来源:origin: net.sf.nimrod/nimrod-laf

public void paint( Graphics g, JComponent c) {
 Dimension s = c.getSize();
 g.setColor( NimRODUtils.getSombra());
 g.drawLine( 1, 0, s.width-1, 0);
 g.setColor( NimRODUtils.getBrillo());
 g.drawLine( 1, 1, s.width-1, 1);
}

代码示例来源:origin: nl.cloudfarming.client/cloudfarming-client-geoviewer-jxmap

public static BufferedImage createImage(JComponent component, int imageType) {
  Dimension componentSize = component.getPreferredSize();
  component.setDoubleBuffered(false);
  component.setSize(componentSize);
  component.validate();
  BufferedImage img = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration().createCompatibleImage(component.getSize().width,
      component.getSize().height, imageType);
  Graphics2D grap = img.createGraphics();
  component.print(grap);
  grap.dispose();
  return img;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-lib-profiler-ui

public void setupMorphing() {
  startComponent = layoutComponent((currentComponent == component1) ? component1 : component2);
  endComponent = layoutComponent((currentComponent == component1) ? component2 : component1);
  heightDelta = (float) (endComponent.getSize().height - startComponent.getSize().height) / (float) morphingSteps;
  morphingStep = 0;
  isMorphing = true;
  setCurrentComponent(startComponent);
}

代码示例来源:origin: net.sf.ingenias/editor

/** @param g graphics
 *  @param c component
 *   */
public void paint(final Graphics g, final JComponent c) {
  Dimension size = c.getSize();
  textArea.setBackground(c.getBackground());
  rendererPane.paintComponent(g, textArea, c, 1, 1,
      size.width - 1, size.height - 1, true);
}

代码示例来源:origin: otros-systems/otroslogviewer

public static void centerOnComponet(Window target, JComponent parent) {
 Dimension targetSize = target.getSize();
 Point location = parent.getLocationOnScreen();
 Dimension sourceSize = parent.getSize();
 Point sourceCenter = new Point(location.x + sourceSize.width / 2, location.y + sourceSize.height / 2);
 Point frameLocation = new Point(sourceCenter.x - targetSize.width / 2, sourceCenter.y - targetSize.height / 2);
 target.setLocation(frameLocation);
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-lib-profiler-ui

/**
   * locks the content size - while resizing the content component size and layout remains the same
   */
  public void lockContentResizing(boolean lock) {
    if ((lock) && (transContent != null)) {
      layout.setLockedSize(transContent.getSize());
    } else {
      layout.setLockedSize(null);
    }
  }
}

代码示例来源:origin: info.aduna.commons/aduna-commons-swing

public void mouseReleased(MouseEvent e) {
  Component glassPane = sideBar.getGlassPane();
  glassPane.setVisible(false);
  glassPane.setCursor(null);
  int dy = e.getY() - clickedY;
  Dimension currentSize = component.getSize();
  int height = Math.max(currentSize.height + dy, 0);
  Dimension newSize = new Dimension(currentSize.width, height);
  component.setPreferredSize(newSize);
  component.revalidate();
}

代码示例来源:origin: datacleaner/DataCleaner

public void addCentered(final JComponent comp) {
  final Dimension compSize = comp.getSize();
  final Dimension totalSize = getSize();
  final int x = (totalSize.width - compSize.width) / 2;
  final int y = (totalSize.height - compSize.height) / 2;
  comp.setLocation(x, y);
  add(comp);
}

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

static void placeUnder(JComponent target, JComponent src) {
  int x = src.getLocation().x;
  int y = src.getLocation().y + src.getSize().height+2;
  target.setLocation(x,y);
}

代码示例来源:origin: net.sf.jung/jung-visualization

protected boolean vertexHit(RenderContext<V,E> rc, Shape s) {
  JComponent vv = rc.getScreenDevice();
  Rectangle deviceRectangle = null;
  if(vv != null) {
    Dimension d = vv.getSize();
    deviceRectangle = new Rectangle(
        0,0,
        d.width,d.height);
  }
  return rc.getMultiLayerTransformer().getTransformer(Layer.VIEW).transform(s).intersects(deviceRectangle);
}

代码示例来源:origin: JetBrains/jediterm

private void invalidateIfNeeded() {
  if (getLabelComponent().getRootPane() == null) return;
  Dimension d = getLabelComponent().getSize();
  Dimension pref = getLabelComponent().getPreferredSize();
  if (d != null && d.equals(pref)) {
    return;
  }
  setInactiveStateImage(null);
  getLabelComponent().invalidate();
  myTabs.revalidateAndRepaint(false);
}

相关文章

JComponent类方法