Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4028474

java.awt.TextArea.replaceRange(String,int,int)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 1.1
    • client-libs
    • 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();
      }
      }
      ======================================================================

            ehawkessunw Eric Hawkes (Inactive)
            mchamnessunw Mark Chamness (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: