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

New set of buttons

 
Jacob Draper
Ranch Hand
Posts: 35
Java Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


So I have a Jframe that has a set of functions that act on a node.

What I want to do is allow the user to expand the gui by creating new sets (copies) of these functions when they have more nodes.


I thought of hiding extra sets and making it appear they are adding them by making them visible.

I know there is a sleeker way I'm just not sure what that way is, do you?



Hopefully that made sense
Appreciate any direction you can give me ! Thanks
 
Jacob Draper
Ranch Hand
Posts: 35
Java Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My thought is that I may want to place it all within a jpanel inside the jframe, and allow the user to add more jpanels. Am I on the right track?
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

It doesn't really matter for the application, if you place them in a panel and add the panel or add them directly. It all depends on your visual layout
You an always add/remove child components from a parent container which is already being displayed. However, when you do this, you need to call revalidate() and repaint() on the container (in that order) for the changes to reflect visually.

 
Campbell Ritchie
Marshal
Posts: 52621
119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome again

You get odd effects if you add and remove things in your GUI. You can enable and disable buttons with the setEnabled method. You can make panels appear to the front and disappear to the back with card layout.
 
Jacob Draper
Ranch Hand
Posts: 35
Java Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay, so I can create extras and allow user to click add to make them isvisible(true) appearing like they are creating.

I guess my difficulty is that after copy and pasting everything in net beans if have to go in my code and copy paste also altering the code to apply to the correct variables. Seems tedious but I guess it won't take too long, just more room for error.
 
Campbell Ritchie
Marshal
Posts: 52621
119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you use setEnabled(), the buttons change colour. Black print for enabled, grey for disabled. Unless you have use the setForeground() method for different colours.
 
Jacob Draper
Ranch Hand
Posts: 35
Java Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the replies especially because this is my first Java GUI.

Appreciate the tips
 
Campbell Ritchie
Marshal
Posts: 52621
119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome
You should really start writing GUIs with something much smaller and simpler. They take a lot of practice to get to work nicely.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!