Results 1 to 7 of 7
Thread: Clearing up a GUI
- 01-30-2012, 11:23 PM #1
Member
- Join Date
- Dec 2011
- Posts
- 17
- Rep Power
- 0
-
Re: Clearing up a GUI
Probably easiest is to remove the image-holding ImageIcons from the JLabels. This can be done by calling setIcon(null) on the JLabels.
- 01-31-2012, 12:18 AM #3
Member
- Join Date
- Dec 2011
- Posts
- 17
- Rep Power
- 0
Re: Clearing up a GUI
How do you mean that? If i just replaced the directory with null, it wouldn't be done by clicking on a button.
-
Re: Clearing up a GUI
You are using terms that I don't understand, and I fear that you assume that I know more about the structure of your program than I do (which is very little indeed).
What I'm suggesting is that if you want to clear an image out of a GUI that is held by a JLabel, you simply call setIcon(null) on that JLabel, that's it.
- 01-31-2012, 12:49 AM #5
Re: Clearing up a GUI
Another way is to place JPanels in the GUI witch you probably already have done... and then use the .setVisible(true/false) to show and hide the images. The advantage of this is that you have control over the placement? But sense Fubarable is better then me in JAVA i would take his advice.
- 01-31-2012, 11:08 AM #6
Member
- Join Date
- Dec 2011
- Posts
- 17
- Rep Power
- 0
Re: Clearing up a GUI
But if I did that, would I be able to place other images on positions where the former images were placed (before they were hid by setting .setVisible(false))?
So you mean by writing labelx.setIcon(null); into the actionPerformed section of my button's code? And then I could write some code to find out which picture was shown on my GUI and then remove it using labelx.setIcon(null);?
- 01-31-2012, 02:55 PM #7
Re: Clearing up a GUI
The things is that me and fubarable are talking about are the same, first you place the JPanel/s and set your layout then you add the imageicons to the panels, and when you want to clear an icon you can call JLable.setIcon(null) on it.
If you are that worried about positions and stuff you can also use the graphics object to draw them on the JFrame/JPanel then they would appear on the exact pixels you'd like
But if the pictures are going to appear in static positions then I'd use Panels and imageicons
Similar Threads
-
Clearing Documents in TextPanes
By wired-in=p in forum AWT / SwingReplies: 1Last Post: 01-31-2012, 08:59 AM -
A lot of conceptual questions that need clearing up.
By Gsangha in forum New To JavaReplies: 4Last Post: 01-06-2012, 04:23 PM -
screen not clearing during resize
By cl2606 in forum Java AppletsReplies: 5Last Post: 11-23-2011, 11:55 AM -
emptying/clearing an array
By i8java in forum New To JavaReplies: 2Last Post: 08-09-2010, 01:39 PM -
Help Clearing BufferedImage
By ketann in forum Java 2DReplies: 19Last Post: 03-29-2010, 07:45 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks