在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();
你能建議我們如何在上面的代碼中實現它嗎? – Rohan 2013-05-09 15:21:50
這段代碼片段有幫助嗎? – 2013-05-09 15:28:00
好的,我會試試這個。但是我們在哪裏創建這個按鈕?我想創建其他活動區域,當我們點擊當前文本區域按鈕時,這個區域會被調用 – Rohan 2013-05-09 15:37:43