Solved

Making stay up frame when outside of frame clicked..

Posted on 2004-04-15
9
248 Views
Last Modified: 2010-03-31
hi!

I have an applet and when I run it on web site floating JFrame pop up. Now, if I click outside of the JFrame, I guess the JFrame goes behind web browser frame. Do do I fix that?
****************************
  public void init() {

    wizardFrame = new JFrame("Configured");
    container = wizardFrame.getContentPane();
0
Comment
Question by:dkim18
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
9 Comments
 
LVL 13

Expert Comment

by:Webstorm
ID: 10836624
Hi dkim18,

>> I guess the JFrame goes behind web browser frame.
Only if you click on another window covering your Frame.

You can either

  * make the JFrame the same size as the screen :
    Dimension screen_size = Toolkit.getDefaultToolkit().getScreenSize();
    wizardFrame.setBounds(0,0,screen_size.width,screen_size.height);

  * or use a swing timer in order to periodically put your JFrame on the top :

         Timer tm=new Timer(1000, // every 1000 ms
             new ActionListener() {
                  public void actionPerformed(ActionEvent ev)
                  { wizardFrame.toFront(); }
             }
         );

0
 
LVL 92

Accepted Solution

by:
objects earned 100 total points
ID: 10837840
Use a JDialog and make your applet the dialog owner.

Frame owner = (Frame) SwingUtilities.getAncestorOfClass(Frame.class, applet);
JDialog dialog = new JDialog(owner);
0
 

Author Comment

by:dkim18
ID: 10839149
     Timer tm=new Timer(1000, // every 1000 ms
             new ActionListener() {
                  public void actionPerformed(ActionEvent ev)
                  { wizardFrame.toFront(); }
             }
         );


 Webstorm,

This didn't work
------------------------

object,

Frame owner = (Frame) SwingUtilities.getAncestorOfClass(Frame.class, applet);
JDialog dialog = new JDialog(owner);

what 'applet' does represent?


0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 92

Expert Comment

by:objects
ID: 10839163
> what 'applet' does represent?

your applet instance.
0
 

Author Comment

by:dkim18
ID: 10839176
applet instance? sorry...i don't understand...
what do you mean by that?
0
 
LVL 92

Expert Comment

by:objects
ID: 10839193
i mean you JApplet object.
0
 

Author Comment

by:dkim18
ID: 10839434
Since this is an applet, how come there is an object?
All are worked in init().
0
 
LVL 92

Expert Comment

by:objects
ID: 10839473
> Since this is an applet, how come there is an object?

not sure what u mean, JApplet is a class, and your applet is an instance of that class.
0
 
LVL 92

Expert Comment

by:objects
ID: 10873915
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Suggested Solutions

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Suggested Courses

739 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