关闭JFrame而不关闭我的整个项目[重复]

时间:2023-01-17 10:13:37

This question already has an answer here:

这个问题在这里已有答案:

Hi this problem is a little bit big.. I started my first big Java Project and right now I do not know how to close a JFrame without closing my whole project.

嗨这个问题有点大..我开始了我的第一个大型Java项目,现在我不知道如何在不关闭整个项目的情况下关闭JFrame。

This are my project files: https://drive.google.com/open?id=0BxIXktk4GMkIMnd6ZXlLQnBHem8

这是我的项目文件:https://drive.google.com/open?id = 0BxIXktk4GMkIMnd6ZXlLQnBHem8

I tried everything to close the JFrame loginRegisterWindow but with everything I tried the Frame stayed open ..

我尝试了所有关闭JFrame loginRegisterWindow但是我尝试过的所有内容都保持打开状态..

Has anyone a specific solution for my project how I could do this?

有没有人为我的项目提供具体的解决方案?

The code where the JFrame loginRegisterWindow should be closed should be in the class Login in the func package after the sentence "logged in has been printed".

应该关闭JFrame loginRegisterWindow的代码应该在“登录已打印”句子后的func包中的类Login中。

NOTE: Please give feedback if you don't understand my question .. i am new to stack overflow

注意:如果您不理解我的问题,请提供反馈..我是新的堆栈溢出

2 个解决方案

#1


2  

You shouldn't use multiple JFrames because it will bring a bad user experience and will be harder to maintain. Instead you should give a try to Card Layout or use JDialogs which will prevent the user from exiting your application or click behind.

您不应该使用多个JFrame,因为它会带来糟糕的用户体验并且难以维护。相反,您应该尝试卡布局或使用JDialogs,这将阻止用户退出您的应用程序或点击后面。

But if you really need to use multiple JFrames, then you could use JFrame.DISPOSE_ON_CLOSE instead of JFrame.EXIT_ON_CLOSE

但是如果你真的需要使用多个JFrame,那么你可以使用JFrame.DISPOSE_ON_CLOSE而不是JFrame.EXIT_ON_CLOSE

#2


1  

try

yourJFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

I assume you have other threads processing your business logic, right? Otherwise, why care to keep Java alive?

我假设您有其他线程处理您的业务逻辑,对吧?否则,为什么要关心让Java活着?

#1


2  

You shouldn't use multiple JFrames because it will bring a bad user experience and will be harder to maintain. Instead you should give a try to Card Layout or use JDialogs which will prevent the user from exiting your application or click behind.

您不应该使用多个JFrame,因为它会带来糟糕的用户体验并且难以维护。相反,您应该尝试卡布局或使用JDialogs,这将阻止用户退出您的应用程序或点击后面。

But if you really need to use multiple JFrames, then you could use JFrame.DISPOSE_ON_CLOSE instead of JFrame.EXIT_ON_CLOSE

但是如果你真的需要使用多个JFrame,那么你可以使用JFrame.DISPOSE_ON_CLOSE而不是JFrame.EXIT_ON_CLOSE

#2


1  

try

yourJFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

I assume you have other threads processing your business logic, right? Otherwise, why care to keep Java alive?

我假设您有其他线程处理您的业务逻辑,对吧?否则,为什么要关心让Java活着?