Question

Hy,

I got an intersting problem which I stumbled upon. When I double-click a JLabel in a JSplitPane I want to add another jbutton in a JPanel, its a shorter way to make a dragg and drop. The problem is that the button doesn't appears only if i'll position the mouse on the area the button should appear. Why does it happens this way? Anyone got a clue? Are there some thread related issues involved? Sorry, I forgot to mention that the jlabel which I want to double-click it's in another Jpanel from which I want to dispaly the jbutton, perhaps is relevant. Thanks in advance

Was it helpful?

Solution

When you add (remove) a component to a visible GUI then you should do:

panel.add( component );
panel.revalidate();
panel.repaint();

If you need more help post your SSCCE showing the problem.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top