I 've run into an problem using some basic awt methods that occurs running under SuSE but NOT under Redhat. Frankly, I don't understand see how this is possible; if I didn't have the benchmarks to prove it, I'm not sure I'd believe it myself. Any thoughts on this (including workarounds) would be greatly appreciated.

The problem is specific to jdk 1.4.*; it does NOT occur with jdk 1.3.1. I have reproduced it with Blackdown 1.4.1, Sun 1.4.0, and IBM 1.4.0, under vanilla installation of SuSE 8.0 and 8.1, with two different x86 processors, an intel III mobile 1133 mhz (in an IBM Thinkpad) and an AMD K7 800 mhz.

Here's the problem: I have an application that resizes a visible frame by calling setPreferredSize() on a JPanel and then calling pack(). The FIRST time the setPreferredSize()-pack() sequence is called, there is a very long delay before the frame is fully redrawn, around 5 SECONDS. With the same OS and hardware, the same sequence takes around 25 MILLIseconds using 1.3.1. Subsequent setPreferredSize()-pack() sequences do not have the delay.

The problem can be demonstrated with a simple test program:


import javax.swing.*;
import java.awt.*;

public class PackDelayTest extends JFrame {

JPanel pan;
int width;

static long tm;

public static void main(String[] argv) {

tm = System.currentTimeMillis();
PackDelayTest test = new PackDelayTest();
elapsed("in constructor");
test.replace(); elapsed("repack 1");
test.replace(); elapsed("repack 2");
test.replace(); elapsed("repack 2");
test.replace(); elapsed("repack 2"); System.exit(0);
}
public PackDelayTest() {
pan = new JPanel();
pan.setLayout(new BoxLayout(pan,BoxLayout.Y_AXIS));
getContentPane().add(pan); JLabel label = new JLabel("Label 0");
pan.add(label); pack();
setVisible(true);
width = pan.getPreferredSize().width;
}
public void replace() { Dimension d = pan.getPreferredSize();
pan.setPreferredSize(new Dimension(++width,d.height)); pack();
}
static void elapsed(String mess) {
long ct = System.currentTimeMillis();
System.out.println("Elapsed milliseconds, " + mess + ": " +
(ct - tm));
tm = ct;
}
}

With jdk 1.3.1 (SuSE 8.1, intel III mobile 1133mhz),
java version "1.3.1_07"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_07-b02)
Java HotSpot(TM) Client VM (build 1.3.1_07-b02, mixed mode)
the output from this program is

Elapsed milliseconds, in constructor: 2226
Elapsed milliseconds, repack 1: 26
Elapsed milliseconds, repack 2: 24
Elapsed milliseconds, repack 2: 25
Elapsed milliseconds, repack 2: 24

With 1.4.1 (and the same OS and hardware),
java version "1.4.1_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_01-b01)
Java HotSpot(TM) Client VM (build 1.4.1_01-b01, mixed mode)
the output is

Elapsed milliseconds, in constructor: 1773
Elapsed milliseconds, repack 1: 5747
Elapsed milliseconds, repack 2: 32
Elapsed milliseconds, repack 2: 7
Elapsed milliseconds, repack 2: 1

Under Redhat (Sun ran these; I don't know the hardware they were using):

On Red Hat Linux 8.0, 1.3.1_06:
Elapsed milliseconds, in constructor: 1999
Elapsed milliseconds, repack 1: 91
Elapsed milliseconds, repack 2: 85
Elapsed milliseconds, repack 2: 86
Elapsed milliseconds, repack 2: 93

On Red Hat Linux 8.0, 1.4.1_01:
Elapsed milliseconds, in constructor: 1968
Elapsed milliseconds, repack 1: 90
Elapsed milliseconds, repack 2: 88
Elapsed milliseconds, repack 2: 88
Elapsed milliseconds, repack 2: 95


I've looked at the source code for pack() and tried various workarounds, but with no success. I'd appreciate any input.

Thanks,

bw


----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to