Results 1 to 3 of 3
- 08-05-2010, 05:24 AM #1
Member
- Join Date
- Oct 2009
- Posts
- 17
- Rep Power
- 0
Help: Displaying Images AND Adding Buttons
At first I had no idea how to display images in a window displayer, so I browsed through the web to find some code, and ended up with:
http://download.oracle.com/javase/tu...dImageApp.java
OK, so the program runs to display an image, no problem there. I copied the code for my own class so then I can display my own image(s). The problem now is that I also want to add buttons in the same program; in this case, I need to get my class to extends EasyApp. The idea is to add 4 directional buttons (up, down, left, right) in which I can move the image a number amount of pixels (with a border limit); simple. However, because my class is already extending another class (Component or EasyApp), there can not be multiple inheritance using extends. Either I have no image(s), or I have no buttons, or the code doesn't compile, or the program doesn't work. I am not so sure about implements right now (I have barely any knowledge on it).
Is there any alternative code to make this work? Or do I have to create separate classes? Or what should I do?Last edited by Rhez; 08-05-2010 at 05:28 AM.
-
If I want my GUI to have a background image, I usually extend JPanel and then draw the image in the JPanel's paintComponent method and then add this JPanel to the JFrame's contentPane. Then I can add whatever components I'd like to this JPanel, but taking sure that if I add other JPanels, I call setOpaque(false) on them first.
You'll find plenty of example code for doing this here at other forum sites, and via google.
- 08-05-2010, 06:19 AM #3
Senior Member
- Join Date
- Jul 2009
- Posts
- 1,143
- Rep Power
- 5
Similar Threads
-
Displaying Radio Buttons in JSP
By kishan in forum Advanced JavaReplies: 4Last Post: 10-23-2009, 03:44 PM -
Changing images by clicking arrow buttons. help?
By ashton in forum New To JavaReplies: 3Last Post: 02-08-2009, 11:29 AM -
Displaying large images
By pir8ped in forum AWT / SwingReplies: 2Last Post: 01-21-2009, 09:20 PM -
[SOLVED] Need help in displaying images
By kirly in forum Advanced JavaReplies: 3Last Post: 10-21-2008, 05:36 AM -
Images not displaying in JSP in IE7
By chadscc in forum Advanced JavaReplies: 0Last Post: 11-13-2007, 03:24 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks