Linux 가상 머신 (JSch
)에 연결하는 응용 프로그램을 만들고 Linux에 OS 이름과 커널 버전과 같은 몇 가지 질문을합니다. 나는 그것에 성공했고 애플리케이션은 작동하지만 Eclipse 콘솔에서만 작동한다.JavaFX 레이블이 텍스트를 올바르게 업데이트하지 않음
Label 또는 TextArea에서 인쇄하려고하면 이상한 일이 발생합니다. 예를 들어, 레이블에 인쇄하려고하면 마지막 명령 만 인쇄합니다.
다음import javafx.fxml.FXML;
import javafx.scene.canvas.Canvas;
import javafx.scene.control.Label;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import javafx.scene.layout.Pane;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Properties;
import com.jcraft.jsch.Channel;
import com.jcraft.jsch.ChannelExec;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.Session;
public class MainWindowController {
@FXML private TextField ip_text_field, username_text_field, password_text_field;
@FXML private Label output;
String ip, username, pass;
private Main main;
public void setMain(Main main){
this.main = main;
}
public String getIP(){ip = ip_text_field.getText(); return ip;}
public String getUsername(){username = username_text_field.getText(); return username;}
public String getPassword(){pass = password_text_field.getText(); return pass;}
public void connectButtonFunction(){
try{
String command = "lsb_release -a | grep -i Description && uname -mrs";
String host = getIP();
String user = getUsername();
String password = getPassword();
JSch jsch = new JSch();
Session session = jsch.getSession(user, host, 22);
Properties config = new Properties();
config.put("StrictHostKeyChecking", "no");
session.setConfig(config);;
session.setPassword(password);
session.connect();
Channel channel = session.openChannel("exec");
((ChannelExec)channel).setCommand(command);
channel.setInputStream(null);
((ChannelExec)channel).setErrStream(System.err);
InputStream input = channel.getInputStream();
channel.connect();
//System.out.println("Channel Connected to machine " + host + " server with command: " + command);
try{
InputStreamReader inputReader = new InputStreamReader(input);
BufferedReader bufferedReader = new BufferedReader(inputReader);
String line = null;
while((line = bufferedReader.readLine()) != null){
//System.out.println(line);
output.setText(line);
}
bufferedReader.close();
inputReader.close();
}catch(IOException ex){
ex.printStackTrace();
}
channel.disconnect();
session.disconnect();
}catch(Exception ex){
ex.printStackTrace();
}
}
}
가 어떻게입니다 : 다음 텍스트 영역에 그것을 시도하는 경우가 여기에
코드는 ... 모두를 출력하지만, 한 줄, 그리고 내가 어떻게 브레이크 라인 모른다 라벨처럼 보입니다.