aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes how to read perticular line in jtextarea Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "how to read perticular line in jtextarea " Watch "how to read perticular line in jtextarea " New topic
Author

how to read perticular line in jtextarea

Sarafaraj Shaikh
Greenhorn

Joined: Nov 03, 2012
Posts: 5
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

Joined: Jun 09, 2003
Posts: 4632
> 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

Joined: Nov 03, 2012
Posts: 5
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

Joined: Oct 16, 2003
Posts: 1075
    
  10

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


Ranga.
SCJP 1.4, OCMJEA/SCEA 5.0.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to read perticular line in jtextarea
 
Similar Threads
Reading From a serial Port
Read from SMDR serial cable!
JTextArea used as a modem terminal
I can't make my JTextArea Scrollable
How a character save in 2 bytes in Java?