Problems adding a component to a jpanel at runtime

Joined
Oct 4, 2007
Messages
1
Reaction score
0
Hi all,
here is my problem: I'm making an application that shows an xml file as a JTree (and this is done). I want to show some components into a JPanel when double-click a node of the tree...for example, if clicking a node, the JPanel has to show a JButton...
I set the Mouse listener to the tree and here is the code i use for the action of the listener:

private void azione(java.awt.event.MouseEvent evt) {
jPanel2.add(new JButton("hello"));
jPanel2.revalidate();
jPanel2.repaint();
}

The application doesn't show anything.
Tnx all
 
Last edited:

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,990
Messages
2,570,211
Members
46,796
Latest member
SteveBreed

Latest Threads

Top