From c1dd28ce3d6c3fc393532101a70f8c3f4c5e9ac7 Mon Sep 17 00:00:00 2001 From: Neel Kallidai <60594105+LaplacesCat@users.noreply.github.com> Date: Wed, 27 Nov 2024 15:47:07 -0400 Subject: [PATCH] Extracted method from RemoteFileChooser.java --- .../org/fife/rtext/RemoteFileChooser.java | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/fife/rtext/RemoteFileChooser.java b/src/main/java/org/fife/rtext/RemoteFileChooser.java index e3c8c485..ad1386e1 100644 --- a/src/main/java/org/fife/rtext/RemoteFileChooser.java +++ b/src/main/java/org/fife/rtext/RemoteFileChooser.java @@ -133,13 +133,10 @@ public RemoteFileChooser(RText owner) { // Make a panel containing the OK and Cancel buttons. JPanel buttonPanel = new JPanel(new GridLayout(1,3, 5,5)); - okButton = UIUtil.newButton(msg, "OK", "OKMnemonic"); - okButton.setActionCommand("OK"); - okButton.addActionListener(this); - JButton cancelButton = UIUtil.newButton(msg, "Cancel", - "CancelMnemonic"); - cancelButton.setActionCommand("Cancel"); - cancelButton.addActionListener(this); + okButton = createButton(msg, "OK", + "OKMnemonic", "OK", this); + JButton cancelButton = createButton(msg, "Cancel", + "CancelMnemonic", "Cancel", this); advancedButton = new JToggleButton(msg.getString("Advanced")); advancedButton.setMnemonic((int)msg.getString("AdvancedMnemonic"). charAt(0)); @@ -576,5 +573,13 @@ public void updateUI() { } } + public JButton createButton(ResourceBundle msg, String textKey, String mnemonicKey, + String actionCommand, ActionListener actionListener) { + JButton button = UIUtil.newButton(msg, textKey, mnemonicKey); + button.setActionCommand(actionCommand); + button.addActionListener(actionListener); + + return button; + } }