Name: ddT132432 Date: 10/25/2001
java version "1.4.0-beta2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta2-b77)
Java HotSpot(TM) Client VM (build 1.4.0-beta2-b77, mixed mode)
Odd behavior is experinced when running a JInternalFrame.
Run the following program:
--begin code--
import javax.swing.*;
import java.awt.*;
import javax.swing.text.*;
class test{
test(){
run();
}
void run(){
//Create the JFrame with a JDesktopPane
JFrame jf=new JFrame();
JDesktopPane jdp=new JDesktopPane();
Rectangle rec=new Rectangle(800,500);
jf.getContentPane().add(jdp);
jf.setLocation(0,0);
jf.setBounds(rec);
jf.setVisible(true);
//Create the JInternalFrame, add a JTextPane to it, and
//add the JInternalFrame to the JFrame
JInternalFrame jif=new JInternalFrame("test",true,true,true);
JTextPane jtp=new JTextPane();
JScrollPane jsp=new JScrollPane(jtp);
jif.getContentPane().add(jsp);
jif.setBounds(new Rectangle(0,0,600,400));
jdp.add(jif);
Document d=jtp.getDocument();
try{
d.insertString(0,"\n\n\n\n\n\n\n\n\n\nhello world",null);
}
catch(Exception e){}
jif.setVisible(true);
}
public static void main(String[] args){
test t=new test();
}
}
--end code--
When you click on the JInternalFrame icon to maximize the frame, you will
notice that "hello world" has been echoed in the top of the JTextPane - which
shouldn't happen. This only seems to happen when text is inserted into the
JTextPane when the JInternalFrame is initially invisible. This is probably a
bug inside the JScrollPane class since adding a JTextPane to the JInternalFrame
without a JScrollPane does not cause the problem.
(Review ID: 134387)
======================================================================