Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to delete components ?

 
Avin Sinanan
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there.. does anyone out there know how to delete a button. For example if you added a button to a JPanel and then if you right click on it then it dissapears.
Or lets say youi draw a line and you want to get rid of the line , how do you do this. Lets assume that you know the cordinates of the line. Does anyone know how to do this? thanks in advance
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To remove an actual component you would have to call remove( button ) and then call validate(), both on the JPanel (or other container) that holds the button.

Since a line isn't a component, but can only be painted on a component, you'll have to handle that in whatever component is painting the line on itself...

-Nate
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!