Solved

sendToBack method in frame

Posted on 2004-04-12
14
336 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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
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…
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:

766 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