JFrame stays unusably small in applet

T

Thomas Richter

Hi folks,

a very strange problem with a program of mine - unfortunately not
reproducible on my machine, but only on the one of the customer. The
code is part of a (signed) applet and opens a JFrame. It simply looks as
follows:

frame = new JFrame("The Title");
frame.setLocationRelativeTo(this);
frame.setSize(800,64);
frame.setVisible(true);

where "this" is the instance of the JApplet. Now, on my machine(s) this
works correctly - opens a JFrame over the JApplet of the correct size.
On the customer's machine, the JFrame remains tiny, so tiny that only
the tile bar is visible, but nothing inside it. As the code is so
incredibly simple, I wonder what might have been gone wrong here.

I'm running a Debian Squeeze with firefox 3.5.16 and java 6 update 29, I
also tested on Windows XP with firefox 3.6.20 and the same java version,
works absolutely perfect, no problem.

Not so on the customer's machine, which is also an XP (but a UK
edition), the same version of firefox (3.6.20), and java 6 update 26 (if
I remember correctly).

I really wonder what is going on here - I'm out of ideas how to debug or
identify the problem. The JFrame is not touched afterwards at all, it is
not resized, not reused etc, the above code is really the only one that
creates and modifies it.

Hope anyone has an idea how to solve this mystery, or at least how to
identify the cause of the problem.

Is there any specific setting of Java or the firefox I should be aware of?

Greetings,
Thomas
 
K

Knute Johnson

Hi folks,

a very strange problem with a program of mine - unfortunately not
reproducible on my machine, but only on the one of the customer. The
code is part of a (signed) applet and opens a JFrame. It simply looks as
follows:

frame = new JFrame("The Title");
frame.setLocationRelativeTo(this);
frame.setSize(800,64);
frame.setVisible(true);

where "this" is the instance of the JApplet. Now, on my machine(s) this
works correctly - opens a JFrame over the JApplet of the correct size.
On the customer's machine, the JFrame remains tiny, so tiny that only
the tile bar is visible, but nothing inside it. As the code is so
incredibly simple, I wonder what might have been gone wrong here.

I'm running a Debian Squeeze with firefox 3.5.16 and java 6 update 29, I
also tested on Windows XP with firefox 3.6.20 and the same java version,
works absolutely perfect, no problem.

Not so on the customer's machine, which is also an XP (but a UK
edition), the same version of firefox (3.6.20), and java 6 update 26 (if
I remember correctly).

I really wonder what is going on here - I'm out of ideas how to debug or
identify the problem. The JFrame is not touched afterwards at all, it is
not resized, not reused etc, the above code is really the only one that
creates and modifies it.

Hope anyone has an idea how to solve this mystery, or at least how to
identify the cause of the problem.

Is there any specific setting of Java or the firefox I should be aware of?

Greetings,
Thomas

I think you have to set the size before you call
setLocationRelativeTo(). The only other possibility I can think of is
that it is too small with whatever font the customer is using and it
won't size correctly. Try just calling pack() and see if that solves it
or pack it, check the size and adjust from there.
 
R

Roedy Green

frame = new JFrame("The Title");
frame.setLocationRelativeTo(this);
frame.setSize(800,64);
frame.setVisible(true);

I use JDialog for pop-up not JFrame. It may just be that you are in
uncharted territory that has not been properly debugged.

see http://mindprod.com/jgloss/jdialog.html

You might be able to track it down by extending JFrame and putting
some instrumentation in setSize and brethren to find out who is
shrinking you.
--
Roedy Green Canadian Mind Products
http://mindprod.com
Capitalism has spurred the competition that makes CPUs faster and
faster each year, but the focus on money makes software manufacturers
do some peculiar things like deliberately leaving bugs and deficiencies
in the software so they can soak the customers for upgrades later.
Whether software is easy to use, or never loses data, when the company
has a near monopoly, is almost irrelevant to profits, and therefore
ignored. The manufacturer focuses on cheap gimicks like dancing paper
clips to dazzle naive first-time buyers. The needs of existing
experienced users are almost irrelevant. I see software rental as the
best remedy.
 
R

Roedy Green

frame.setSize(800,64);

a pack would shrink it. What kind of layout do you have inside the
JFrame? Is it something that would survive a pack?
when use absolute positioning, remember to setLayout(null).
--
Roedy Green Canadian Mind Products
http://mindprod.com
Capitalism has spurred the competition that makes CPUs faster and
faster each year, but the focus on money makes software manufacturers
do some peculiar things like deliberately leaving bugs and deficiencies
in the software so they can soak the customers for upgrades later.
Whether software is easy to use, or never loses data, when the company
has a near monopoly, is almost irrelevant to profits, and therefore
ignored. The manufacturer focuses on cheap gimicks like dancing paper
clips to dazzle naive first-time buyers. The needs of existing
experienced users are almost irrelevant. I see software rental as the
best remedy.
 
T

Thomas Richter

a pack would shrink it. What kind of layout do you have inside the
JFrame? Is it something that would survive a pack?
when use absolute positioning, remember to setLayout(null).

There is absolutely no layout within at all. All I do is to get the
graphics and render some text. I do not call "pack" - there is beyond
the text output nothing else that happens there...

Are there any known settings in firefox or windows or java that would
prevent JFrames from opening the indicated size (yes, the size does fit
onto the monitor of the customer, checked that).

So long,
Thomas
 
M

markspace

There is absolutely no layout within at all. All I do is to get the
graphics and render some text. I do not call "pack" - there is beyond
the text output nothing else that happens there...

Are there any known settings in firefox or windows or java that would
prevent JFrames from opening the indicated size (yes, the size does fit
onto the monitor of the customer, checked that).


Oh... yes, I think there are. FireFox itself can call various methods
on the applet to resize it. Even if you don't normally see it, I'd
assume that the applet is calling some public methods (like pack()) to
try to resize the window.

With no layout, the JFrame might become confused and assume it has a
size of "0,0". That would sure explain the behavior you are seeing.

Can you modify the JFrame to have a layout, and add a subcomponent
that's fixed to the size you want? The normal way to do this is to make
a JPanel subclass, and then to override the JPanel::getPreferredSize()
method to always return the size you want. Within the JPanel you can
use any absolute layout you want.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,737
Latest member
Georgeengab

Latest Threads

Top