diff --git a/src/JRexFrame.java b/src/JRexFrame.java index 24eaa86..181117b 100644 --- a/src/JRexFrame.java +++ b/src/JRexFrame.java @@ -1,17 +1,18 @@ import java.awt.Color; -import java.util.logging.Level; -import java.util.logging.Logger; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; +import javax.swing.Action; import javax.swing.JFileChooser; import javax.swing.JOptionPane; +import javax.swing.JPopupMenu; +import javax.swing.KeyStroke; import javax.swing.SpinnerNumberModel; -import javax.swing.SwingUtilities; import javax.swing.UIManager; import javax.swing.table.DefaultTableModel; import javax.swing.table.TableModel; +import javax.swing.text.DefaultEditorKit; /** * @@ -28,13 +29,39 @@ initComponents(); splitPane.setResizeWeight(0.66); spnColumns.setModel(new SpinnerNumberModel(0, 0, Integer.MAX_VALUE, 1)); + + JPopupMenu rightClickMenu = new JPopupMenu(); + + Action cut = new DefaultEditorKit.CutAction(); + cut.putValue(Action.NAME, "Cut"); + cut.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke("control X")); + rightClickMenu.add(cut); + + Action copy = new DefaultEditorKit.CopyAction(); + copy.putValue(Action.NAME, "Copy"); + copy.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke("control C")); + rightClickMenu.add(copy); + + Action paste = new DefaultEditorKit.PasteAction(); + paste.putValue(Action.NAME, "Paste"); + paste.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke("control V")); + rightClickMenu.add(paste); + + Action tab = new DefaultEditorKit.InsertTabAction(); + tab.putValue(Action.NAME, "Insert Tab"); + rightClickMenu.add(tab); + + txtInput.setComponentPopupMenu(rightClickMenu); + txtOutput.setComponentPopupMenu(rightClickMenu); + txtRegex.setComponentPopupMenu(rightClickMenu); + txtFormat.setComponentPopupMenu(rightClickMenu); + } /** - * This method is called from within the constructor to - * initialize the form. - * WARNING: Do NOT modify this code. The content of this method is - * always regenerated by the Form Editor. + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // //GEN-BEGIN:initComponents @@ -403,7 +430,6 @@ input = text.split("\n"); } - for (String line : input) { Matcher matcher = pattern.matcher(line); while (matcher.find()) { @@ -442,7 +468,7 @@ } txtOutput.append("Matched " + numMatches + " line(s) out of " - + input.length + " line(s) of input."); + + input.length + " line(s) of input."); if (!flags.toString().isEmpty()) { txtOutput.append("\n\nFlags: " + flags.toString().trim());