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.
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.
Joined: Feb 15, 2002
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 ?
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.