This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Update GUI In Realtime  RSS feed

 
Isaac Hewitt
Ranch Hand
Posts: 191
Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would like to allow the user to update a JToolbar in realtime without having to restart the program. In the JMenu, a user has a choice of JToolbar without an Icon and text, or with an Icon and text.

I wanted to know if there is a way to destroy the first JToolbar and add another one in its place. Thanks
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you can just add() and remove() the JToolbar from it's container, just like any other JComponent.
 
Isaac Hewitt
Ranch Hand
Posts: 191
Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks
 
Isaac Hewitt
Ranch Hand
Posts: 191
Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For anyone wanting to use this code in a similar situation, here it is. It does not work correctly unless the validate() method is used at the end.
The variable pane refers to a Container in a JFrame.

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