File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to read perticular line in jtextarea

 
Sarafaraj Shaikh
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
dear friends
i am trying to develop desktop application.which reading data from input serial port and send entered keyboard data to serial port and simultaneously display in jtextarea. I am using netBean gui and RXTX for it. It work properly when data entered at console window of netBean. But not take data from keyboard as it run out of IDE.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> how to read perticular line in jtextarea
> and simultaneously display in jtextarea...It work properly when data entered at console window of netBean. But not take data from keyboard as it run out of IDE.

your subject line and post don't match - exactly what's the problem?
 
Sarafaraj Shaikh
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
dear friend
i am just trying to use jtextarea as display. whatever data send to serial port or read from serial post must be displayed in jtextarea. I am using keyboard input to send data to serial port. I am not able to to display sending data
public static class SerialWriter implements Runnable
{
OutputStream out;

public SerialWriter ( OutputStream out )
{
this.out = out;
}

public void run ()
{
try
{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String s;
String a = new String("hello");

while( (s = in.readLine()) != null && s.length() != 0)

gui.txtLog.append(s);
// System.out.println(s);

System.out.println(s);

}

catch ( IOException e )
{
System.err.println("Couldn't read from System.in!");
}
}
 
Ranganathan Kaliyur Mannar
Bartender
Posts: 1101
10
Java Netbeans IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Please UseCodeTags when posting code. Click on the link to understand what it means.

So, what is happening when you run the program? are you able to enter data via keyborad? is it just not reflecting in GUI?

Looks like you have a separate thread to read data from keyboard. Remember that, updates to Swing components should be done via EDT. If not, wrap your calls in SwingUtilities.invokeLater().
For more information, checkout this link
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic