NewToJava
NewToJava

Reputation: 83

How can I travese to a next / previous page in a swing GUI

I am new to Swing. I am trying to develop an application using Swing. I have managed to create the first page of my application. Now what I want to do is to traverse to a new page, using the next button. But am not able to find a way to do it using Swing. Also, if I click the previous button, would I be able to get the data that I had entered in the text boxes or selected using radio buttons on the previous page. I think this can be done pretty easily in Struts, but how is this to be achieved using Swing.

Please do help.

Thanks a lot.

Upvotes: 1

Views: 3040

Answers (4)

Markus Lausberg
Markus Lausberg

Reputation: 12257

You can create different views like "Login", "Configuration", "MainPage". The views will contain all components you want to show at the screen. You can implement a ViewManager who can handle this views (Show one of the views).

At the bottom of the Main Frame you can add a Button area, where the forware/backward buttons are placed. At the center of the frame you will show the views.

When the button are selected the ViewManager decideds which view is set to visible. From the ViewManager you can get every information from the views you want.

The views can enter the ViewManager and can get the information they need from another view.

Upvotes: 0

Simon Groenewolt
Simon Groenewolt

Reputation: 10665

This one is old but might just get you started: http://java.sun.com/developer/technicalArticles/GUI/swing/wizard/

Upvotes: 0

Rahel Lüthy
Rahel Lüthy

Reputation: 7007

I assume you're trying to build a wizard-style swing dialog? swing does not offer an out-of-the-box framework for this type of task (but of course it offers all UI elements/controls that you will need to create one). just google for "swing wizard framework" and you will find plenty of inspiration -- unfortunately, i can't recommend a single best one (at my company, we have written our own), but i am confident that you will either find one that will work for you or you will familiarize with some patterns that will help you to write one yourself -- good luck!

Upvotes: 1

Related Questions