Solved

sendToBack method in frame

Posted on 2004-04-12
14
338 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
[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
  • 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
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 

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

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!

Question has a verified solution.

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

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…
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

726 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