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.

Similar Messages

  • 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 resize a custom tree node like you would a JFrame window?

    Hello,
    I am trying to resize a custom tree node like you would a JFrame window.
    As with a JFrame, when your mouse crosses the Border, the cursor should change and you are able to drag the edge to resize the node.
    However, I am faced with a problem. Border cannot detect this and I dont want to use a mouse motion listener (with a large number of nodes, I fear it will be inefficient, calculating every node's position constantly).
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.Component;
    import java.awt.Dimension;
    import java.awt.Insets;
    import java.util.EventObject;
    import javax.swing.BorderFactory;
    import javax.swing.Box;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTextArea;
    import javax.swing.JTree;
    import javax.swing.tree.DefaultMutableTreeNode;
    import javax.swing.tree.DefaultTreeCellEditor;
    import javax.swing.tree.DefaultTreeCellRenderer;
    import javax.swing.tree.DefaultTreeModel;
    import javax.swing.tree.TreeSelectionModel;
    public class ResizeNode extends JPanel {
           AnilTreeCellRenderer2 atcr;
           AnilTreeCellEditor2 atce;
           DefaultTreeModel treeModel;
           JTree tree;
           DefaultMutableTreeNode markedNode = null;
         public ResizeNode() {
                super(new BorderLayout());
                   treeModel = new DefaultTreeModel(null);
                   tree = new JTree(treeModel);          
                  tree.setEditable(true);
                   tree.getSelectionModel().setSelectionMode(
                             TreeSelectionModel.SINGLE_TREE_SELECTION);
                   tree.setShowsRootHandles(true);
                  tree.setCellRenderer(atcr = new AnilTreeCellRenderer2());
                  tree.setCellEditor(atce = new AnilTreeCellEditor2(tree, atcr));
                   JScrollPane scrollPane = new JScrollPane(tree);
                   add(scrollPane,BorderLayout.CENTER);
         public void setRootNode(DefaultMutableTreeNode node) {
              treeModel.setRoot(node);
              treeModel.reload();
           public static void main(String[] args){
                ResizeNode tb = new ResizeNode();
                tb.setPreferredSize(new Dimension(400,200));
                  JFrame frame = new JFrame("ResizeNode");
                  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                  frame.setContentPane(tb);
                  frame.setSize(400, 200);
                  frame.pack();
                  frame.setVisible(true);
                  tb.populate();
         private void populate() {
              TextAreaNode2 r = new TextAreaNode2(this);
               setRootNode(r);
               TextAreaNode2 a = new TextAreaNode2(this);
               treeModel.insertNodeInto(a, r, r.getChildCount());          
    class AnilTreeCellRenderer2 extends DefaultTreeCellRenderer{
    TreeBasic panel;
    DefaultMutableTreeNode currentNode;
      public AnilTreeCellRenderer2() {
         super();
    public Component getTreeCellRendererComponent
       (JTree tree, Object value, boolean selected, boolean expanded,
       boolean leaf, int row, boolean hasFocus){
         TextAreaNode2 currentNode = (TextAreaNode2)value;
         NodeGUI2 gNode = (NodeGUI2) currentNode.gNode;
        return gNode.box;
    class AnilTreeCellEditor2 extends DefaultTreeCellEditor{
      DefaultTreeCellRenderer rend;
      public AnilTreeCellEditor2(JTree tree, DefaultTreeCellRenderer r){
        super(tree, r);
        rend = r;
      public Component getTreeCellEditorComponent(JTree tree, Object value,
       boolean isSelected, boolean expanded, boolean leaf, int row){
        return rend.getTreeCellRendererComponent(tree, value, isSelected, expanded,
         leaf, row, true);
      public boolean isCellEditable(EventObject event){
        return true;
    class NodeGUI2 {
         final ResizeNode view;
         Box box = Box.createVerticalBox();
         final JTextArea aa = new JTextArea( 1, 5 );
         final JTextArea aaa = new JTextArea( 1, 8 );
         NodeGUI2( ResizeNode view_ ) {
              this.view = view_;
              box.add( aa );
              aa.setBorder( BorderFactory.createMatteBorder( 0, 0, 1, 0, Color.GREEN ) );
              box.add( aaa );
              box.setBorder( BorderFactory.createMatteBorder( 5, 5, 5, 5, Color.CYAN ) );
         private Dimension getEditorPreferredSize() {
              Insets insets = box.getInsets();
              Dimension boxSize = box.getPreferredSize();
              Dimension aaSize = aa.getPreferredSize();
              Dimension aaaSize = aaa.getPreferredSize();
              int height = aaSize.height + aaaSize.height + insets.top + insets.bottom;
              int width = Math.max( aaSize.width, aaaSize.width );
              if ( width < boxSize.width )
                   width += insets.right + insets.left + 3;     // 3 for cursor
              return new Dimension( width, height );               
    class TextAreaNode2 extends DefaultMutableTreeNode {  
         NodeGUI2 gNode;
         TextAreaNode2(ResizeNode view_) {     
              gNode = new NodeGUI2(view_);
    }

    the node on the tree is only painted on using the
    renderer to do the painting work. A mouse listener
    has to be added to the tree, and when moved over an
    area, you have to determine if you are over the
    border and which direction to update the cursor and
    to know which way to resize when dragged. One of the
    BasicRootPaneUI has some code that can help determine
    that.Thanks for replying. What is your opinion on this alternative idea that I just had?
    I am wondering if it might be easier to have a toggle button in the node that you click when you want to resize the node. Then a mouse-down and dragging the mouse will resize the node. Mouse-up will reset the toggle button, and so will mouse down in an invalid area.
    Anil

  • 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

  • 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?

  • How to set the fix size jframe window

    when I run the jframe ,the jframe window size is very small
    1)how to set the fix size jframe window??
    2)how to set the jframe cannot change the window size??
    thx~~

    1. You can set the size by calling JFrame's method setSize. There are two versions of this method: (1) setSize(int width, int height) and (2) setSize(Dimension d). Note, that when you use this method to set the frame size, you don't have to call JFrame's pack method.
    2. JFrame has a method called setResizable(boolean resizable) which you can call with the argument false.
    Without any ill intent, these questions are regarding something that is very easily answered by looking at the documentation for the JFrame class. I suggest to anyone working with swing to at least look briefly through the base classes they're extending before giving up. In my experience it is always more gratifying to figure things out on my own than asking someone. But please don't take this the wrong way, I respect people who seek out help in order to further their knowledge, instead of just giving up.

  • If Adobe Digital Edition 4.0.3 is open and no book is opened, it crashes when minimizing the window

    I am trying to find a fix for this issue and I saw on a lot's of post, that people are having the same problem as I am with Adobe Digital Edition 4.0.3. If I open Adobe Digital Editions 4.0.3 with no book opened and I minimized the window, then it crashes and it give's me the following error message:

    note to moderator -   this is MY response to MY own posting.  How can this be a duplicate.
    success.  ADE 4.0 is to be avoided. It crashed after my solution.
    The solution is trash the activation.dat preference file.
    Navigate to /Users//Library/Application Support/Adobe/Digital Editions and drag the activation.dat file to the trash.
    If you are using 10.7, see Access hidden library files | Mac OS 10.7 and later.
    I reinstalled ADE 3.0 and life is good.
    The Error getting License. License Server Communication Problem: E_ACT_NOT_READY

  • 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.

  • How to blink the tab of a minimized JFrame?

    Hi,
    I am creating a chat software. When a message comes for a specific jframe, how can we start that minimized jframe to blink. In this way, the user knows that message has arrived.
    Thanks
    Karar Haider

    you need to use the Frame.setIconImage() method to change the icon.
    in order to flash the icon use something like this (this is for a flashing JLabel, but you can easily change that to flash the icon):
    public class FlashLabel extends JLabel implements Runnable {
        public static final int NORMAL_COLOR = 0,
                                FLASH_COLOR = 1;
        private Color           colors[] = new Color[2];
        private int             well = 500;
        public FlashLabel(String text, int horizontalAlignment) {
            super(text, horizontalAlignment);
            colors[NORMAL_COLOR] = getBackground();
        public void setFlashColor(Color c) {
            colors[FLASH_COLOR] = c;
            setOpaque(true);
        public void startFlashing() {
            Thread t = new Thread(this);
            t.start();
        public void setTime(int t) { well = t; }
        public int getTime() { return well; }
        public void run() {
            int current = 0;
            try {
                while (true) {
                    setBackground(colors[current]);
                    current ^= 1;
                    Thread.currentThread().sleep(well);
            } catch (InterruptedException e) { return; }
    }you could also add a ComponentListener to your frame to get informed if and when your frames gets iconized in order to do the flashing only if the frame really is minimized.
    thomas

  • Problems with Audio Stutter when moving minimizing/maximizing windows

    I am using an Emu 1820m (ASIO driver) with AA3.0. I'm using the same ASIO driver mode in both edit and multi-track view.
    In multi-track view, I can have several tracks going (i.e., 24 tracks as I type this) and the audio is fairly rock solid. I can go to other programs, move windows around, minimize/maximize windows, etc. and the audio is glitch free. This is while running the Emu 1820m at 48k/24-bit and 2ms latency!
    However, in the single edit view, this is another story. When I have an audio playing in the edit view, I get many audio glitches with audio events. The worst is when I minimize/maximize any window (not just AA3). I get a "brzzzzzt" while the window minimizes/maximizes. I can make this stop by disabling animations when minimizing/maximizing windows; however, why does mult-track view behave fine even with animations on?
    Also, in single edit view, moving windows around causes a lot of dropouts in audio (but again, not in multi-track view.)
    Can anyone shed any light as to what is going on here?
    A very extreme case to show the problem even further:
    In multi-track view, load up some tracks and play them. Now run dxdiag (while the multi-tracks are playing) and on the display tab, run the Direct3D tests. Even with the Direct3D tests running, the AA3.0 audio plays flawlessly while in multi-track mode. Now, play a file in Edit mode. Do the same test with dxdiag while the file is playing - GLITCH CITY!
    This doesn't happen in other audio programs I have (i.e., Sound Forge, Sonar, etc.)
    Please, someone, shed some light on this issue!
    My system is:
    + Intel Q6600 2.4 quad core G0 stepping @ 3.20
    + Arctic pro freezer 7 cooler
    + 4 gigs (2 sticks of 2 gigs) of G.Skill DDR2 1066 ram (PC2 8500)
    + Gigabyte GA-EP35-DS3P Mobo
    + Gigabyte Nvidia GeForce 8600GTS 256MB PCI Express graphics
    + Rosewill RP600V2-S-SL 600W SLI Ready-ATX12V V2.01 PSU
    + Seagate Barracuda ES.2 250GB 7200 RPM SATA 3.0Gb/s Hard Drive (system)
    + Seagate Barracuda ES.2 250GB 7200 RPM SATA 3.0Gb/s Hard Drive (user/recording)
    + Seagate Barracuda 7200.11 500GB 7200 RPM SATA 3.0Gb/s Hard Drive (samples)
    + Seagate Barracuda 7200.11 750GB 7200 RPM SATA 3.0Gb/s Hard Drive (backup)
    + Emu 1820m PCI Audio
    + Sunbeam Silent Storm IC-SS-SVBK Case
    + SAMSUNG 20X DVD±R DVD Burner Model SH-S203N
    + Windows XP Pro SP2

    SteveG, I don't believe it is an 1820m issue at all. Do you have a single or multi-core processor? This behavior did not occur on my old P4 3GHz system. I only started observing it when I built this quad core system about a month ago.
    By the way, today I replaced my mobo with one of the same brand and model and the behavior still exists (to rule out a defective mobo.) I've also tried 3 different video cards (although they were all NVIDIA) and the problem remains no matter which card I use.
    Durin,
    As I was typing the first post, I verified that I was using the Emu 1820m ASIO driver in both Edit and Multitrack views. (As I was writing it, it crossed my mind that I might have it set to something else in one mode.) However, it is the same in both.
    One thing I forgot to mention is that there is one more app that behaves similarly (Reaper). All other apps (Sonar, FL Studio, eXT, Ableton Live, Sound Forge, Wavosaur) do not show this behavior and are rock solid.
    If you'd like to see my thread about this behavior in Reaper (and others who can reproduce it) see here: http://www.cockos.com/forum/showthread.php?t=19036
    I believe Sonar, FL Studio, eXT, Ableton Live, Sound Forge, Wavosaur, etc.. are doing something properly when playing back audio and/or initializing plugins that Adobe Audition and Reaper are failing to do properly with certain hardware configurations.
    -Clayton

  • Jframe window not closing

    Hi can anyone plz tell me how i will close my jframe window..
    I have a button called EXIT,clicking which i want to close my Frame...
    I am writiing setvisible(false) but thats not working..

    use
    System.exit(0);
    All the best

  • After Firefox update, my gmails open up in separate instances of minimized Firefox windows. Any suggestions?

    After an automatic Firefox update, my gmails started to open up in separate instances of minimized Firefox windows. The former way was that any email I clicked on would open full screen in the same instance of Firefox and in the same maximized window. Any suggestions on how to get back to the former way?

    First, try to update to the recently released Firefox 15, see if that resolves your issue. [[Update Firefox to the latest version]].
    If it doesn't, try to Reset Firefox.
    To Reset Firefox do the following:
    #Go to Firefox > Help > Troubleshooting Information.
    #Click the "Reset Firefox" button.
    #Firefox will close and reset. After Firefox is done, it will show a window with the information that is imported. Click Finish.
    #Firefox will open with all factory defaults applied.
    Further information can be found in the [[Reset Firefox – easily fix most problems]] article.
    Did this fix your problems? Please report back to us!

  • 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"

  • JFrame window

    How to create Jframe Window using swings

    solution wrote:
    How to create Jframe Window using swingsGosh, if only.
    If only Sun had tutorials that we could read and learn about how to do Java and Swing coding. I know that it's only a pipe-dream, but it's a dear one.

Maybe you are looking for

  • Problem with Price

    hello here is my problem say i have an amount of 8,765.43, some times in sap this value is comming as 8.765,43 i mean to say its displaying . in the place of , and , in the palce of . now if my value is displayed like 8.765,43 how can i change this t

  • Navigation Issue - popup

    Hi experts,   I have two windows ,one is mainwindow and another one is popup window.   In the main window I have two views,first views action button calls the popup window. On clicking OK from popup i need to display second view of  main window. I in

  • How to use circular linked list in pl/sql?

    Hi all, how to use the circular linked list on pl/sql programming. thanks in advance Rgds, B@L@

  • I Need Sales Order Status Reports using ALV

    Hi I Need Sales Order Status Reports using ALV.

  • WRT54G Ver 6 Internet connectivity problems

    Alright so here's the deal. I'm on Windows XP with Verizon DSL (in Orange County, CA) that uses a Westell modem (just modem, not modem and router combo). I have the old Linksys BEFSR41 v.2 router that runs with everything fine. I just bought the WRT5