473,395 Members | 1,681 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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 11794
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

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

Similar topics

1
by: Tuno | last post by:
I'm relatively new to Java Swing programming. I have a console application that processes text files and while doing so I want to suspend the execution when an error is encountered that requires...
5
Shinzon
by: Shinzon | last post by:
ok so far I have got: JFrame frame = new JFrame( "Matt's DVD's" ); frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); frame.setSize( 420, 170 ); // set frame size ...
5
Shinzon
by: Shinzon | last post by:
Ok so I have been working on this for a moment now and wondering how to add multiple jlabels to a jframe. the code looks like this: JLabel jl = new JLabel("DVD ID #= " + dvd); //Displays DVD...
3
by: coffeetime | last post by:
Hi, I just decided to learn java, so I'm quite a noob. I use the book learning java third edition. have JDK 1.6 program in notepad. I have made the simple HelloJava example, and now i wanted to...
3
by: coffeetime | last post by:
Hi, I just decided to learn java, so I'm quite a noob. I use the book learning java third edition. have JDK 1.6 program in notepad. I have made the simple HelloJava example, and now i wanted to...
2
by: zahit | last post by:
hi guys, my line doesn't appear on the frame. what's the problem? import java.util.*; import java.io.*; import javax.swing.JFrame; import javax.swing.JPanel; import java.awt.*; public class...
6
by: gaya3 | last post by:
Hi, I need to make the frame invisible on action event in swings. I have the following code: public class sample_pgm extends JFrame{ public void sample() { JFrame jf =...
1
by: Gimzo | last post by:
Hi, I'm trying to create a button that opens a new window for setting up a whole crapload of constants for an analysis program. For this, I have a JButton. The actionPerformed-method activates...
1
by: sibusiso | last post by:
HI Can anyone help with the scenario where where you have to pass a certain data from one JFrame to another. For example, suppose you have a JFrame is your main window you disabled your Jmenu...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.