Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to set a pop-up frame always on the top?

Posted on 2004-09-30
7
Medium Priority
?
192 Views
Last Modified: 2011-10-03
In my program, if I click a button, it will pop-up a small frame-based window and I want to set it always on the top. How can I do that?

Assumed the frame-based window looks like:

...
JFrame myFrame = new JFrame();
myFrame.setVisable(true);
...

Besides, if I click the OK-button on this window, it will be closed or distroyed, not using setVisable(false). How to do that?
0
Comment
Question by:chenwei
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 4

Expert Comment

by:gdrnec
ID: 12193826
Do you mean you want the Frame to act as a modal dialog?
0
 
LVL 9

Accepted Solution

by:
DrWarezz earned 120 total points
ID: 12194041
To set it to be on top, try this:

myFrame.toFront();

should work. :)

gL,
[r.D]
0
 
LVL 18

Expert Comment

by:armoghan
ID: 12197492
JDialog myDialog = new Dialog();
myDialog.setModel(true);
myDialog.show();
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:chenwei
ID: 12199332
To DrWarezz:

It works.

Bur how about the followings:
Besides, if I click the OK-button on this window, it will be closed or distroyed, not using setVisable(false). How to do that?
0
 
LVL 9

Expert Comment

by:DrWarezz
ID: 12200276
Hi chenwei,
I'm not totally sure what you mean, by:
"not using setVisable(false)"

Could you elaborate a little more? Thanks.
[r.D]
0
 

Author Comment

by:chenwei
ID: 12200447
Hi DrWarezz,

after I click the OK-button on this frame, this frame-window should close, i.e. should be deleted from the program memory. Since I don't know how to do that, I use setVisable(false). But the frame-window is still in the program-memory, right?

Is there any function like myFrame.close() ?
0
 
LVL 18

Expert Comment

by:armoghan
ID: 12223952
add the listener to the button and call this function
frame.dispose();

use like this for X button on toolbar
frame.setDefaultCloseOperation(
                                 JFrame.EXIT_ON_CLOSE);

 
 you can also handle the closing event like this
 frame.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                super.windowClosing(e);
///Do some stuff here before closing
            }
        });
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses

927 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question