用paintComponent()方法,最后再调用updateUI()试一下,不行就自己写个UI。
解决方案 »
- 2/15 PLS-00201: 必须声明标识符 'DATASET.REFCURSOR'这是什么原因呢
- 『求助』 依次添加两个带图片的JLabel,怎么让第二个覆盖掉第一个?
- 用Runtime类修改系统IP时的管理员权限
- 请问关于使用java为db2创建触发器问题。谢谢各位。
- static初始化块的问题
- some questions
- 我该怎么办?帮帮我吧!!!
- 如何使用Runtime.getRuntime.exec()执行一个批处理文件??
- CORBA的初学者问题?
- 求推荐java基础的入门书籍
- 关于jfc的使用?
- java在什么网址有详细的学习材料?jbuild什么地方可以下载?怎么安装?分数随答案马上给出!
看看能出来不能
所以画框的代码应改为
public void paint(Graphics g) {
super.paint(g);
g.setColor(this.getBackground());
g.fillRect(0, 0, this.getWidth(), this.getHeight());
g.setColor(this.getForeground());
g.drawRect(0, 0, this.getWidth()-1, this..getHeight()-1);
}
另外,圆角框线应该使用drawRoundRect方法。
右下角的坐标是(x+width+1,y+height+1);ksxy (空山新雨)的代码画
到了Label的外面,所以看不到。
* Override this method to implement customized painting.
* @param g the Graphics.
*/
public void paint(Graphics g) {
g.setColor(borderColor);
g.drawRect(0, 0, this.getWidth() - 1, this.getHeight() - 1);
g.drawString(" " + tipString + " ", 0, this.getHeight() - 4);
}我觉得先前的代码起码应该看到点东东,问题是什么也看不到啊。
super.paint(g);
if(isVisible());//加这样一句试试.
g.setColor(this.getBackground());
g.fillRect(0, 0, this.getWidth(), this.getHeight());
g.setColor(this.getForeground());
g.drawRect(0, 0, this.getWidth()-1, this..getHeight()-1);
}
如果你改变一下label的大小是不是就显示出来啦.