diff --git a/src/RegexTool.java b/src/RegexTool.java index 82e459d..143b2ab 100644 --- a/src/RegexTool.java +++ b/src/RegexTool.java @@ -1,4 +1,6 @@ import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; import java.awt.event.ItemEvent; import java.util.ArrayList; import java.util.Iterator; @@ -91,6 +93,26 @@ pnlButtons.add(lblDirtyHackySpacer, null); this.pnlButtons.add(getBtnMatch(), null); this.pnlButtons.add(getJButton(), null); + final JButton btnLoad = new JButton("Load from file"); + + btnLoad.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + JFileChooser jfc = new JFileChooser(); + if (jfc.showOpenDialog(RegexTool.this) == JFileChooser.APPROVE_OPTION) { + try { + String data = JSedUtils.readFile(jfc.getSelectedFile()); + + taText.setText(data); + + } catch (Exception ex) { + JOptionPane.showMessageDialog(RegexTool.this, "Error", ex.getMessage(), JOptionPane.ERROR_MESSAGE); + } + } + } + }); + + this.pnlButtons.add(btnLoad, null); this.pnlButtons.add(getBtnExit(), null); } catch (java.lang.Throwable e) { e.printStackTrace();