nasty bug under IE/JVM1.5 - component sizing?

B

bugbear

I have a small and pretty simple applet. It's little more than a single
(nested) dialog.

Under IE 6.0.28 with JVM1.5 some sub-components
of the dialog have the wrong sizes (too small).

looking around the structure, all manner of
"strange" numbers have ended up in min/max/pref
size(). 2 identical sub-elements of a Panel
have different sizes from each other!?

The applet works fine with JVM1.4 on the same IE,
and works fine under JVM1.5 with all other browsers.

I only get bad behaviour in the 1 combination.

I can go into more detail, but does
any body recognise anything from this
over-view description?

BugBear

P.S. If anyone cares, I wrote this to dump the size tree.

private void spc(int i) {
for(int ii = 0; ii < i * 2; ii++) {
System.out.print(" ");
}
}

String r(String lab, java.awt.Rectangle rect) {
return lab + "[x=" + rect.x + ",y=" + rect.y +
",width=" + rect.width + ",height=" + rect.height + "]";
}

String d(String lab, java.awt.Dimension d) {
int h = d.height;
int w = d.width;
if(h <= 0 && w <= 0) {
return lab + "[MIN]";
}
if(h >= 32767 && w >= 32767) {
return lab + "[MAX]";
}
return lab + "[h=" + d.height + ",w=" + d.width + "]";
}
void showBounds(int lead, java.awt.Component comp) {
spc(lead);
System.out.println("" + comp.getClass() + ":" + r("",comp.getBounds()));
spc(lead);
System.out.print(d("size",comp.getSize()));
System.out.print(d(",pref_size",comp.getPreferredSize()));
System.out.print(d(",min_size",comp.getMinimumSize()));
System.out.println(d(",max_size",comp.getMaximumSize()));
if(comp instanceof java.awt.Container) {
java.awt.Container cont = (java.awt.Container)comp;
spc(lead);
int c = cont.getComponentCount();
System.out.println("{" + c);
for(int i = 0; i < c; i++) {
showBounds(lead + 1, cont.getComponent(i));
}
spc(lead);
System.out.println("}");
}
}
 
B

bugbear

bugbear said:
I have a small and pretty simple applet. It's little more than a single
(nested) dialog.

Under IE 6.0.28 with JVM1.5 some sub-components
of the dialog have the wrong sizes (too small).

looking around the structure, all manner of
"strange" numbers have ended up in min/max/pref
size(). 2 identical sub-elements of a Panel
have different sizes from each other!?

The applet works fine with JVM1.4 on the same IE,
and works fine under JVM1.5 with all other browsers.

I only get bad behaviour in the 1 combination.

Well, I've fixed my problem, but my diagnosis
is partial.

It appears that GridBagLayout in the containing
container was calling setBounds() on my item, with some
"unpleasant" numbers.

Later it calls setBounds() again, with some
properly (as per documentation) calculated numbers.

Sadly, my Component class starts with a
defined preferred and minimum size, but IF
setBounds is called, updates pref and min
to reflect to setBounds() numbers.
Unwise, perhaps, but not wrong.

This means the first call from GridBagLayout
to my setBounds() does permanent damage.

The fix (of course) was for my class to retain
its perf and min size, independant of setBounds()
calls.

But there shouldn't be that first (nasty)
call.

Hoping this information helps someone else.

BugBear
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top