Solved

sendToBack method in frame

Posted on 2004-04-12
14
337 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
Industry Leaders: 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!

 

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

Independent Software Vendors: 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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Tomcat: Unable to run tomcat service. 2 29
SequenceInputStream example 3 22
wild fly 8 startup error 2 41
spring maven example issues 3 42
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 learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

749 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