-
Bug
-
Resolution: Fixed
-
P4
-
1.3.0
-
beta
-
sparc
-
solaris_7
Name: stC104175 Date: 03/28/2000
java version "1.3beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3beta-O)
Java(TM) HotSpot Client VM (build 1.3beta-O-release, 1.3beta-O-release,
interpreted mode)
Steps to reproduce the problem -
1. Start the SwingSet (not SwingSet2) demo
2. Select the "HTML Text" tab
3. Triple click somewhere in the middle of the first line ("Swing Contributors")
Instead of the whole line being selected, the part of the line after the cursor
is selected, and there is a beep. If you triple click on a different line, such
as "New! Here is ...", you'll see the correct behavior.
Here's some source code that sheds a little more light on the matter -
// Begin ClickBug.java
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.text.*;
public class ClickBug
{
public static void main (String[] args)
{
ClickBug cb = new ClickBug ();
}
private JFrame frame;
private JEditorPane pane;
ClickBug ()
{
frame = new JFrame ("Click Bug");
frame.setDefaultCloseOperation
(JFrame.EXIT_ON_CLOSE);
pane = new JEditorPane ();
pane.addMouseListener
(new ClickListener ());
pane.setContentType ("text/html");
pane.setText ("<html><body>" +
"<p>Here is line one</p>" +
"<p>Here is line two</p>" +
"</body></html>");
frame.getContentPane ().add
(new JScrollPane (pane),
BorderLayout.CENTER);
frame.setSize (400, 300);
frame.setVisible (true);
}
class ClickListener extends MouseAdapter
{
public void mouseClicked
(MouseEvent event)
{
try
{
System.out.println
("Caret: " +
pane.getCaretPosition ());
System.out.println
("Line start: " +
Utilities.getRowStart
(pane, pane.getCaretPosition ()));
System.out.println
("Line end: " +
Utilities.getRowEnd
(pane, pane.getCaretPosition ()));
}
catch (BadLocationException blex)
{
blex.printStackTrace ();
}
}
}
}
// End ClickBug.java
Run this and click on the second line - the correct positions are shown.
Then click the first line - the caret position is correct, but the
"findRowStart" call throws a BadLocationException - this is what causes
the beep, and the selection not to go to the start of the line, if you
look at the source for DefaultEditorKit.SelectLineAction and
DefaultEditorKit.BeginLineAction.
(Review ID: 102945)
======================================================================