Skip to content

Commit 5a0cb29

Browse files
author
Arun Prasaad
committed
Refactor creation of the save button
1 parent e6c11d2 commit 5a0cb29

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/main/java/ihm/Editor.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,9 @@ public Editor (int rowCount, int columnCount, String name) throws IOException {
8888
JLabel errorLabel = createErrorLabel();
8989

9090
// Action buttons
91-
JButton save = new JButton("Save");
92-
save.setName(Component.SAVE_BUTTON.name());
93-
save.setBounds(windowWidth + 20, 170, 110, 30);
94-
9591
createBackButton();
9692
createQuitButton();
93+
JButton save = createSaveButton();
9794

9895
save.addActionListener(new ActionListener() {
9996
@Override
@@ -169,10 +166,6 @@ else if (line.length() == columnCount) {
169166
}
170167
});
171168

172-
173-
this.add(save);
174-
this.add(errorLabel);
175-
176169
JPanel sokobanPanel = new SokobanPanel(controller);
177170
sokobanPanel.setName(Component.SOKOBAN_PANEL.name());
178171
this.add(sokobanPanel);
@@ -290,6 +283,14 @@ private void createTargetButton() {
290283
this.add(button);
291284
}
292285

286+
private JButton createSaveButton() {
287+
JButton save = new JButton("Save");
288+
save.setName(Component.SAVE_BUTTON.name());
289+
save.setBounds(windowWidth + 20, 170, 110, 30);
290+
this.add(save);
291+
return save;
292+
}
293+
293294
private JLabel createErrorLabel() {
294295
JLabel label = new JLabel("", SwingConstants.CENTER);
295296
label.setName(Component.ERROR_LABEL.name());

0 commit comments

Comments
 (0)