-
Bug
-
Resolution: Duplicate
-
P3
-
None
-
1.1
-
None
-
x86
-
windows_95
Name: mc57594 Date: 01/28/97
/*
This is a simple class using TextArea
by selecting text and then pressing 'p' you should get all
positions correctly. By pressing 'c' the selected text should be
replaced by the string 'huuu'. Works fine under Solaris. Under Win95
works fine on the first line of the text. On another lines you'd have
to correct arguments in replaceRange method what'd cause
non-compatibility on other platforms.
*/
import java.awt.*;
import java.awt.event.*;
public class pok_sel extends Frame implements KeyListener
{TextArea t;
pok_sel()
{
t=new TextArea();
add(t);
pack();
show();
t.addKeyListener(this);
}
public void keyTyped(KeyEvent e)
{
}
public void keyReleased(KeyEvent e)
{
}
public void keyPressed(KeyEvent e)
{
char c=e.getKeyChar();
if(c=='p')
{ e.consume();
System.out.println("selend:"+t.getSelectionEnd());
System.out.println("sel start:"+t.getSelectionStart());
System.out.println("caret:"+t.getCaretPosition());
System.out.println("text:"+t.getSelectedText());
}
if(c=='c')
{
e.consume();
t.replaceRange("huuu",t.getSelectionStart(),t.getSelectionEnd());
}
}
public static void main(String args[])
{
pok_sel p=new pok_sel();
}
}
======================================================================
- duplicates
-
JDK-4072264 getSelectedText, getSelectedStart/End in TextArea class returns wrong
- Closed