-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.2.0
-
x86
-
windows_95
Name: rk38400 Date: 04/16/98
JTextPane is not working with a large file inside
the pane. If you run this program and feed it a
large file, like Character.java from the jdk sources,
on the command line:
java FilePane Character.java
and then click inside the text pane, it does
bad things:
- the background color is wrong
- the text is garbled visually
Note: this is a bitter disappointment to me
because I've been struggling for a long time with
the AWT TextArea and its limit of 32K on the size
of the contents of a TextArea. I thought this
would be fixed with Swing. Looks like it isn't,
yet. Here's the program source:
import com.sun.java.swing.*;
import com.sun.java.swing.text.*;
import java.awt.*;
import java.io.*;
class FilePane extends JFrame {
public static void main (String [] argv) {
// SystemLAF.setSystemLAF();
String fileName = (argv.length > 0) ? argv[0] : "FilePane.java";
new FilePane(fileName);
}
FilePane (String fileName) {
byte [] contents = null;
setName(fileName);
setSize(600, 500);
try {
FileInputStream FIS = new FileInputStream(fileName);
BufferedInputStream BS = new BufferedInputStream(FIS);
int siz = BS.available();
contents = new byte[siz];
int nread = BS.read(contents, 0, siz);
System.out.println("nread=" + nread);
} catch (Exception e) {
e.printStackTrace();
return;
}
JTextPane textPane = new JTextPane();
textPane.setText(new String(contents));
JScrollPane scroller = new JScrollPane(textPane,
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
JPanel panel = new JPanel();
panel.setLayout(new BorderLayout());
panel.add(scroller, BorderLayout.CENTER);
getContentPane().add(panel);
setVisible(true);
}
}
(Review ID: 28307)
======================================================================
- duplicates
-
JDK-4138673 Graphics coordinate overflow with sizes larger than Short.MAX_VALUE
-
- Closed
-