• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

New set of buttons

 
Ranch Hand
Posts: 35
Netbeans IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Netbeans IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Netbeans IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Netbeans IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the replies especially because this is my first Java GUI.

Appreciate the tips
 
Campbell Ritchie
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic