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
2010-03-31 18:42:37
what if its job is done and you no longer need it(if thats a requirement)
2010-03-31 20:24:01
+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
2010-03-31 19:22:36