use*_*790 0 java graphics swing jlabel paintcomponent
我已经创建了一个矩形,现在我必须将一个JLabel放入其中.那我怎么能把JLabel放在矩形里面呢.
代码在这里: -
public class ColoredRect extends JPanel
{
private double x, y, width, height;
public ColoredRect(double x,double y)
{
this.x = x;
this.y = y;
width = 100;
height =40;
rect = new Rectangle2D.Double(this.x , this.y,width,height);
}
public void paintComponent(Graphics g)
{
super.paintComponent(g);
Graphics2D g2 = (Graphics2D) g;
g2.setColor(Color.cyan);
g2.fill(rect);
}
}
Run Code Online (Sandbox Code Playgroud)
请给我一些实现这个的想法.
提前致谢.
| 归档时间: |
|
| 查看次数: |
1817 次 |
| 最近记录: |