在 JAVAFX 应用程序中有一个文本区域,我想在其中创建超链接,以便在单击该超链接后,新阶段将在运行时打开(其中将包含一个文本区域)并且当前进入主文本区域的文本将被转发到新阶段的新文本区域。这可以实现吗?有什么建议吗?
我在我的应用程序中有以下代码,其中“actLogTArea”是我想在其中提供超链接/按钮的文本区域,并且我想将进入主文本区域的文本传输到新文本区域,你能建议如何这样做吗?被改变?
new Thread(new Runnable() {
protected Logger logger = Logger.getLogger(UnixBoxTask.class.getName());
public void run() {
try {
String user = userName;
String pass = pwd;
String host = lanIP;
JSch jsch = new JSch();
Session session = jsch.getSession(user, host, 22);
//session.setHostKeyAlias(sshHostKey);
java.util.Properties config = new java.util.Properties();
config.put("StrictHostKeyChecking", "no");
session.setConfig(config);
session.setPassword(pass);
session.connect();
BufferedReader br = new BufferedReader(new FileReader(scriptPath));
String line;
String command_cd = "";
// Build unix command list separated by semicolon
while ((line = br.readLine()) != null) {
if (line.charAt(0) == '.' && line.charAt(1) == '/') {
line = ". " + line;
}
command_cd += line + ";";
}
br.close();
ArrayList nameofthreads = new ArrayList();
StringBuilder outputFromUnix = new StringBuilder();
this.logger.info("Command = " + command_cd);
Channel channel = session.openChannel("shell");
if (taskName.equalsIgnoreCase(increseSRB) || taskName.equalsIgnoreCase(decreseSRB)) {
String keyValueFile = DeploymentTaskController.getInstance().scriptFilePath + "\\" + taskName + "_KeyValue.txt";
buildParameterList(keyValueFile, taskName);
ChannelSftp channelSftp = (ChannelSftp) session.openChannel("sftp");
channelSftp.connect();
copyFiles(channelSftp, new File(keyValueFile), GlobalValues.getValueFromProps(taskName, "Build Path", LoginController.environment) + "/" + taskName);
channelSftp.disconnect();
}
channel.connect();
PrintStream commander = new PrintStream(channel.getOutputStream(), true);
commander.println(command_cd);
commander.println("exit;");
commander.close();
BufferedWriter bw = null;
InputStream outputstream_from_the_channel = channel.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(outputstream_from_the_channel));
bw = new BufferedWriter(new FileWriter(resultLogFile.getAbsolutePath(), true), 20000);
String jarOutput;
int count=0;
while ((jarOutput = reader.readLine()) != null) {
this.logger.info("Status Update = " + jarOutput);
bw.write(jarOutput);
if (jarOutput.contains("Test")) {
nameofthreads.add(jarOutput);
continue;
}
bw.newLine();
bw.flush();
outputFromUnix.append(jarOutput).append("\n");
// Display in activity log area in realtime.
if (DeploymentTaskController.actLogTArea != null && !taskName.equalsIgnoreCase(connectBundle)) {
final String outputStr = outputFromUnix.toString();
Platform.runLater(new Runnable() {
@Override
public void run() {
**DeploymentTaskController.actLogTArea.setText(outputStr);
DeploymentTaskController.actLogTArea.end();**
}
});
}
}
bw.close();
reader.close();
do {
Thread.sleep(1000);
} while (!channel.isEOF());
channel.disconnect();
session.disconnect();
Thread.sleep(1000);
} catch (JSchException jex) {
System.out.println("JSCH Exception : " + jex.getMessage());
} catch (Exception ex) {
System.out.println("General Exception JSCH Block : " + ex.getMessage() + AppUtil.stack2string(ex));
}
}
}).start();