-
Bug
-
Resolution: Cannot Reproduce
-
P4
-
None
-
1.2.0
-
sparc
-
solaris_2.6
JDK: 1.2beta4-D
OS: Solaris 2.6
Locale: All
When using JTextArea default constructor (no arguments) to construct an
instance of JTextArea, and set multi lines of text in it, the scroll
bar will has some problem. Following is a program to reproduce it.
=====================CheckJTextArea.java=================================
import java.awt.swing.*;
import java.awt.swing.border.*;
import java.awt.swing.text.*;
import java.awt.accessibility.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.io.*;
public class CheckJTextArea extends JScrollPane implements Runnable {
JTextArea myJTextArea;
JLabel jlabel;
static CheckJTextArea myPanel;
int textLines = 0;
Vector myJComponents;
public static void main(String args[]) {
JFrame f = new JFrame("Check JTextArea");
f.getContentPane().setLayout(new BorderLayout());
myPanel = new CheckJTextArea();
Thread t = new Thread(myPanel, "");
f.getContentPane().add(myPanel, BorderLayout.CENTER);
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
f.setSize(screenSize.width/2, screenSize.height/3);
f.show();
t.start();
}
public void run() {
while(true) {
if (myJTextArea == null) {
continue;
}
if (textLines >= 60) {
myJTextArea.setText("");
textLines = 0;
}
if (textLines % 8 == 0) {
for (int i = 0; i < myJComponents.size(); i ++) {
Font myFont = new Font("Dialog", Font.PLAIN, 12 + 2 * (textLines / 8));
JComponent myJcomponent = (JComponent)myJComponents.elementAt(i);
myJcomponent.setFont(myFont);
myJcomponent.invalidate();
}
validate();
myJTextArea.setText("");
}
myJTextArea.append("ABCDEFGHIJK" + "\n");
textLines ++;
try {
Thread.sleep(1000);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
public CheckJTextArea() {
JPanel mainPanel = new JPanel();
SoftBevelBorder loweredBorder = new SoftBevelBorder(BevelBorder.LOWERED);
EmptyBorder emptyBorder10 = new EmptyBorder(10, 10, 10, 10);
mainPanel.setBorder(new CompoundBorder(loweredBorder, emptyBorder10));
Font boldFont = new Font("Dialog", Font.BOLD, 18);
//setAlignmentX(LEFT_ALIGNMENT);
mainPanel.setAlignmentY(TOP_ALIGNMENT);
JPanel jtextArea = new JPanel();
jtextArea.setLayout(new BoxLayout(jtextArea, BoxLayout.Y_AXIS));
jtextArea.setAlignmentX(LEFT_ALIGNMENT);
jtextArea.setAlignmentY(TOP_ALIGNMENT);
JPanel wrapper = new JPanel(new BorderLayout());
wrapper.setAlignmentX(LEFT_ALIGNMENT);
wrapper.setBorder(loweredBorder);
myJTextArea = new JTextArea();
//myJTextArea.setFont(boldFont);
JScrollPane scroller = new JScrollPane() {
public Dimension getPreferredSize() {
return new Dimension(300, 100);
}
public float getAlignmentX() {
return LEFT_ALIGNMENT;
}
};
scroller.getViewport().add(myJTextArea);
wrapper.add(scroller, BorderLayout.CENTER);
jtextArea.add(wrapper);
mainPanel.add(jtextArea);
getViewport().add(mainPanel);
myJComponents = new Vector();
myJComponents.add(myJTextArea);
}
}
===========================================================================
java CheckJTextArea
wait to see its second cycle fo setting text
jim.hu@prc 1998-05-06
OS: Solaris 2.6
Locale: All
When using JTextArea default constructor (no arguments) to construct an
instance of JTextArea, and set multi lines of text in it, the scroll
bar will has some problem. Following is a program to reproduce it.
=====================CheckJTextArea.java=================================
import java.awt.swing.*;
import java.awt.swing.border.*;
import java.awt.swing.text.*;
import java.awt.accessibility.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.io.*;
public class CheckJTextArea extends JScrollPane implements Runnable {
JTextArea myJTextArea;
JLabel jlabel;
static CheckJTextArea myPanel;
int textLines = 0;
Vector myJComponents;
public static void main(String args[]) {
JFrame f = new JFrame("Check JTextArea");
f.getContentPane().setLayout(new BorderLayout());
myPanel = new CheckJTextArea();
Thread t = new Thread(myPanel, "");
f.getContentPane().add(myPanel, BorderLayout.CENTER);
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
f.setSize(screenSize.width/2, screenSize.height/3);
f.show();
t.start();
}
public void run() {
while(true) {
if (myJTextArea == null) {
continue;
}
if (textLines >= 60) {
myJTextArea.setText("");
textLines = 0;
}
if (textLines % 8 == 0) {
for (int i = 0; i < myJComponents.size(); i ++) {
Font myFont = new Font("Dialog", Font.PLAIN, 12 + 2 * (textLines / 8));
JComponent myJcomponent = (JComponent)myJComponents.elementAt(i);
myJcomponent.setFont(myFont);
myJcomponent.invalidate();
}
validate();
myJTextArea.setText("");
}
myJTextArea.append("ABCDEFGHIJK" + "\n");
textLines ++;
try {
Thread.sleep(1000);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
public CheckJTextArea() {
JPanel mainPanel = new JPanel();
SoftBevelBorder loweredBorder = new SoftBevelBorder(BevelBorder.LOWERED);
EmptyBorder emptyBorder10 = new EmptyBorder(10, 10, 10, 10);
mainPanel.setBorder(new CompoundBorder(loweredBorder, emptyBorder10));
Font boldFont = new Font("Dialog", Font.BOLD, 18);
//setAlignmentX(LEFT_ALIGNMENT);
mainPanel.setAlignmentY(TOP_ALIGNMENT);
JPanel jtextArea = new JPanel();
jtextArea.setLayout(new BoxLayout(jtextArea, BoxLayout.Y_AXIS));
jtextArea.setAlignmentX(LEFT_ALIGNMENT);
jtextArea.setAlignmentY(TOP_ALIGNMENT);
JPanel wrapper = new JPanel(new BorderLayout());
wrapper.setAlignmentX(LEFT_ALIGNMENT);
wrapper.setBorder(loweredBorder);
myJTextArea = new JTextArea();
//myJTextArea.setFont(boldFont);
JScrollPane scroller = new JScrollPane() {
public Dimension getPreferredSize() {
return new Dimension(300, 100);
}
public float getAlignmentX() {
return LEFT_ALIGNMENT;
}
};
scroller.getViewport().add(myJTextArea);
wrapper.add(scroller, BorderLayout.CENTER);
jtextArea.add(wrapper);
mainPanel.add(jtextArea);
getViewport().add(mainPanel);
myJComponents = new Vector();
myJComponents.add(myJTextArea);
}
}
===========================================================================
java CheckJTextArea
wait to see its second cycle fo setting text
jim.hu@prc 1998-05-06