why is remove(myPanel2) not working?

G

Geoff Cox

Hello,

For some reason the

contentArea.remove(myPanel3);

works but the

contentArea.remove(myPanel2);

does not - any ideas please?

(happy to post the whole code if this helps)

Cheers

Geoff


if (textIndex == 0)
{


contentArea.remove(myPanel2);

contentArea.remove(myPanel3);
myPanel3 = new JPanel();
myPanel3.setBackground(Color.white);

JLabel endMessage = new JLabel("Thank you - all questions
answered");

myPanel3.add(endMessage);
contentArea.add(myPanel3, BorderLayout.SOUTH);
setContentPane(contentArea);
contentArea.setVisible(true);

}
 
A

Andrew Thompson

For some reason the

contentArea.remove(myPanel3);

works
[1]

...but the

contentArea.remove(myPanel2);

[1] What do you mean 'it works'? *Specifically* what
do you mean? Describe it in detail, ..
does not - any ideas please?

(happy to post the whole code if this helps)

...provide that code. Since the word
descriptions are not that clear.

E.G. you state that removing the myPanel3 'works', yet
your code immediately re-adds it, so I am not certain
how *you* can be sure it is *ever* removed in the first
place.

And look, for my personal preferences, the SSCCE[1] provided
with the brief explanation and question is almost always
necessary. *Especially* when the poster[2] has no idea what is
going wrong. The trick is that if the poster does not know
what is going wrong, they often (usually) post the wrong
'bit' of code.

[1] <http://www.physci.org/codes/sscce.jsp>
[2] you, in this instance, but could be anyone.

[ Note: Follow-Ups to this response set to c.l.j.help only. ]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,999
Messages
2,570,246
Members
46,841
Latest member
WilmerBelg

Latest Threads

Top