Keeping windows in front

I want to be able to force windows like JOptionPanes, JFileChoosers, etc. to be place in front of the main window of my program. The problem is that the class that calls the 'show' methord of the new windows is not necessarily a Component object. So when I call methords like ShowMessageDialog, I can only use null as the paramenter value for the Component.

Try this:
Frame main = null;
Frame[] instantiated = Frame.getFrames();
for(int i=0;i < instantiated.length && main==null;i++) {
  // you need to identify your main frame somehow,
  // maybe through the caption or the class
  if(f.getCaption().equals("My Main Window")) {
main = f[i];
JOptionPane.showMessageDialog(main, "A message");
Hope that helps

Similar Messages

  • How can I keep windows in front while using other apps?

    I want to keep a Preview window in front of all windows while I work in photoshop, how can I do that? I know it is possible, because I saw an artist do it on youtube. He had his references opened up in Preview, while working photohsop, and the Preview window some how stays above the Photoshop window. I know I can just have them side by side by using photoshop in window mode, and shtinking it into a half sized window, but I have porblem rotating the canvas and it is just to small to work when it is like that. He mangaed to use phoshop in full window mode (fills the whole screen) and still have his preview window stay in front. I asked him but I got no reply. So I was hoping some here would know.

    Yeah, I was also using Afloat before updating to Lion, but now it seems it is not compatible anymore. Mac should have that function (keep a window on top) built in - such an easy thing and so helpful, much more than all claimed "productivity" apps etc. Linux has it since always...

  • Opening an external link using javascript.  Keeping new window in front

    I am displaying a photo from an external link when called upon from my swf.  When the user clicks a button, up pops a corresponding photo in a new browser window.  After the photo window has opened, if the user clicks another button the photo browser will update but its no longer in front.  I know I need to use the focus() command but cannot figure how to incorporate it into my AS3 code.
    var req=new URLRequest();
    function scrollPanePopulate(event:Event){     
         //create the temp variables
         var calledPhoto=pntxml.row[pointindex].PhotoUrl;
         req=pntxml.row[pointindex].PhotoUrl;
         var jscommand:String = "var newwin=window.open('"+req+"','win','height=400,width=600,left=650,top=50,toolbar=no,scrollbars=yes,location=no');";
         var url:URLRequest = new URLRequest("javascript:" + jscommand +"void(0);"); navigateToURL(url, "_self");
    The above code works great but I want to keep the photo window in front when it is refreshed.  Any suggestions?
    thanks in advance...
    -josh

    var req=new URLRequest();
    function scrollPanePopulate(event:Event){    
         //create the temp variables
         var calledPhoto=pntxml.row[pointindex].PhotoUrl;
         req=pntxml.row[pointindex].PhotoUrl;
         var jscommand:String = "var newwin=window.open('"+req+"','win','height=400,width=600,left=650,top=50,toolbar=no,scrollbars=yes,location=no');";
         var url:URLRequest = new URLRequest("javascript:" + jscommand +"void(0);newwin.focus();");
    navigateToURL(url, "_self"); }
    //  p.s.  you should be using externalinterface class.

  • Any way to keep iChat window in front?

    I was wondering if there is a setting that can be used that would keep the iChat window in front, rather than let other opening windows cover parts of it.

    Hi,
    What setting does your daughter use to do this with then ?
    10:02 PM Thursday; December 30, 2010
    Please, if posting Logs, do not post any Log info after the line "Binary Images for iChat"

  • How bring window to Front?

    Hi again,
    I just have one more question, regarding manipulation the z-order of different stages. As I stated yesterday, I am developing a chat application.
    I have my mainScene bound to an instance of jfxPanel and set this to a Jframe, to register AWT D&D events this way. Receiving a new message,
    i get a notification via a TrayIcon bubble. I attached an action listener to it, that should bring the requested chat window of the specific user to front,
    but it simply doesnt work. How can one basically bring a window in front of all other open windows on the screen in JavaFX? I tried a lot like :
    chatStage.setVisible(true);
    chatStage.toFront();
    responseArea.requestFocus();
    with chatStage being the stage of the chatwindow, and response area being the textarea one can write in..but actually i dont get it...

    Sure...check out this thread:
    How to keep a Stage always on top...
    Basicly I set up a WindowManager that is used to create all new stages, this manager has a collection of all live stages and sets listeners to properties like focus and iconized and handles
    the reordering to the "correct" z-order each time something changes and affects it.
    So each time the focus is changed, I run through all live stages and call .toFront() on them in the order I want them to appear on the z-axis.
    Cheers,
    Nuwanda

  • How to bring the new window in front of old window

    Hi everyone,
    Here is what I have:
    there is a hyperlink on Page1.jsp, which opens another page Page2.jsp through onclick=
    window.open('./faces/Page2.jsp','mywindow','width=500','height=600');
    However, after Page2.jsp is opened in a new window, it is always behind the old window with Page1.jsp. That is, Page1.jsp always gets the focus. I have to click Page2.jsp at windows' bottom bar in order to bring it up.
    How to set Page2.jsp window in front of Page1.jsp window as default?
    Thanks in advance,

    it should have the focus
    jsut tried your code and my browser keeps focused on the other window
    i would be looking elsewhere for your problem
    maybe in your browsers setup?

  • Minimized JFrame window to front

    Hi,
    I having some trouble trying... to bring my frame to the front
    I have a frame( frame1) and a button when clicked opens one more frame ( frame2).
    I always want to make sure that only one frame2 window is open .. so i keep and check and when the button is clicked if frame2 is not opened then open a new instance .. else bring the existing window to Front.
    Now toFront works properly if the frame is open and have some other windows open on top for frame2 ... when i click the button it comes to front... but when I minimize the frame2 window and then i hit the button again .. it doesn't come to the front. I want to make sure that the frame2 window comes back up .. even if it is minimized ...
    Any help would be appreciated ... thanks in advance
    sandsouza

    Only works in 1.5 but
    setAlwaysOnTop
    public final void setAlwaysOnTop(boolean alwaysOnTop)
    throws SecurityExceptionChanges the always-on-top window state. An always-on-top window is a window that stays above all other windows except maybe other always-on-top windows. If there are several always-on-top windows the order in which they stay relative to each other is not specified and is platform dependent.
    This will force your window to be always on top of all other windows.

  • HT4718 I have bought a used mac air 2  which is now running windows .Who ever installed it has given all of the drive capacity over to boot camp.I now want to restore lio but want to know if there isa way of keeping windows as a dual boot .

    Hi. i have bought a two month old Mac air book 11.6 with 64 gb ssd .The previous owner installed windows and I want to reinstall Lion.Is there a way to do this and keep windows as a dual boot system.If so what size partition is best for windows..I am new to apples having always had PC,s .When the previos owner istalled windows he made the whole drive something called bootcamp.Help!! Roy

    Before you do anything else, I would make a copy of the Windows system on to an external hard disk.  Carbon Copy Cloner (CCC) will help you do this.
    Bootcamp partition needs to be set up using Bootcamp Assistant, from within Lion. There are sometimes problems using third party disk management apps, and the partition order is important too.
    I suspect the previous owner should have re-installed his original OS before giving you the computer. Are you saying that there is no Lion on it at present? If so, you will need to get it, or if it was Snow Leopard, the installation disk, from him.   In the latter case, with SL 10.6.8 installed, you can then access MAS to buy Lion.
    Once you have Lion installed you can setup Bootcamp and restore your Windows system to it, from the external disk.

  • Forbid sending window to front after clicking on it.

    I have application with main window in AIR which is maximized on whole screen and a few "small" windows which are created from Window component (Window was the only option 'cause times to time I need move it out of main application) and live above main app window.
    I would like to have main app window always in the back and all other "small" windows in front of it. The problem is that whenever I click on main window system brings it to the front. So the question is how can I force AIR not to bring newly focused window to the front? I tried to set alwaysInFront=true on each "small" window (Window.NativeWindow.alwaysInFront) which worked but in the end it brought other problems and I didn't really liked the fact that they were always above all other application windows.
    I know that I could use NativeWindow.orderToFront() method and after clicking on main app window send it behind all others but all sent windows into front then blink. Perfect would be to suppress default behaviour and don't let system bring clicked window to front.
    Any idea?
    //pyso

    See if any of these provide pointers.
    *Various causes of sleep issues in Macs*
    [Post by Dale Weisshaar|http://discussions.apple.com/message.jspa?messageID=8980488] - general post on sleep issues.
    [Logitech keyboard drivers out of date after updates|http://discussions.apple.com/message.jspa?messageID=8999415]
    [Try safe boot, then rebooting normally|http://discussions.apple.com/thread.jspa?threadID=1906841]
    [Mac OS X: Why your Mac might not sleep or stay in sleep mode|http://support.apple.com/kb/HT1776]
    [A long list of sleep issue reports and comments|http://www.macintouch.com/readerreports/macosx10_4tiger/topic3083.html ]
    Check if third party USB devices or cards are causing problems.

  • [AIR] May I catch "bring window to front" event?

    Hi,
    I wonder who is responsible for bringing windows to front when user click on that window (application contains more Windows components inside). Is it operating system or AIR runtime? Or perhaps AIR runtime send event to operating system which does it? In this case there would be some chance to catch and stop propagation of that event not to let operating system bring that window to front. Am I right? Any idea how to do it?
    //pyso

    This thread explains my experiences with the toFront() method on Windows 98. It works, but only if the frame has been hidden for about 20 seconds.
    http://forum.java.sun.com/thread.jsp?forum=57&thread=426257

  • Keep windows running when macbook closed using dvi-out?

    Is there a way I can keep windows running when I close the lid on my macbook when using dvi out?
    at the moment it goes to sleep and logs me out and the dvi out looses connection and goes dark.

    in jad file add 2 more keys:
    Background - True
    FlipInsensitive - True
    regards
    piter

  • Is it okay to do a bare metal Linux Mint 17 install, or do I need to keep Windows 8 on my SSD drive?

    I will be installing a new Samsung EVO SSD drive in a new T540p.  I really don't use Windows anymore, so I'm wondering if I have to keep Windows 8 on this machine and set up a dual boot with the new Mint 17 on the new SSD - or - can I just install the Mint on the new bare metal SSD?  Can I do this and still have UEFI too?  I'd prefer that.  It would just be Mint 17 on the UEFI SSD.
    Or is this a crazy idea?   My old computer is dual boot and I just don't use the Windows OS anymore.  It's just uselessly using up my drive space.
    Solved!
    Go to Solution.

    The T540p is a really nice machine. I have Windows 8.1 running on mine. The display is fantastic. I'm sure you will really enjoy yours.

  • I just switched from pc to mac.  what is the best way to keep Windows?  Parallel or Boot camp?

    I have just switched from pc to mac.  What is the best way to keep Windows, Parallel of Boot camp?

    Parallels should be able to handle that without any problems.
    There is a version of both of those that will run on the Mac. So you might consider upgrading to that version instead of going with Windows on your Mac.
    Allan

  • How to keep windows unhidden on same Space?

    I use four Spaces on my Macbook. Sometimes when I'm closing a program, it's confirmation or some other modal window will create in a different Space and hide behind all windows there. For example, I close Adobe Premiere in Space 1 but it prompts to save the project. All I see is that Premiere doesn't want to close. I click Premiere and get the bump system sound. Nothing. I have to force quit.
    Now I've learned that those little confirmation windows are appearing in other Spaces. For the above example, the confirm save window is in Space 4 under all the windows there. This doesn't just happen with Premiere. Lots of other programs will do this. It doesn't happen all the time but often enough.
    Is there a way to "Keep windows grouped" or something that will prevent them from slipping off into another desktop instance?

    this shouldn't happen but the responsibility for that lies with particular applications in question. there is no general system setting you can adjust. complain to program developers. some apps have poor spaces integration.
    the only option you can choose on the system level is to assign an app to all spaces. but I don't know if you want to do that.

  • Keeping popup windows in front of NS or IE

    Hello,
    I have the problem of keeping popup windows spawned from an applet in an IE or NS web page in front.
    When the user clicks on the title bar or a scrollbar of a Jtable or the UI of another applet in the web page, NS or IE gains focus and covers up the popup window. There may be multiple popup windows. The "popup" behavior is a requirement.
    How do you make sure that all windows of a particular class (since multiple instances of the windows) are in front of the NS or IE window. The popups can occlude one another but must be in front of Netscape.
    Any ideas? Any URLs for information?
    John F. Richardson

    I used the JPanel on the glasspane technique and it seems to work pretty well
    http://forum.java.sun.com/thread.jsp?forum=57&thread=115498&message=1102428#1102428

Maybe you are looking for

  • Loud fan and metal cracking noise on Macbook Pro 13''?

    I have the late 2011 model Macbook Pro 13''. The problem started out with just a loud fan, the computer started to operate really slowly and just yesterday I started to hear loud metal rattling on the inside. At first it was just when I turned the co

  • How to create epub book in indesign in details.

    I have found lots of time regarding epub in indesign,  but couldn't get full details tutorials on any other blogs.  I would like each and every step in details in indesign. Could you please send me link so I will complete my epub book in indesign.

  • Photos on my iPad are everywhere after latest update?

    I'm not loving the latest update when it comes to iCloud for my photos. For some odd reason I have photos taken on my iPhone which were saved to my IMac appear in the photos section on my iPad. My iPad only has 32GB so I have to meticulously go throu

  • Strange tags

    Hi, I have an application developed in HTMLDB 1.5 and I imported this into an workspace which is in 1.6. The application seems to work fine but I see these strange html tags like <script language="JavaS at the bottom of the page. It varies from page

  • ODIInvokeWebservice and Certificate Error

    Hi, I am trying to call a Third Party web service. It is an https service and when I try to call the service I am getting the following error Invalid Request : javax.xml.ws.WebServiceException: Failed to access the WSDL at: https://xxxxxx?WSDL. It fa