如何从登录屏幕进入下一个屏幕?JPanel,JFrame? [英] How to proceed from login screen to the next screen? JPanel, JFrame?

查看:42
本文介绍了如何从登录屏幕进入下一个屏幕?JPanel,JFrame?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个关于构建 GUI 应用程序的问题.我觉得这个问题的标题不是很准确,但我想不出更好的.

I have a question regarding building GUI applications. I feel like the title of this question is not really accurate but I could not think of a better one.

构建应用程序的正确方法是什么?我应该只创建一个 JFrame,然后根据需要更改该 JFrame 中的面板吗?或者我应该总是创建新的 JFrame 并在从一件事转移到另一件事时摆脱旧的?

What is the proper way of building the application? Should I just create one JFrame, then change the panels in that JFrame as needed? Or should I always create new JFrame and get rid of the old one when moving from one thing to another?

例如,我的 JFrame 包含一个 JPanel,该 JPanel 几乎没有文本字段和 JLabel.用户输入用户名和密码,单击登录按钮继续.应该出现一个全新的 JFrame,还是应该使用旧的 JFrame 创建一个新的 JPanel?

For example, I have the JFrame containing a JPanel that has few text fields and JLabels. User enters username and password, clicks a login button to continue. Should a completely new JFrame appear, or should a new JPanel be created instead, using the old JFrame?

推荐答案

视情况而定,但通常情况下,如果您可以重用同一个窗口会更好.通常,您可能希望使用 JDialog/JOptionPane 来处理登录.对话框窗口更易于使用

Depends, but often it's better if you can reuse the same window. Often, you might want to use a JDialog / JOptionPane to handle login. Dialog windows are meant to be more disposable

这篇关于如何从登录屏幕进入下一个屏幕?JPanel,JFrame?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆