嘿,所有人
我想为我的JWindow设置一个背景。我在JWindow中使用了setIconImage方法。但它不起作用
如何知道问题出在哪里?
public MainMenu() throws Exception {
try {
bg = ImageIO.read(new File("pics" + File.separator
+ "mainMenuBackground.jpg"));
content = new JWindow(this);
content.setIconImage(bg);
gs.setFullScreenWindow(content);
content.repaint();
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.repaint();
} catch (Exception e) {
throw new Exception("Some files are unavailable");
}
}这几行代码创建了一个没有背景图像的全屏窗口。为什么?
我怎么才能修复它?
发布于 2011-05-25 20:29:18
setIconImage用于窗口图标,而不是背景。
以setBackground为例。如果您想要一些自定义背景图像,您可能需要覆盖一些paint(Graphics g)方法,或者设置一些内容窗格/添加一些绘制图像的组件。
https://stackoverflow.com/questions/6124418
复制相似问题