Guest User

NotepadController

a guest
Nov 14th, 2016
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.24 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.scene.Parent;
  7. import javafx.scene.Scene;
  8. import javafx.scene.control.MenuBar;
  9. import javafx.scene.control.TextArea;
  10. import javafx.scene.text.Font;
  11. import javafx.stage.Stage;
  12. import notepad.model.Notepad;
  13.  
  14.  
  15. import java.io.IOException;
  16.  
  17.  
  18. /**
  19.  * Created by Krzysztof on 2016-10-25.
  20.  */
  21. public class NotepadController{
  22.  
  23.     @FXML
  24.     private MenuBar menubar;
  25.     @FXML
  26.     private TextArea text_area;
  27.  
  28.     private Stage stage;
  29.     private Notepad notepad;
  30.  
  31.     public void initialize(Stage stage) throws IOException {
  32.  
  33.         this.notepad = new Notepad();
  34.         this.stage = stage;
  35.  
  36.         notepad.initialize(this);
  37.  
  38.     }
  39.  
  40.  
  41.  
  42.     //---------------------getters------------
  43.  
  44.     public TextArea getText_area() {
  45.         return text_area;
  46.     }
  47.  
  48.     public Stage getStage() {
  49.         return stage;
  50.     }
  51.  
  52.  
  53.     public Notepad getNotepad() {
  54.         return notepad;
  55.     }
  56.  
  57.  
  58.     //--------------------setters----------------
  59.  
  60.     public void setTextAreaContent(String content) {
  61.         text_area.setText(content);
  62.     }
  63.  
  64.     public void setText_area(TextArea text_area) {
  65.         this.text_area = text_area;
  66.     }
  67.  
  68.  
  69.  
  70.     public void handleItemSaveAs(ActionEvent event) {
  71.         notepad.saveFileAs(text_area,stage);
  72.     }
  73.  
  74.     public void handleItemOpen(ActionEvent event) throws IOException {
  75.         text_area.setText(notepad.openFile(text_area, stage));
  76.     }
  77.  
  78.     public void handleItemNew(ActionEvent event) throws IOException {
  79.         notepad.newFile(text_area, stage);
  80.     }
  81.  
  82.     public void handleItemSave(ActionEvent event) throws IOException {
  83.         notepad.saveFile(text_area,stage);
  84.     }
  85.  
  86.     public void test(){
  87.  
  88.     }
  89.  
  90.     public void handleItemWordWrap(ActionEvent event) {
  91.         if (!text_area.isWrapText()){
  92.             text_area.setWrapText(true);
  93.         }
  94.         else{
  95.             text_area.setWrapText(false);
  96.         }
  97.     }
  98.  
  99.     public void handleItemFont(ActionEvent event) throws IOException {
  100.         notepad.loadFontWindow();
  101.     }
  102.  
  103.  
  104.     public void handleIteamClear(ActionEvent event) {
  105.         text_area.clear();
  106.     }
  107. }
Add Comment
Please, Sign In to add comment