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

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

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

JComponent.paintComponent介绍

暂无

代码示例

代码示例来源:origin: chewiebug/GCViewer

protected void paintComponent(Graphics g) {
  super.paintComponent(g);
  Graphics2D g2d = (Graphics2D)g;
  Paint oldPaint = g2d.getPaint();
  Object oldAAHint = g2d.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
  if (modelChart.isAntiAlias()) g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
  g2d.setPaint(getLinePaint());
  paintComponent(g2d);
  g2d.setPaint(oldPaint);
  g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, oldAAHint);
}

代码示例来源:origin: apache/geode

@Override
 protected void paintComponent(Graphics g) {
  super.paintComponent(g);
  Rectangle bounds = g.getClipBounds();
  int index = 0;
  for (String name : shortLineNames.keySet()) {
   int nameWidth = g.getFontMetrics().stringWidth(name);
   int lineX = lineStep * index;
   index++;
   if (bounds.getMaxX() < lineX || bounds.getMinX() > lineX + nameWidth) {
    continue;
   }
   g.setClip(lineX + LINE_LABEL_BOUNDARY, 0, lineStep - +LINE_LABEL_BOUNDARY * 2, getHeight());
   g.drawString(name, lineX + LINE_LABEL_BOUNDARY, AXIS_SIZE / 3);
   g.setClip(null);
  }
 }
}

代码示例来源:origin: magefree/mage

@Override
public void paintComponent(Graphics graphics) {
  if (bigImage != null) {
    graphics.drawImage(bigImage, 0, 0, this);
  }
  super.paintComponent(graphics);
}

代码示例来源:origin: magefree/mage

@Override
  public void paintComponent(Graphics g) {
    super.paintComponent(g);
    g = g.create();
    g.setColor(new Color(100, 100, 200, 128));
    g.fillRect(0, 0, getWidth(), getHeight());
    g.setColor(new Color(0, 0, 255));
    g.drawRect(0, 0, getWidth() - 1, getHeight() - 1);
    g.dispose();
  }
}

代码示例来源:origin: apache/pdfbox

@Override
protected void paintComponent(Graphics g)
  super.paintComponent(g);

代码示例来源:origin: apache/pdfbox

@Override
protected void paintComponent(Graphics g)
  super.paintComponent(g);

代码示例来源:origin: SINTEF-9012/JArduino

public void paintComponent(Graphics g) {
  super.paintComponent(g);
  if (arduinoImage !=null){
    arduinoImage.paintIcon(this,g,0,0);
  }
  else {
    g.drawString("Could not draw image", 0, 0);
  }
}

代码示例来源:origin: de.sciss/scisslib

public void paintComponent( Graphics g )
  {
    super.paintComponent( g );

    final Graphics2D g2 = (Graphics2D) g;

    g2.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON );
    g2.drawLine( 4, 13, 13, 4 );
    g2.drawLine( 8, 13, 13, 8 );
    g2.drawLine( 12, 13, 13, 12 );
  }
}

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

public void paintComponent(Graphics g) {
    super.paintComponent(g);

    Dimension size = getSize();
    g.setColor(color);
    if (orientation == SwingConstants.HORIZONTAL) {
      g.drawLine(0, 0, size.width, 0);
    }
    else if (orientation == SwingConstants.VERTICAL) {
      g.drawLine(0, 0, 0, size.height);
    }
  }
}

代码示例来源:origin: Multibit-Legacy/multibit-hd

public void paintComponent(Graphics g) {
  g.setColor(new Color(0, 0, 0, 50));
  g.fillRect(0, 0, getWidth(), getHeight());
  super.paintComponent(g);
 }
};

代码示例来源:origin: xyz.cofe/docking-frames-core

@Override
  protected void paintComponent( Graphics g ) {
    super.paintComponent( g );
    if( image != null ){
      int x = (getWidth() - image.getWidth()) / 2;
      int y = (getHeight() - image.getHeight()) / 2;
      
      g.drawImage( image, x, y, this );
      
      g.setColor( getForeground() );
      g.drawRect( x-1, y-1, image.getWidth(), image.getHeight() );
    }
  }
}

代码示例来源:origin: org.nuiton.thirdparty/rsyntaxtextarea

/**
 * Overridden to (possibly) draw the caret's position.
 *
 * @param g The graphics context.
 */
protected void paintComponent(Graphics g) {
  super.paintComponent(g);
  if (caretLineY>-1) {
    g.setColor(getCaretMarkerColor());
    g.fillRect(0, caretLineY, getWidth(), 2);
  }
}

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

@Override
protected void paintComponent(Graphics g) {
  super.paintComponent(g);
  draw((Graphics2D)g, getWidth(), getHeight());
}

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

@Override
protected void paintComponent( Graphics g )
{
 super.paintComponent( g );
 g.setColor( getBackground() );
 g.fillRect( 0, 0, getWidth(), getHeight() );
}

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

@Override
protected void paintComponent( Graphics g )
{
 super.paintComponent( g );
 g.setColor( getBackground() );
 g.fillRect( 0, 0, getWidth(), getHeight() );
}

代码示例来源:origin: com.mgmtp.gcviewer/gcviewer

protected void paintComponent(Graphics g) {
  super.paintComponent(g);
  Graphics2D g2d = (Graphics2D)g;
  Paint oldPaint = g2d.getPaint();
  Object oldAAHint = g2d.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
  if (modelChart.isAntiAlias()) g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
  g2d.setPaint(getLinePaint());
  paintComponent(g2d);
  g2d.setPaint(oldPaint);
  g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, oldAAHint);
}

代码示例来源:origin: igvteam/igv

@Override
protected void paintComponent(Graphics g) {
  super.paintComponent(g);
  Rectangle visibleRect = getVisibleRect();
  RenderContext context = new RenderContext(this, (Graphics2D) g, frame, visibleRect);
  drawGenomicAxis(context, visibleRect);
}

代码示例来源:origin: igvteam/igv

@Override
public void paintComponent(Graphics g) {
  super.paintComponent(g);
  Rectangle visibleRect = getVisibleRect();
  RenderContext context = new RenderContext(this, (Graphics2D) g, frame, visibleRect);
  track.render(context, visibleRect);
}

代码示例来源:origin: com.threerings/nenya

@Override
public void paintComponent (Graphics g)
{
  super.paintComponent(g);
  _tiler.paint(g, 0, 0, getWidth(), getHeight());
}

代码示例来源:origin: com.fossgalaxy.games/fireworks

@Override
protected void paintComponent(Graphics g) {
  super.paintComponent(g);
  Graphics2D g2 = (Graphics2D)g;
  int handSize = state.getHandSize();
  int cardsRemaining = Math.max(0, state.getDeck().getCardsLeft() - handSize);
  CardComponent.drawCard(g2, GameView.TANGO_DARK, Integer.toString(cardsRemaining), 0, 0, getWidth(), getHeight(), false);
}

相关文章

JComponent类方法