2008-05-08
refresh JPanel & print Image in JPanel
//刷新JPanel
public void refresh() {
contentPanel.validate();
contentPanel.revalidate();
contentPanel.updateUI();
contentPanel.repaint();
}
JPanel里面画背景图片:
@Override
protected void paintComponent(Graphics g){
paintBackLeftImg(g);
paintBackCentertImg(g);
this.setOpaque(false);//!!!
}
private void paintBackCentertImg(Graphics g) {
ImageIcon bg = new ImageIcon("pic/yct/backYCTWaitCard.jpg");
g.drawImage(bg.getImage(), getBackgroudLeft().getWidth(), 0,
Color.green, null);
}
sun forums :
cPane=new JPanel() {
public void paintComponent(Graphics g)
{
ImageIcon icon=new ImageIcon(ClassLoader.getSystemResource("test.jpg"));
Rectangle rect=g.getClipBounds();
g.fillRect(rect.x, rect.y, rect.width, rect.height);
g.drawImage(icon.getImage(), 0, 0, Color.green, null);
}
};
cPane.setOpaque(false);
发表评论
- 浏览: 10756 次
- 性别:

- 来自: 广州

- 详细资料
搜索本博客
最近加入圈子
最新评论
-
gwt spring 完美整合
gwt前端定义一个异常类 public class ApplicationExc ...
-- by yongyuan.jiang -
gwt spring 完美整合
(gwt+spring)我想用aop拦截来判断session超时,但是我怎样才能 ...
-- by angeltping -
GWT HTML Template :模板 ...
hehe,HTMLTemplatePanel增强功能,gwt类直接获得模板页面对 ...
-- by yongyuan.jiang -
Gwt 服务端使用hiberante ...
能说说都有哪些问题?为什么产生?如何解决? 正打算在一个GWT项目的服务器端使用 ...
-- by abo -
gwt spring 完美整合
博主是javaeye上的gwt第一高人,特别希望博主可以就如何用gwt开发一个伸 ...
-- by abo






评论排行榜