开发者

How to remove a line drawn between two labels

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?


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();


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜