我得jframe上有4个panel,如果想在其中的一个上面显示由对话框打开的图片,该怎么做呢?
解决方案 »
- System.gc()不能保证垃圾回收是因为垃圾回收器的线程级别低,还是因为垃圾回收器是每隔一段时间去扫描有没有垃圾并且看内存够不够再决定是否回收的,还是都是?
- 咨询一个简单问题,请问如何将swing的界面生成在屏幕中间?
- J2SE问题The type MyChessFrame must implement the inherited abstract 疑惑中~~~求高手相助
- static 的问题!一个小小菜鸟的问题!!
- mysql驱动类notfound,怎么回事?
- resultSet是只读的,如何将它变成可写的?
- 有研究入侵检测的朋友吗
- 菜鸟求教,有谁来帮我看看啊!
- scanner问题
- 创建socket出现unknown host的异常?
- 谁能帮我解释这段代码?关于正则表达式
- 如何js中调用VBA?实现多个word文档的合并?
//
private ImageIcon image = null;
//
public ImagePanel(ImageIcon image) {
this.image = image;
} //
protected void paintComponent(Graphics g) {
setOpaque(true);
super.paintComponent(g); Dimension d = getSize();
for (int x = 0; x < d.width; x += image.getIconWidth()) {
for (int y = 0; y < d.height; y += image.getIconHeight()) {
g.drawImage(image.getImage(), x, y, null, null);
}
}
}
}然后就在mypanel里添加这个带图片的imagepanel(mypanel为BorderLayout):mypanel.removeAll();
mypanel.add(imagepanel, BorderLayout.CENTER);
mypanel.validate();