Solved

sendToBack method in frame

Posted on 2004-04-12
14
335 Views
Last Modified: 2012-08-13
Sample code:
JFrame myFrame = new JFrame("New windows");
myFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
myFrame.pack();
myFrame.setVisible(true);

My problem is how to use the sendToBack method in the frame ? or have any similar function will do the same thing? Actually i want to display the frame in first come first server order that mean which frame is launch first it should get the focus.

thanks

0
Comment
Question by:Kennywen
  • 6
  • 5
  • 2
  • +1
14 Comments
 
LVL 14

Expert Comment

by:StillUnAware
ID: 10810843
You may do a trick:
first you make a frame iconified, it means minimized, and later restore it after some time, or after the last frame loaded.

Frame.setState(Frame.ICONIFIED);
0
 

Author Comment

by:Kennywen
ID: 10810858
No, i don't want the frame to be minimized, i just want to send to back of the frame.

thanks
0
 
LVL 14

Expert Comment

by:StillUnAware
ID: 10810886
Well, after minimizing the first frame and loading other frames, you restore it to be on the top with Frame.setState(Frame.NORMAL). I don't think there is a way to make a frame to stay always on top.
0
ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

 

Author Comment

by:Kennywen
ID: 10810911
Sorry, i think i should describe more about my current program.

Actually there is only 1 frame in the program but the program can be launch many time. E.g. in console 1 type :java popUp, in console 2 type :java popUp, in console 3 type :java popUp. So this will bring up 3 popUp frame and i want to make the popUp frame in first come first serve sequence. so how can i do it? because currently the order is last come first serve..

thanks


0
 
LVL 14

Expert Comment

by:StillUnAware
ID: 10810931
I meant something like that:

import java.awt.Frame;
import javax.swing.JFrame;

public class FrameOnTop {
  public static void main(String[] args) {
    JFrame frame = new JFrame("Loaded 1st");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
    JFrame frame2 = new JFrame("Loaded 2nd");
    frame2.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame2.setLocation(100,100);
    frame2.setVisible(true);
    frame.setState(Frame.ICONIFIED);
    frame.setState(Frame.NORMAL);
  }
}
0
 
LVL 14

Accepted Solution

by:
StillUnAware earned 25 total points
ID: 10810941
Sorry, you cant know anything about two programs running independently, cause Java won't allow to disturb any other programs to run. But again, you may do a trick, for example make a file or some other way write down how many active windows are running and then read the information and take actions accordingly.
0
 

Author Comment

by:Kennywen
ID: 10810960
Actually in the program only content one frame
0
 

Author Comment

by:Kennywen
ID: 10810990
Sorry, repeat my question:

Actually there is only 1 frame in the program but the program can be launch many time. E.g. in console 1 type :java popUp, in console 2 type :java popUp, in console 3 type :java popUp. So this will bring up 3 popUp frame and i want to make the popUp frame in first come first serve sequence. so how can i do it? because currently the order is last come first serve..

thanks
0
 
LVL 14

Expert Comment

by:StillUnAware
ID: 10811105
My last comment explains that you can not know if other programs are running, although they are all the same.
Eg.:
you run java popUp, the frame is acitve and on top,
you run 2nd time java popUp,  the frame is acitve and on top, but you can not know anything about the first already running, you can achieve this only by writing down (to file?) about how many progrms already launched and take actions accordingly to the information you have read.
0
 

Author Comment

by:Kennywen
ID: 10811142
i don't need to know there is other programs is running or not.
i just want to send the frame to back whenever i run the program.
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 10811744
You do need a handle to the other instances of the running programs for that. I don't think that you can do it without that.
0
 
LVL 24

Expert Comment

by:sciuriware
ID: 10811936
What is wrong with the solution I gave you in http://oldlook.experts-exchange.com:8080/Programming/Programming_Languages/Java/Q_20950824.html

And why don't you close questions but start asking them again?

Thrifty on points?

;JOOP!
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 10813761
Ah, I see.... Kennywen, its better to let discussions related to the same problem continue on one page. If you are not satisfied with the answers on a page, you should post on that page and let the experts know what is it that you don't understand. If you fear that the question is now old and that other experts will not post on it, then you can just provide a link to that question in a new one. You don't need to re-ask the same question. Its better to allow all discussions be on one single page.
0
 

Author Comment

by:Kennywen
ID: 10820582
ok, sorry
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how do i compare an object based on two fields 6 54
eclipse shortcuts 9 55
Groovy problem when using SOAPUI : DispatchException occurred 7 46
hibernate insert example 13 29
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This video teaches viewers about errors in exception handling.

810 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