JFrame always on top

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jrobinson3k1
    New Member
    • Jul 2008
    • 5

    #1

    JFrame always on top

    Whenever I run my GUI, the frame is pinned as the top window ALWAYS even though I never set it to be like that. I even added in setAlwaysOnTop( false) for good measure (it's default false, right?) and my frame is always on top regardless. Any clues?

    Code:
    public static void main(String[] args){
             JFrame frame = new JFrame("Pearson Warranty");
             frame.setResizable(false);
             frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    	 frame.setAlwaysOnTop(false);
             Dimension screenSize =
                		Toolkit.getDefaultToolkit().getScreenSize();
             frame.setLocation(screenSize.width/2 - (400/2),
                        screenSize.height/2 - (400/2));
          	
            // Get additional frame information
             PearsonWarrantyGUIpanel mainPanel = new PearsonWarrantyGUIpanel();
          	
             frame.getContentPane().add(mainPanel);
             frame.pack();
             frame.setVisible(true);
          }
  • Dököll
    Recognized Expert Top Contributor
    • Nov 2006
    • 2379

    #2
    Hey there!

    Try to set the frame's content Layout to adjust positioning.

    Stay tuned if that does not help....

    Comment

    • JosAH
      Recognized Expert MVP
      • Mar 2007
      • 11453

      #3
      Originally posted by Dököll
      Hey there!

      Try to set the frame's content Layout to adjust positioning.

      Stay tuned if that does not help....
      That surely doesn't help; @OP: what JVM (and version) are you running?

      kind regards,

      Jos

      Comment

      • jrobinson3k1
        New Member
        • Jul 2008
        • 5

        #4
        Originally posted by JosAH
        That surely doesn't help; @OP: what JVM (and version) are you running?

        kind regards,

        Jos
        1.5.0_15

        and since I need to enter 20 characters I have written this line :P

        Comment

        • JosAH
          Recognized Expert MVP
          • Mar 2007
          • 11453

          #5
          Originally posted by jrobinson3k1
          1.5.0_15

          and since I need to enter 20 characters I have written this line :P
          Strange; my Java versions don't show that "always on top" behaviour and they
          shouldn't; any chance for an upgrade? (1.6)

          kind regards,

          Jos

          Comment

          • jrobinson3k1
            New Member
            • Jul 2008
            • 5

            #6
            Originally posted by JosAH
            Strange; my Java versions don't show that "always on top" behaviour and they
            shouldn't; any chance for an upgrade? (1.6)

            kind regards,

            Jos
            I'm also running this program on a Windows 98 machine if that has anything to do with it, but it shouldn't

            Comment

            • jrobinson3k1
              New Member
              • Jul 2008
              • 5

              #7
              OK, well I fixed my problem...sorta . Check this out.

              When I compile and run my program from command line the window ALWAYS stays on top (the problem I've been having).

              Now, I condensed all my files into a jar file and poof! Problem has disappeared. I was planning on eventually making my program a java executable anyway, so as long as it works like this, then I'm happy. But its still odd that when I run it from command line the window is always on top.

              Comment

              • JosAH
                Recognized Expert MVP
                • Mar 2007
                • 11453

                #8
                Originally posted by jrobinson3k1
                OK, well I fixed my problem...sorta . Check this out.

                When I compile and run my program from command line the window ALWAYS stays on top (the problem I've been having).

                Now, I condensed all my files into a jar file and poof! Problem has disappeared. I was planning on eventually making my program a java executable anyway, so as long as it works like this, then I'm happy. But its still odd that when I run it from command line the window is always on top.
                I find this a bit strange; it is as if the properties of the command window are
                inherited by your JFrame; but then again, it shouldn't inherit those things.

                What happens if you run your program from a command line window using either
                java.exe and javaw.exe? The last one doesn't open another console while the
                first one does so.

                Or maybe it's MS Windows 98 itself ...

                kind regards,

                Jos

                Comment

                • jrobinson3k1
                  New Member
                  • Jul 2008
                  • 5

                  #9
                  So the problem seems to be with the Windows 98 console I suppose, because same problem with java, but problem gone with javaw.

                  Isn't it great how computers always make sense? >_<

                  Comment

                  • JosAH
                    Recognized Expert MVP
                    • Mar 2007
                    • 11453

                    #10
                    Originally posted by jrobinson3k1
                    So the problem seems to be with the Windows 98 console I suppose, because same problem with java, but problem gone with javaw.

                    Isn't it great how computers always make sense? >_<
                    Does running java.exe open a new console or is your java program just able to
                    print in the currently opened console? What does javaw.exe do when you run it
                    in an already opened console?

                    I'm afraid we have to point to MS Windows 98 for this all; I can't prove it because
                    I don't run that blasphemy of an OS.

                    kind regards,

                    Jos

                    ps. MS Windows: a 32 bit graphical shell for a 16 bit patch to an 8 bit operating
                    system, written for a 4 bit processor, developed by a 2 bit company that can't
                    stand 1 bit of competition ;-)

                    Comment

                    Working...