-
Bug
-
Resolution: Cannot Reproduce
-
P4
-
None
-
2.0, 1.1.5, 1.1.6, 1.2.0
-
x86
-
windows_95, windows_nt
Name: bk70084 Date: 03/30/98
Under Win32 of JDK1.1.5, the TextArea ScrollBars both forward MousePressed
events to the TextArea. This has the effect of randomly selecting text when the
TextArea is scrolled.
Run the following test case, and use either scrollbar. The scrollbars do work, but
the TextArea also interprets the mouse click as text selection, and since the mouse
pointer is below the valid text display area, the TextArea is auto-scrolled while
text is selected.
//----------------------TextAreaBug.java-------------------------
import java.awt.*;
import java.awt.event.*;
// reproduces the unwanted selection of text in the text area and
// the shifting of horizontal scroll bar as you scroll down
// Win95, jdk 1.1.5
public class TextAreaBug extends Frame {
private static final String NEWLINE = System.getProperty("line.separator");
TextArea textFile;
public TextAreaBug() {
textFile = new TextArea(25, 50);
textFile.setEditable(false);
setLayout(new BorderLayout());
setFont(new Font ("Courier", Font.BOLD, 14));
// display selected file in text area
String line;
for (int i = 0; i < 100; i++) {
line = "This is line number " + i + " to be appended to the text are
a.";
textFile.append(line);
textFile.append(NEWLINE);
}
//Put a text area in the center of the window.
add("Center", textFile);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
textFile.addComponentListener(new ComponentListener() {
public void componentHidden(ComponentEvent e) {
System.out.println("componentHidden " + e);
}
public void componentMoved(ComponentEvent e) {
System.out.println("componentMoved " + e);
}
public void componentResized(ComponentEvent e) {
System.out.println("componentResized " + e);
}
public void componentShown(ComponentEvent e) {
System.out.println("componentShown " + e);
}
});
textFile.addFocusListener(new FocusListener() {
public void focusGained(FocusEvent e) {
System.out.println("focusGained " + e);
}
public void focusLost(FocusEvent e) {
System.out.println("focusLost " + e);
}
});
textFile.addKeyListener(new KeyListener() {
public void keyPressed(KeyEvent e) {
System.out.println("keyPressed " + e);
}
public void keyReleased(KeyEvent e) {
System.out.println("keyReleased " + e);
}
public void keyTyped(KeyEvent e) {
System.out.println("keyTyped " + e);
}
});
textFile.addMouseListener(new MouseListener() {
public void mouseClicked(MouseEvent e) {
System.out.println("mouseClicked " + e);
}
public void mouseEntered(MouseEvent e) {
System.out.println("mouseEntered " + e);
}
public void mouseExited(MouseEvent e) {
System.out.println("mouseExited " + e);
}
public void mousePressed(MouseEvent e) {
System.out.println("mousePressed " + e);
System.out.println("Size: " + textFile.getSize());
System.out.println("contains: " + textFile.contains(e.getPoint()
));
//e.consume(); // uncommenting this line works as a partial fix
}
public void mouseReleased(MouseEvent e) {
System.out.println("mouseReleased " + e);
}
});
textFile.addMouseMotionListener(new MouseMotionListener() {
public void mouseDragged(MouseEvent e) {
System.out.println("mouseDragged " + e);
}
public void mouseMoved(MouseEvent e) {
System.out.println("mouseMoved " + e);
}
});
System.out.println("Size: " + textFile.getSize());
}
public static void main(String args[]) {
TextAreaBug tab = new TextAreaBug();
tab.setTitle("Bug Check");
tab.pack();
tab.setVisible(true);
}
}
(Review ID: 27029)
======================================================================