I am very new to JavaFX. I am developing a desktop app using JavaFX and scene builder with Netbeans IDE.
Here is my application UI in words (I have less reputation to show screenshot).
One check box named "Click here to enable textbox" (present in right side of the checkbox)
One textbox (this should be disabled by default, if user click/check on the checkbox, it should have write option; i.e. enabled)
one button name "Do the big task" - This button performs main task, this task is quite long. (A ssh connection is done and script is called from a Java class to a remote machine, this scripts calls another two scrpts and finally done and all process's logs are recorded in a file named output.log )
another button named "show logs" (intention is to show output.log live [as writing at the time of execution] ) followed by a large text field (where logs should be shown)
and a progress bar (where calling from script1 to script n progress will be shown)
Below is my FXMLDocumentController.java class:
@FXML
Button btnDotheBigtask;
@FXML
Button btnShowLogs;
@FXML
TextArea txtShowLogs;
@FXML
TextField txtMyText;
@FXML
CheckBox clickHeretoEnableTextBox;
@FXML
public void btnDotheBigtaskClick(ActionEvent event) throws IOException {
//CreateRelease create = new CreateRelease();
MyClassImpl m = new MyClassImpl();
m.doTheWork();
}
@FXML
public void btnShowLogs(ActionEvent event) throws IOException {
}
@FXML
public void clickHeretoEnableTextBox(ActionEvent event) throws IOException {
}
@FXML
public void txtAreaShowLogs(ActionEvent event) throws IOException {
}
@FXML
public void txtMyText(ActionEvent event) throws IOException {
}
MyClassImpl.java to perform the main task [I have used SSHExecute 1.0 jar to establish ssh connection]
ConnBean cb = new ConnBean("RemoteServer", "user","password");
// Put the ConnBean instance as parameter for SSHExec static method getInstance(ConnBean) to retrieve a singleton SSHExec instance
ssh = SSHExec.getInstance(cb);
//Connect to server
ssh.connect();
CustomTask sampleTask = new ExecCommand("/usr/Test/myscript.sh");
//Execution of main taks
Result rs = ssh.exec(sampleTask);
What I want to do is :
- By default the textbox should disbaled, at clicking in checkbox it should enabled.
- On clicking btnDotheBigtaskClick button the UI should not be freeze, when I click on this button A message should be shown in a label something like "work is started... " (That I will create later) and after completion of the whole task label value should be updated to "Work Done".
- On clicking on Show logs button, logs should stared showing in the text feild. (UI should not freeze at that time)
Basically I have performed a lot of task to achive this and check where I failed
The big task executes smoothly (As I have used a java standard thread) but failed to show the logs, when I clicked on show log button UI gets freeze. (On showLogs I have read the log file and tried to print in the text feild)
I failed to show/set the work finised/started messsage from a different class (MyClassImpl)in a label present in controller class.
Can anybody help me with concepts or code to achieve this task (code will be much easier to understand).