469,349 Members | 1,528 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,349 developers. It's quick & easy.

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?

Expand|Select|Wrap|Line Numbers
  1. public static void main(String[] args){
  2.          JFrame frame = new JFrame("Pearson Warranty");
  3.          frame.setResizable(false);
  4.          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  5.      frame.setAlwaysOnTop(false);
  6.          Dimension screenSize =
  7.                     Toolkit.getDefaultToolkit().getScreenSize();
  8.          frame.setLocation(screenSize.width/2 - (400/2),
  9.                     screenSize.height/2 - (400/2));
  10.  
  11.         // Get additional frame information
  12.          PearsonWarrantyGUIpanel mainPanel = new PearsonWarrantyGUIpanel();
  13.  
  14.          frame.getContentPane().add(mainPanel);
  15.          frame.pack();
  16.          frame.setVisible(true);
  17.       }
Jul 7 '08 #1
9 11355
Dököll
2,364 Expert 2GB
Hey there!

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

Stay tuned if that does not help....
Jul 8 '08 #2
JosAH
11,448 Expert 8TB
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
Jul 8 '08 #3
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
Jul 8 '08 #4
JosAH
11,448 Expert 8TB
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
Jul 8 '08 #5
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
Jul 9 '08 #6
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.
Jul 9 '08 #7
JosAH
11,448 Expert 8TB
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
Jul 10 '08 #8
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? >_<
Jul 10 '08 #9
JosAH
11,448 Expert 8TB
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 ;-)
Jul 10 '08 #10

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

Shinzon
5 posts views Thread by Shinzon | last post: by
Shinzon
5 posts views Thread by Shinzon | last post: by
3 posts views Thread by coffeetime | last post: by
3 posts views Thread by coffeetime | last post: by
2 posts views Thread by zahit | last post: by
6 posts views Thread by gaya3 | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.