Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
629 views
in Technique[技术] by (71.8m points)

java - Swing , Multiple Screens , Transfer of control

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

1.A button from screen1 will launch screen 2.

PseudoCode :

ScreenA extends JFrame{

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

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

Now the output is :

  1. The screen 2 will be displayed 2.Hai will be printed.

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

How do i achieve it ?

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 ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...