diff --git a/src/com/gpl/rpg/atcontentstudio/ui/gamedataeditors/DialogueEditor.java b/src/com/gpl/rpg/atcontentstudio/ui/gamedataeditors/DialogueEditor.java index b7dc0b8..e554c0d 100644 --- a/src/com/gpl/rpg/atcontentstudio/ui/gamedataeditors/DialogueEditor.java +++ b/src/com/gpl/rpg/atcontentstudio/ui/gamedataeditors/DialogueEditor.java @@ -108,15 +108,7 @@ public class DialogueEditor extends JSONElementEditor { dialogueGraphView = new DialogueGraphView(dialogue, null); pane.add(dialogueGraphView, BorderLayout.CENTER); - JPanel buttonPane = new JPanel(); - buttonPane.setLayout(new JideBoxLayout(buttonPane, JideBoxLayout.LINE_AXIS)); - JButton reloadButton = new JButton("Refresh graph"); - buttonPane.add(reloadButton, JideBoxLayout.FIX); - buttonPane.add(new JPanel(), JideBoxLayout.VARY); - pane.add(buttonPane, BorderLayout.NORTH); - - - reloadButton.addActionListener(new ActionListener() { + JPanel buttonPane = UiUtils.createRefreshButtonPane(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { pane.remove(dialogueGraphView); @@ -126,6 +118,7 @@ public class DialogueEditor extends JSONElementEditor { pane.repaint(); } }); + pane.add(buttonPane, BorderLayout.NORTH); return pane; } diff --git a/src/com/gpl/rpg/atcontentstudio/ui/gamedataeditors/NPCEditor.java b/src/com/gpl/rpg/atcontentstudio/ui/gamedataeditors/NPCEditor.java index 705dbc0..7dc86bb 100644 --- a/src/com/gpl/rpg/atcontentstudio/ui/gamedataeditors/NPCEditor.java +++ b/src/com/gpl/rpg/atcontentstudio/ui/gamedataeditors/NPCEditor.java @@ -8,6 +8,7 @@ import com.gpl.rpg.atcontentstudio.model.gamedata.*; import com.gpl.rpg.atcontentstudio.model.sprites.Spritesheet; import com.gpl.rpg.atcontentstudio.ui.*; import com.gpl.rpg.atcontentstudio.ui.gamedataeditors.dialoguetree.DialogueGraphView; +import com.gpl.rpg.atcontentstudio.utils.UiUtils; import com.jidesoft.swing.JideBoxLayout; import javax.swing.*; @@ -170,20 +171,14 @@ public class NPCEditor extends JSONElementEditor { dialogueGraphView = new DialogueGraphView(npc.dialogue, npc); dialogueGraphPane.add(dialogueGraphView, BorderLayout.CENTER); - JPanel buttonPane = new JPanel(); - buttonPane.setLayout(new JideBoxLayout(buttonPane, JideBoxLayout.LINE_AXIS)); - JButton reloadButton = new JButton("Refresh graph"); - buttonPane.add(reloadButton, JideBoxLayout.FIX); - buttonPane.add(new JPanel(), JideBoxLayout.VARY); - dialogueGraphPane.add(buttonPane, BorderLayout.NORTH); - - - reloadButton.addActionListener(new ActionListener() { + JPanel buttonPane = UiUtils.createRefreshButtonPane(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { reloadGraphView(npc); } }); + dialogueGraphPane.add(buttonPane, BorderLayout.NORTH); + return dialogueGraphPane; } diff --git a/src/com/gpl/rpg/atcontentstudio/utils/UiUtils.java b/src/com/gpl/rpg/atcontentstudio/utils/UiUtils.java index 5c0b9c2..a9d5ba0 100644 --- a/src/com/gpl/rpg/atcontentstudio/utils/UiUtils.java +++ b/src/com/gpl/rpg/atcontentstudio/utils/UiUtils.java @@ -9,10 +9,8 @@ import com.gpl.rpg.atcontentstudio.ui.OrderedListenerListModel; import com.jidesoft.swing.JideBoxLayout; import javax.swing.*; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; +import java.awt.*; +import java.awt.event.*; import java.util.function.Supplier; public class UiUtils { @@ -20,6 +18,16 @@ public class UiUtils { public CollapsiblePanel collapsiblePanel; public JList list; } + public static JPanel createRefreshButtonPane(ActionListener reloadButtonEditor){ + JPanel buttonPane = new JPanel(); + buttonPane.setLayout(new JideBoxLayout(buttonPane, JideBoxLayout.LINE_AXIS)); + JButton reloadButton = new JButton("Refresh graph"); + buttonPane.add(reloadButton, JideBoxLayout.FIX); + buttonPane.add(new JPanel(), JideBoxLayout.VARY); + + reloadButton.addActionListener(reloadButtonEditor); + return buttonPane; + } public static > CollapsibleItemListCreation getCollapsibleItemList(FieldUpdateListener listener, M itemsListModel,