开发者

Set JWindow Background Image

Hey All

I want to set a Background for my JWindow. I used setIconImage method in JWindow. but it's not working

How knows what the problem is?

    public MainMenu() throws Exception {
    try {
        bg = ImageIO.read(new File("pics" + File.separator
                + "mainMenuBackground.jpg"));

        content = new JWindow(this);
        content.set开发者_开发百科IconImage(bg);
        gs.setFullScreenWindow(content);
        content.repaint();

        this.setDefaultCloseOperation(EXIT_ON_CLOSE);
        this.repaint();
    } catch (Exception e) {
        throw new Exception("Some files are unavailable");
    }
}

This lines of code makes a Full-screen window with no background image. why?

How can i fix it?


The setIconImage is for the window icon, not for the background.

Try for instance setBackground. If you want some custom background image, you probably have to either override some paint(Graphics g) method, or set some content pane / add some component that paints the image.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜