Swing , 多画面 , 控制转移 [英] Swing , Multiple Screens , Transfer of control

查看:15
本文介绍了Swing , 多画面 , 控制转移的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个摇摆应用程序.我正在使用两个屏幕

I am developing a swing application. I am using two screens

1.屏幕 1 中的按钮将启动屏幕 2.

1.A button from screen1 will launch screen 2.

伪代码:

ScreenA extends JFrame{

    onButtonClick(){
        Screen2.setVisible(true);
    }
    System.out.println("Hai");
}

Screen2 extends JFrame{
    onButtonClick{
         Hide this screen;
    }
}

现在的输出是:

  1. 将显示屏幕 22.Hai会被打印出来.

我的目标:我只想在单击屏幕 2 中的按钮并且屏幕 2 消失时才显示 hai.

My Objective : I want to display hai only when a button from screen 2 is clicked and screen 2 dissppears.

我如何实现它?

我尝试在屏幕二中为按钮点击设置一个标志.但程序只是通过条件并继续下一行.我如何保持控制?

I tried setting a flag for buttonclicked in screen two. But the program just passes through the condition and goes on to the next line . How do i keep the control ?

推荐答案

使用模式对话框.有关详细信息,请参阅如何制作对话框.

Use a modal dialog. See How to Make Dialogs for more details.

这篇关于Swing , 多画面 , 控制转移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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