tags:

views:

34

answers:

2

I want to remove a line connecting two labels. Actually, I want to remove a label after which the line connecting the label is also removed. How can I do it?

+1  A: 

You can't "remove lines" in swing. You can only add stuff onto a component when drawing. Just don't draw the line.

Show us some code

Pyrolistical
what if its job is done and you no longer need it(if thats a requirement)
+1  A: 

Do the opposite to what you do when you add the line to the panel. Presumably you have an ArrayList containing "lines to be drawn". So, whenever you link two labels you add a line to the ArrayList. So now you would just remove the line from the ArrayList and repaint the panel.

To remove the component you just do:

panel.remove(...);
panel.revalidate();
panel.repaint();
camickr
wel thanx.i think dis should work.but i dont think revalidate() is really needed.