diff --git a/src/main/java/view/EditorView.java b/src/main/java/view/EditorView.java index 3eb6326e6bb2814eb82b407851d43b3ef5d429c3..302b74322a4caf5df0ee1417003aadd084fb2b41 100644 --- a/src/main/java/view/EditorView.java +++ b/src/main/java/view/EditorView.java @@ -17,7 +17,6 @@ limitations under the License. package view; import complexityparser.Model; - import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; @@ -29,33 +28,27 @@ import java.nio.charset.StandardCharsets; import java.nio.file.Files; /** - * a basic view to display a text editor containing the code that is analysed and displayed by the ANTLR tree + * A basic view to display a text editor containing the code that is analysed and displayed by the ANTLR tree. */ public class EditorView extends JPanel { private JScrollPane panel; private JTextArea area; private JButton updateButton; - private MainFrame parent; - private Model m; public EditorView(Model m, MainFrame parent) { this.parent = parent; this.m = m; InputMap inputMap = getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); - area = new JTextArea(m.getCode()); - area.setCaretColor(area.getForeground()); area.getCaret().setBlinkRate(0); area.setTabSize(4); area.setFont(new Font("monospaced", Font.PLAIN, 12)); - panel = new JScrollPane(area); panel.setWheelScrollingEnabled(true); - updateButton = new JButton("update"); Action action = new AbstractAction() { @Override @@ -67,20 +60,16 @@ public class EditorView extends JPanel { updateButton.addActionListener(action); inputMap.put(KeyStroke.getKeyStroke("F6"), "F6"); getActionMap().put("F6", action); - BorderLayout layout = new BorderLayout(); setLayout(layout); - add(panel, BorderLayout.CENTER); add(updateButton, BorderLayout.SOUTH); - inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_DOWN_MASK), "o"); getActionMap().put("o", new AbstractAction() { @Override public void actionPerformed(ActionEvent actionEvent) { JFileChooser fc = new JFileChooser(); fc.setCurrentDirectory(new File(System.getProperty("user.dir"))); - if(JFileChooser.APPROVE_OPTION == fc.showOpenDialog(parent)) { File f = fc.getSelectedFile(); try { @@ -96,9 +85,7 @@ public class EditorView extends JPanel { } } }); - setPreferredSize(new Dimension(400, 600)); - inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "escape"); getActionMap().put("escape", new AbstractAction() { @Override @@ -107,4 +94,4 @@ public class EditorView extends JPanel { } }); } -} +} \ No newline at end of file diff --git a/src/main/java/view/MainFrame.java b/src/main/java/view/MainFrame.java index 5ac53f9f57c2eaaf367dc6991a35195341db0af5..0f20a97304290e106cdd497f446618a1b9735e8f 100644 --- a/src/main/java/view/MainFrame.java +++ b/src/main/java/view/MainFrame.java @@ -17,34 +17,29 @@ limitations under the License. package view; import complexityparser.Model; - import javax.swing.*; import java.awt.*; /** - * just the main window + * The main window. */ public class MainFrame extends JFrame { public MainFrame(Model m) { setTheme(); setVisible(true); setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); - setTitle("ComplexityParser"); - BorderLayout layout = new BorderLayout(); setLayout(layout); - add(new EditorView(m, this), BorderLayout.WEST); add(new TreePanel(m), BorderLayout.CENTER); add(new MessageView(m), BorderLayout.EAST); - pack(); //setSize(600,600); } /** - * changes the look and feel of java swing to the OS theme + * Changes the look and feel of java swing to the OS theme. */ private static void setTheme() { try { @@ -53,4 +48,4 @@ public class MainFrame extends JFrame { e.printStackTrace(); } } -} +} \ No newline at end of file