Guest User

MessageController

a guest
Nov 14th, 2016
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.16 KB | None | 0 0
  1. package notepad.controller;
  2.  
  3. import javafx.event.ActionEvent;
  4. import javafx.fxml.FXML;
  5. import javafx.fxml.FXMLLoader;
  6. import javafx.fxml.Initializable;
  7. import javafx.scene.Node;
  8. import javafx.scene.control.Label;
  9. import javafx.scene.control.TextArea;
  10. import javafx.stage.Stage;
  11. import notepad.model.Notepad;
  12.  
  13.  
  14. import javax.xml.soap.Text;
  15. import java.io.IOException;
  16. import java.lang.reflect.InvocationTargetException;
  17. import java.net.URL;
  18. import java.util.ResourceBundle;
  19.  
  20. /**
  21.  * Created by Krzysztof on 2016-10-25.
  22.  */
  23. public class MessageController {
  24.  
  25.     @FXML
  26.     private Label lbl_msg;
  27.     private TextArea textArea;
  28.     private Stage stage;
  29.  
  30.     private String text;
  31.  
  32.     private Notepad notepad;
  33.     private NotepadController notepadController;
  34.  
  35.  
  36.     public void initialize(Notepad notepad, TextArea textArea, Stage stage){
  37.         this.notepad = notepad;
  38.         this.textArea = textArea;
  39.         this.stage = stage;
  40.     }
  41.  
  42.  
  43.  
  44.     //--------------------setters
  45.  
  46.     public void setTextArea(TextArea textArea) {
  47.         this.textArea = textArea;
  48.     }
  49.  
  50.     public void setStage(Stage stage) {
  51.         this.stage = stage;
  52.     }
  53.  
  54.     public void setText(String text) {
  55.         this.text = text;
  56.     }
  57.  
  58.  
  59.  
  60.     public void handleSaveMsg(ActionEvent event) throws IOException {
  61.  
  62.         notepad.saveFile(textArea, stage);
  63.  
  64.         Stage window = (Stage) ((Node) event.getSource()).getScene().getWindow();
  65.         textArea.clear();
  66.         window.close();
  67.         notepad.changeWindowName(stage,"New");
  68.         notepad.setCloseEnabled(true);
  69.  
  70.     }
  71.  
  72.     public void handleDontSaveMsg(ActionEvent event) throws IOException{
  73.  
  74.         Stage window = (Stage) ((Node) event.getSource()).getScene().getWindow();
  75.         textArea.clear();
  76.         window.close();
  77.         notepad.changeWindowName(stage,"New");
  78.         notepad.setCloseEnabled(true);
  79.     }
  80.  
  81.     public void handleCancelMsg(ActionEvent event) throws IOException {
  82.  
  83.         notepad.setIsOpenFileNeeded(true);
  84.         Stage window = (Stage) ((Node) event.getSource()).getScene().getWindow();
  85.         window.close();
  86.         notepad.setCloseEnabled(false);
  87.  
  88.     }
  89.  
  90. }
Add Comment
Please, Sign In to add comment