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

Discussion in 'Java' started by bugbear, Jul 12, 2005.

  1. bugbear

    bugbear Guest

    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("}");
    }
    }
     
    bugbear, Jul 12, 2005
    #1
    1. Advertising

  2. bugbear

    bugbear Guest

    bugbear wrote:
    > 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
     
    bugbear, Jul 13, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dejan Vesic
    Replies:
    1
    Views:
    678
    Chee Seong Ong
    Jul 3, 2003
  2. Larry Barowski
    Replies:
    2
    Views:
    714
    Tor Iver Wilhelmsen
    Sep 11, 2004
  3. tarmat
    Replies:
    4
    Views:
    328
    Marko Becirevic
    Dec 16, 2003
  4. Zygmunt Krynicki
    Replies:
    5
    Views:
    431
    Zygmunt Krynicki
    Sep 19, 2003
  5. Dieter Maurer
    Replies:
    0
    Views:
    267
    Dieter Maurer
    May 21, 2004
Loading...

Share This Page