Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to design ?

 
kwwong wong
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am new in Swing application. I want to write an application that has login screen for user login when the application launch. After the user login, it will show another screen which has several buttons. Each button when clicks will show another screen for different functions. The new screen also has another buttons to go to the new screens etc...
How to implement? Is it using the card layout ? Or is there has any standard mechanise for the page navigation in Swing application ? Thanks.
 
George McCain
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Correct me if i'm wrong.
Layouts are just for content layout on a UI component. Ie how buttons/labels and other things are displayed on the screen.
For page navigation (on clicking this button go here), i don't believe that there are any flow managers built into java. Of course you could make your own flow engine or something.
 
kwwong wong
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can I create a JFrame first and then add a JPanel on the JFrame which is the one page of my application. When I click the button on page one, I remove the JPanel from the JFrame and then add another JPanel on the JFrame which is page two of my application. It also has a button on the page two to navigate to other pages for different functions in my application ?
Where can I download the sample application which has the page natvigation mechanism ?
 
Masi Man
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can work with the JTabbed Pane. So each of them has the buttons and objects you need , and you can easily switch between the different Panels.
Also if one should be invisible for one kind of user, that isnt a problem
Take a look at this:
http://java.sun.com/docs/books/tutorial/uiswing/components/tabbedpane.html
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
kwwong wong, your initial idea about using CardLayout is correct. Use a CardLayout when you want to control the users progress through a series of panels. Use a JTabbedPane if the order doesn't matter and the user can control their movement through the panels.

Just name each "card" in the card layout a specific name and define which buttons take the user to which card in one big actionlistener. Then attach this actionlistener to all the buttons.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic