2016-04-04 14 views
1

私はそれについて多くの記事を見ましたが、それは複雑に見えます。ここで私のコードは、gui textAreaの情報を表示する最も簡単な方法は何ですか?あなたが更新したい場合はguiにテキストを表示する最も簡単な方法は?

textArea.setText(s + "\n"); 

public static void runSystemCommand(String command) { 

    String message=null; 
    int i=0; 
    while (i<1) {  
    try { 
     Process p = Runtime.getRuntime().exec(command); 
     BufferedReader inputStream = new BufferedReader(
       new InputStreamReader(p.getInputStream())); 

     String s = ""; 
     // reading output stream of the command 
     while ((s = inputStream.readLine()) != null) { 
      //here i dont know what to type..please help 
     } 
     Thread.sleep(9000); 
    } catch (Exception e) { 
     e.printStackTrace(); 
    }  
    i++; 
    } 
} 
+0

これはJTextAreaに関するものですか、JavaScriptの 'alert()'に似たものがほしいだけですか? – Laurel

+2

'textArea.append(s +" \ r \ n ")'はこの場合に有効でしょうか? –

+0

JTextAreaコンポーネント – swipeales

答えて

0

最も簡単な方法は、あなただけsにテキストを設定したい場合、それは次のようになりますあなたのケースでは

textAreaName.setText(/*What ever you want to display here*/); 

だろう既存のテキストと一緒に使用するテキスト:

textArea.append(s + "\n"); 
+0

doesnt work mate – swipeales