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

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

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

JLabel.paintComponent介绍

暂无

代码示例

代码示例来源:origin: RaiMan/SikuliX2

@Override
 public void paintComponent(Graphics g) {
  super.paintComponent(g);
  Graphics2D g2d = (Graphics2D) g.create();
  if (getActiveSide() == ALL) {
   drawSelection(g2d);
  } else {
   drawCrossHair(g2d);
  }
 }
};

代码示例来源:origin: haraldk/TwelveMonkeys

@Override
protected void paintComponent(Graphics g) {
  Graphics2D gr = (Graphics2D) g;
  gr.setPaint(backgroundPaint);
  gr.fillRect(0, 0, getWidth(), getHeight());
  super.paintComponent(g);
}

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

@Override
public void paintComponent(Graphics g) {
  super.paintComponent(g);
  Graphics2D g2D = (Graphics2D) g;
  // ////////////////////////////////////////////////////////////////
  // antialiasing
  g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
       RenderingHints.VALUE_ANTIALIAS_ON);
  // ////////////////////////////////////////////////////////////////
  
  /**
   * draw text
   */
  if (!invertColors) {
    g2D.setFont(f);
    g2D.setColor(new Color(0, 0, 0));
    g2D.drawString(this.text, 1, 14);
    g2D.setColor(new Color(255, 255, 255, 230));
    g2D.drawString(this.text, 0, 13);
  } else {
    g2D.setFont(f);
    g2D.setColor(new Color(255, 255, 255, 230));
    g2D.drawString(this.text, 1, 14);
    g2D.setColor(new Color(0, 0, 0));
    g2D.drawString(this.text, 0, 13);
  }
  g2D.dispose();
}

代码示例来源:origin: org.netbeans.api/org-openide-dialogs

@Override
  protected void paintComponent(Graphics g) {
    super.paintComponent(g);
    // #9804. Draw bullet if the content is not numbered.
    if (!WrappedCellRenderer.this.contentNumbered) {
      java.awt.Rectangle rect = g.getClipBounds();
      g.fillOval(rect.x, rect.y, 7, 7);
    }
  }
};

代码示例来源:origin: jshiell/checkstyle-idea

@Override
public void paintComponent(final Graphics g) {
  g.setColor(getBackground());
  int offset = 0;
  if (getIcon() != null) {
    offset = getIcon().getIconWidth() + getIconTextGap();
  }
  g.fillRect(offset, 0, getWidth() - 1 - offset, getHeight() - 1);
  if (selected) {
    g.setColor(UIManager.getColor("Tree.selectionBorderColor"));
    g.drawRect(offset, 0, getWidth() - 1 - offset, getHeight() - 1);
  }
  super.paintComponent(g);
}

代码示例来源:origin: haraldk/TwelveMonkeys

@Override
protected void paintComponent(Graphics graphics) {
  Graphics2D g = (Graphics2D) graphics;
  int iconHeight = getIcon() == null ? 0 : getIcon().getIconHeight() + getIconTextGap();
  // Paint checkered bg behind icon
  g.setPaint(checkeredBG);
  g.fillRect(0, 0, getWidth(), getHeight());
  // Paint black bg behind text
  g.setColor(getBackground());
  g.fillRect(0, iconHeight, getWidth(), getHeight() - iconHeight);
  try {
    opaque = false;
    super.paintComponent(g);
  }
  finally {
    opaque = true;
  }
}

代码示例来源:origin: com.github.insubstantial/substance

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

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

@Override
protected void paintComponent(Graphics g) {
 if (myEditorPane == null) {
  super.paintComponent(g);
 }
}

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

public void paintComponent(Graphics g) {
    if (g instanceof Graphics2D) {
      ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
    }

    super.paintComponent(g);
  }
}

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

@Override
  protected void paintComponent(Graphics g) {
    Graphics2D g2d = (Graphics2D) g;
    Composite alphaComp = AlphaComposite.getInstance(
        AlphaComposite.SRC_OVER, 1.0f);
    g2d.setComposite(alphaComp);
    super.paintComponent(g2d);
  }
}

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

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

  if (this.hintIcon != null) {
   int iconWidth = hintIcon.getIconWidth();
   int x = getWidth() - iconWidth - 2;

   int y = 0;
   hintIcon.paintIcon(this, g, x, y);
  }
 }
}

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

@Override
 protected void paintComponent(Graphics g) {

  // Fixes font antialias problem on Windows
  // Note: Must be this exact reference or it doesn't work
  // e.g. using new StringBuffer("AATextInfoPropertyKey") fails
  // See StackOverflow: http://stackoverflow.com/questions/2266199/how-to-make-jtextpane-paint-anti-aliased-font
  if (useAATextProperty) {
   this.putClientProperty(SwingUtilities2.AA_TEXT_PROPERTY_KEY, null);
  }
  super.paintComponent(g);
 }
}

代码示例来源:origin: net.java.dev.laf-widget/laf-widget

@Override
  protected void paintComponent(Graphics g) {
    Graphics2D g2 = (Graphics2D) g.create();
    g2.setComposite(AlphaComposite.SrcOver.derive(this.alpha));
    super.paintComponent(g2);
    g2.dispose();
  }
}

代码示例来源:origin: robo-code/robocode

@Override
  public void paintComponent(Graphics g) {
    g.setColor(SystemColor.activeCaption);
    
    int width = getWidth() * battlefieldWidthSlider.getValue() / MAX_BATTLEFIELD_SIZE;
    int height = getHeight() * battlefieldHeightSlider.getValue() / MAX_BATTLEFIELD_SIZE;
    g.fillRect(0, 0, width, height);
    super.paintComponent(g);
  }
}

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

public void paintComponent(Graphics g)
{
  if (isRenderImage())
  {
    super.paintComponent(g);
  }
  else
  {
    viewer.paintPage((Graphics2D)g.create());
  }
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-modelutil

public @Override void paintComponent(Graphics g) {
    super.paintComponent(g);
    if (item.kind == Kind.MAIN) {
      g.setColor(Color.gray);
      int h = getHeight();
      h -= 2;
      g.drawLine(0, h, getWidth(), h);
    }
  }
}

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

@Override
protected void paintComponent( final Graphics g )
{
  final Graphics2D g2d = (Graphics2D)g;
  final RenderingHints oldHints = g2d.getRenderingHints();
  g2d.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON );
  super.paintComponent( g );
  g2d.setRenderingHints( oldHints );
}

代码示例来源:origin: aterai/java-swing-tips

@Override protected void paintComponent(Graphics g) {
  Graphics2D g2 = (Graphics2D) g.create();
  // Insets ins = getInsets();
  g2.setPaint(new GradientPaint(50, 0, Color.WHITE, getWidth(), getHeight(), bgc));
  g2.fillRect(0, 0, getWidth(), getHeight());
  g2.dispose();
  super.paintComponent(g);
 }
};

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

@Override
public void paintComponent(Graphics g) {
  super.paintComponent(g);
  if (getIcon()!=null)
   g.drawImage(((ImageIcon)getIcon()).getImage(), 0, 0, getWidth(), getHeight(), null);
}

代码示例来源:origin: org.bidib.jbidib.com.vldocking/vldocking

public void paintComponent(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;
    Paint p = g2.getPaint();
    g2.setPaint(new GradientPaint(0, 0, Color.WHITE, getWidth(), 0, getBackground()));
    g2.fillRect(0, 0, getWidth(), getHeight());
    g2.setPaint(p);
    super.paintComponent(g);
  }
};

相关文章

JLabel类方法