Solved

Making stay up frame when outside of frame clicked..

Posted on 2004-04-15
9
208 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
  • 5
  • 3
9 Comments
 
LVL 13

Expert Comment

by:Webstorm
Comment Utility
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
Comment Utility
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
Comment Utility
     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
 
LVL 92

Expert Comment

by:objects
Comment Utility
> what 'applet' does represent?

your applet instance.
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

Author Comment

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

Expert Comment

by:objects
Comment Utility
i mean you JApplet object.
0
 

Author Comment

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

Expert Comment

by:objects
Comment Utility
> 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
Comment Utility
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

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 first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
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:
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

743 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now