• Post Reply Bookmark Topic Watch Topic
  • New Topic

select JTextArea - what am i doing wrong  RSS feed

 
simcel jones
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello
thanks for reading this
I am trying to select some text in a JTextArea
the following code compiles and runs fine
however the text is not selected
what am i doing wrong
many thanks

import java.awt.*;
import javax.swing.*;
public class SearchText1 extends JFrame
{
JTextArea textarea;
public SearchText1()
{
setDefaultCloseOperation(EXIT_ON_CLOSE);
Container holder=this.getContentPane();
holder.setLayout(new BorderLayout());
textarea=new JTextArea();
textarea.setText("hello my name is simon");
holder.add("Center",textarea);
findChar();
}
public void findChar(){
System.out.println("select called");
textarea.select(5,10);
}
public static void main(String args[])
{
SearchText st = new SearchText();
st.setSize(400,500);
st.show();
}
}
 
Ashwin Desai
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I just executed your code and when the frame opens, the text is selected !!
I am using JDK1.2.2 on a windows Nt workstation.
Ashwin.
[This message has been edited by Ashwin Desai (edited May 03, 2001).]
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!