Vote count: 0
new to java, javaFX(-8) and NetBeans. Quite some programming experiance, but way back when C and C++ were all the rage. So little experience with graphical GUI.
Trying to get some feedback (info, error, progress) back to the user (me) from within the inner workings of a complex object (written by me :-)). Want to use javaFX TextArea for that, does not even compile? And I do not get why... Simplified code added.
Any help to get this working much appreciated.
P.S. I realise there may be other approaches to this, and i am willing to look into those, but I would like to get this running, if at all possible, for learning purposes.
public class TestWriteToText extends Application { /* as generated */
@Override
public void start(Stage stage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("FXMLDocument.fxml"));
Scene scene = new Scene(root);
stage.setScene(scene);
stage.show();
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}
}
public class FXMLDocumentController implements Initializable {
@FXML
private TextArea txtArea;
@FXML
private Button localButton;
@FXML
private Button logicButton;
/**
* Initializes the controller class.
*/
@Override
public void initialize(URL url, ResourceBundle rb) {
// TODO
}
@FXML
private void doLocalButton(ActionEvent event) {
writeOutput (String.format("It works locally %n"));
}
@FXML
private void doLogicButton(ActionEvent event) {
BusinessObject myLogic = new BusinessObject();
}
public void writeOutput (String outputLine){
txtArea.appendText(outputLine);
}
}
public class BusinessObject {
public BusinessObject (){
String outputLine;
outputLine = String.format("How to make this work from business logic???%n");
FXMLDocumentController.writeOutput(outputLine);
}
}
Writing output from within a business logic object to a NetBeans/JavaFX TextArea
Aucun commentaire:
Enregistrer un commentaire