如何在swing GUI中浏览下一页/上一页

时间:2022-06-08 20:59:13

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.

我是Swing的新手。我正在尝试使用Swing开发应用程序。我设法创建了我的应用程序的第一页。现在我想要做的是使用下一个按钮遍历到新页面。但是我无法使用Swing找到一种方法。此外,如果我单击上一个按钮,我是否能够获取我在文本框中输入的数据或使用上一页上的单选按钮选择的数据。我认为这可以在Struts中轻松完成,但是如何使用Swing实现这一点。

Please do help.

请帮忙。

Thanks a lot.

非常感谢。

4 个解决方案

#1


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

这个很旧但可能只是让你开始:http://java.sun.com/developer/technicalArticles/GUI/swing/wizard/

#2


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!

我假设您正在尝试构建向导式的摇摆对话框? swing不为这类任务提供开箱即用的框架(但当然它提供了创建一个所需的所有UI元素/控件)。只是谷歌的“摇摆向导框架”,你会发现很多灵感 - 不幸的是,我不能推荐一个最好的(在我的公司,我们已经写了我们自己),但我相信你会找到一个这对你有用,或者你会熟悉一些可以帮助你自己写一个的模式 - 祝你好运!

#3


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).

您可以创建不同的视图,如“登录”,“配置”,“MainPage”。视图将包含您要在屏幕上显示的所有组件。您可以实现可以处理此视图的ViewManager(显示其中一个视图)。

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.

在主框架的底部,您可以添加一个按钮区域,其中放置了forware / backward按钮。在框架的中心,您将显示视图。

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.

选择按钮后,ViewManager会决定将哪个视图设置为可见。从ViewManager中,您可以从所需的视图中获取所有信息。

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

视图可以进入ViewManager,并可以从另一个视图获取所需的信息。

#4


Try a tabbed pane or use a CardLayout.

尝试使用选项卡式窗格或使用CardLayout。

#1


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

这个很旧但可能只是让你开始:http://java.sun.com/developer/technicalArticles/GUI/swing/wizard/

#2


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!

我假设您正在尝试构建向导式的摇摆对话框? swing不为这类任务提供开箱即用的框架(但当然它提供了创建一个所需的所有UI元素/控件)。只是谷歌的“摇摆向导框架”,你会发现很多灵感 - 不幸的是,我不能推荐一个最好的(在我的公司,我们已经写了我们自己),但我相信你会找到一个这对你有用,或者你会熟悉一些可以帮助你自己写一个的模式 - 祝你好运!

#3


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).

您可以创建不同的视图,如“登录”,“配置”,“MainPage”。视图将包含您要在屏幕上显示的所有组件。您可以实现可以处理此视图的ViewManager(显示其中一个视图)。

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.

在主框架的底部,您可以添加一个按钮区域,其中放置了forware / backward按钮。在框架的中心,您将显示视图。

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.

选择按钮后,ViewManager会决定将哪个视图设置为可见。从ViewManager中,您可以从所需的视图中获取所有信息。

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

视图可以进入ViewManager,并可以从另一个视图获取所需的信息。

#4


Try a tabbed pane or use a CardLayout.

尝试使用选项卡式窗格或使用CardLayout。