Results 1 to 7 of 7
Thread: GUI Problem
- 08-29-2013, 11:15 PM #1
Member
- Join Date
- Feb 2010
- Posts
- 25
- Rep Power
- 0
GUI Problem
Hi every body
i made a JPanel with a custom background (photo) and it contains many labels (label1 ... label 4)
each label (i) with a custom photo (photo i) as background ...
a JComboBox is made for showing a label and hidding all other labels by selecting the desired label ...
the problem is :
when i select label1 for example : okey it shows the photo1
when i select label2 for example : it shows the photo1 and photo2 still appears
and when i select label3 also photos 1 2 3 are visibles one over others ... and also the Jpanel main photo is no longer visible...
(each time i resize the application window a little, the photo1 photo2 disappear correctly but Jpanel main photo is still invisible...)
Many thanks to any help
- 08-29-2013, 11:16 PM #2
Member
- Join Date
- Feb 2010
- Posts
- 25
- Rep Power
- 0
Re: GUI Problem
...also i used repaint() and revalidate() .. the problem exists ...
- 08-30-2013, 06:12 AM #3
Re: GUI Problem
Never use getGraphics() of a Component.
To get better help sooner, post a SSCCE (Short, Self Contained, Correct (Compilable), Example) that demonstrates the problem.
And if you've cross posted this elsewhere, please tell us about it.
dbIf you're forever cleaning cobwebs, it's time to get rid of the spiders.
- 08-31-2013, 01:20 AM #4
Member
- Join Date
- Feb 2010
- Posts
- 25
- Rep Power
- 0
Re: GUI Problem
Any help Please
- 08-31-2013, 01:23 AM #5
Just a guy
- Join Date
- Jun 2013
- Location
- Netherlands
- Posts
- 5,114
- Rep Power
- 13
Re: GUI Problem
No, don't pretend that Darryl never replied so you can keep doing as little as possible. Create an SSCCE and THEN you'll get "any help". First you make some effort to present a clear problem description.
"Syntactic sugar causes cancer of the semicolon." -- Alan Perlis
- 08-31-2013, 05:28 AM #6
Member
- Join Date
- Feb 2010
- Posts
- 25
- Rep Power
- 0
Re: GUI Problem
Hi all,
thanks for your replies above....
the complete code is too long and i can NOT paste it here completely ...
here is a short but clear explanation :
First i made many labels (3 for example) with a custom background and put them in a main JPanel :
/// the main Panel
mainPanel = new JPanel();
mainPanel.setBounds(0,30,1420,830);
mainPanel.setLayout(null);
///Label1 …
Label1 = new JLabel();
Label1.setBounds(170,125,1340,750);
Label1.setLayout(null);
ImageIcon StdBack = new ImageIcon("src/Graphics/Pnl1.png"); Label1.setIcon(StdBack);
MainPanel.add(Label1);Label1.setVisible(false);
/// and so for Label2 and Label3
Then, a JComboBox calls the method ShowChoosed(int i) each time i select from it some JLabel :
// Show the appropriate Label...
public static void ShowChoosed(int i) {HidePanels();
switch (i) {case 1 : Label1.setVisible(true); break;
case 2 : Label2.setVisible(true); break;
case 3 : Label3.setVisible(true); break;
}
}
// Hide All Panels ...
public static void HidePanels() {Label1.setVisible(false);
Label2.setVisible(false);
Label3.setVisible(false);
}
even if i use :
mainPanel.repaint();
mainPanel.revalidate();
the problem still exists : When i choose Label 2 for example : the Label 2 is Visible okey, but the label 1 is also still visible and there is a clutter of labels...
Please note that : if i resize the window a little (make it bigger or smaller a little) the label 1 disappears ....
Thanks to any help
- 08-31-2013, 06:14 PM #7
Senior Member
- Join Date
- Jan 2013
- Location
- Northern Virginia, United States
- Posts
- 6,226
- Rep Power
- 15
Re: GUI Problem
Please place your code between code tags [CODE][/CODE]. And where is the SSCCE? I can't answer your question as presented but I have done enough graphics programming to know that it doesn't take much code to put a couple of buttons in a JPanel.
Also, where is your JFrame?
Regards,
JimThe JavaTM Tutorials | SSCCE | Java Naming Conventions
Poor planning on your part does not constitute an emergency on my part
Similar Threads
-
Delay between 2 same timings problem (Video of explanation of the problem inside)
By Lionlev in forum Advanced JavaReplies: 0Last Post: 11-07-2012, 01:44 PM -
Small problem with problem with Java, C++ parse program.
By dragstang86 in forum New To JavaReplies: 4Last Post: 10-30-2011, 04:43 AM -
Can anyone see the problem with my code? problem understanding switch (newbish)
By keith in forum New To JavaReplies: 9Last Post: 09-21-2010, 05:15 PM -
simple line problem / for loop problem
By helpisontheway in forum New To JavaReplies: 1Last Post: 11-17-2009, 07:12 AM
Bookmarks