File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes How to design ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to design ?" Watch "How to design ?" New topic

How to design ?

kwwong wong
Ranch Hand

Joined: Feb 15, 2002
Posts: 56
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

Joined: May 06, 2003
Posts: 35
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

Joined: Feb 15, 2002
Posts: 56
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

Joined: Mar 03, 2003
Posts: 5
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:
Nathan Pruett

Joined: Oct 18, 2000
Posts: 4121

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.

Write once, run anywhere, because there's nowhere to hide! - /. A.C.
I agree. Here's the link:
subject: How to design ?
It's not a secret anymore!