Solved

sendToBack method in frame

Posted on 2004-04-12
14
333 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
 

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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

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:mayankeagle
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:mayankeagle
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

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…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

759 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

18 Experts available now in Live!

Get 1:1 Help Now