|
-
Background image
I am trying to get a lot of JButtons to display on top of a background image of the world in a JFrame.
So far, I've tried a lot of things. I tried overwriting the paint function of the JFrame to drawImage the image of the world. But whenever I repainted, the buttons got painted very quickly and then covered by the background image.
I then tried to create a JLayeredPane. Here is an excerpt of the code:
Dimension layeredPaneSize = new Dimension(1025, 740);
JLayeredPane layeredPane = new JLayeredPane();
layeredPane.setPreferredSize(layeredPaneSize);
JButton myWorldButton = new JButton (big_world);
myWorldButton.setVisible(true);
myWorldButton.setBounds (10, 10, 1000, 700);
layeredPane.add(myWorldButton, JLayeredPane.DEFAULT_LAYER, 0);
tmp1 = 0;
tmp2 = 0;
for (int s = 0; s < 5; ++s)
{
world[s].myButton.setBounds(tmp1,tmp2, 8, 8);
layeredPane.add(world[s].myButton, JLayeredPane.POPUP_LAYER, 0);
tmp1 = tmp1 + 10;
tmp2 = tmp2 + 10;
}
Checkbox less_than = new Checkbox (" <");
less_than.setBounds(20, 650, 10, 10);
layeredPane.add(less_than, JLayeredPane.MODAL_LAYER, 0);
frame.getContentPane().add(layeredPane);
And the only thing that happens is that the checkbox displays. Does anybody have any idea how I should proceed/what I'm doing wrong? Please let me know. Thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks