mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
- GUI: Themed order selection window.
This commit is contained in:
@@ -22,6 +22,12 @@ import javax.swing.event.ListSelectionListener;
|
|||||||
import forge.Card;
|
import forge.Card;
|
||||||
import forge.card.spellability.SpellAbility;
|
import forge.card.spellability.SpellAbility;
|
||||||
import forge.gui.match.CMatchUI;
|
import forge.gui.match.CMatchUI;
|
||||||
|
import forge.gui.toolbox.FButton;
|
||||||
|
import forge.gui.toolbox.FLabel;
|
||||||
|
import forge.gui.toolbox.FList;
|
||||||
|
import forge.gui.toolbox.FPanel;
|
||||||
|
import forge.gui.toolbox.FScrollPane;
|
||||||
|
import forge.gui.toolbox.FSkin;
|
||||||
|
|
||||||
// An input box for handling the order of choices.
|
// An input box for handling the order of choices.
|
||||||
// Left box has the original choices
|
// Left box has the original choices
|
||||||
@@ -34,25 +40,25 @@ import forge.gui.match.CMatchUI;
|
|||||||
// Single ok button, disabled until left box is empty
|
// Single ok button, disabled until left box is empty
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class DualListBox<T> extends JPanel {
|
public class DualListBox<T> extends FPanel {
|
||||||
private JList sourceList;
|
private FList sourceList;
|
||||||
|
|
||||||
private UnsortedListModel<T> sourceListModel;
|
private UnsortedListModel<T> sourceListModel;
|
||||||
|
|
||||||
private JList destList;
|
private FList destList;
|
||||||
|
|
||||||
private UnsortedListModel<T> destListModel;
|
private UnsortedListModel<T> destListModel;
|
||||||
|
|
||||||
private JButton addButton;
|
private FButton addButton;
|
||||||
private JButton addAllButton;
|
private FButton addAllButton;
|
||||||
|
|
||||||
private JButton removeButton;
|
private FButton removeButton;
|
||||||
private JButton removeAllButton;
|
private FButton removeAllButton;
|
||||||
|
|
||||||
private JButton okButton;
|
private FButton okButton;
|
||||||
private JButton autoButton;
|
private FButton autoButton;
|
||||||
|
|
||||||
private JLabel orderedLabel;
|
private FLabel orderedLabel;
|
||||||
|
|
||||||
private int remainingObjects = 0;
|
private int remainingObjects = 0;
|
||||||
|
|
||||||
@@ -161,48 +167,53 @@ public class DualListBox<T> extends JPanel {
|
|||||||
private void initScreen() {
|
private void initScreen() {
|
||||||
setPreferredSize(new Dimension(650, 300));
|
setPreferredSize(new Dimension(650, 300));
|
||||||
setLayout(new GridLayout(0, 3));
|
setLayout(new GridLayout(0, 3));
|
||||||
|
setBackground(FSkin.getColor(FSkin.Colors.CLR_THEME));
|
||||||
|
setForeground(FSkin.getColor(FSkin.Colors.CLR_TEXT));
|
||||||
sourceListModel = new UnsortedListModel<T>();
|
sourceListModel = new UnsortedListModel<T>();
|
||||||
sourceList = new JList(sourceListModel);
|
sourceList = new FList(sourceListModel);
|
||||||
|
|
||||||
// Dual List control buttons
|
// Dual List control buttons
|
||||||
addButton = new JButton(">");
|
addButton = new FButton(">");
|
||||||
addButton.addActionListener(new AddListener());
|
addButton.addActionListener(new AddListener());
|
||||||
addAllButton = new JButton(">>");
|
addAllButton = new FButton(">>");
|
||||||
addAllButton.addActionListener(new AddAllListener());
|
addAllButton.addActionListener(new AddAllListener());
|
||||||
removeButton = new JButton("<");
|
removeButton = new FButton("<");
|
||||||
removeButton.addActionListener(new RemoveListener());
|
removeButton.addActionListener(new RemoveListener());
|
||||||
removeAllButton = new JButton("<<");
|
removeAllButton = new FButton("<<");
|
||||||
removeAllButton.addActionListener(new RemoveAllListener());
|
removeAllButton.addActionListener(new RemoveAllListener());
|
||||||
|
|
||||||
// Dual List Complete Buttons
|
// Dual List Complete Buttons
|
||||||
okButton = new JButton("OK");
|
okButton = new FButton("OK");
|
||||||
okButton.addActionListener(new OkListener());
|
okButton.addActionListener(new OkListener());
|
||||||
|
|
||||||
autoButton = new JButton("Auto");
|
autoButton = new FButton("Auto");
|
||||||
autoButton.addActionListener(new AutoListener());
|
autoButton.addActionListener(new AutoListener());
|
||||||
|
|
||||||
destListModel = new UnsortedListModel<T>();
|
destListModel = new UnsortedListModel<T>();
|
||||||
destList = new JList(destListModel);
|
destList = new FList(destListModel);
|
||||||
|
|
||||||
JPanel leftPanel = new JPanel(new BorderLayout());
|
FPanel leftPanel = new FPanel(new BorderLayout());
|
||||||
|
FLabel selectOrder = new FLabel.Builder().build();
|
||||||
|
selectOrder.setText("Select Order:");
|
||||||
leftPanel.setSize(300, 300);
|
leftPanel.setSize(300, 300);
|
||||||
leftPanel.add(new JLabel("Select Order:"), BorderLayout.NORTH);
|
leftPanel.add(selectOrder, BorderLayout.NORTH);
|
||||||
leftPanel.add(new JScrollPane(sourceList), BorderLayout.CENTER);
|
leftPanel.add(new FScrollPane(sourceList), BorderLayout.CENTER);
|
||||||
leftPanel.add(okButton, BorderLayout.SOUTH);
|
leftPanel.add(okButton, BorderLayout.SOUTH);
|
||||||
|
|
||||||
JPanel centerPanel = new JPanel(new GridLayout(5, 1));
|
FPanel centerPanel = new FPanel(new GridLayout(5, 1));
|
||||||
centerPanel.setSize(50, this.getHeight());
|
centerPanel.setSize(50, this.getHeight());
|
||||||
centerPanel.add(addButton);
|
centerPanel.add(addButton);
|
||||||
centerPanel.add(addAllButton);
|
centerPanel.add(addAllButton);
|
||||||
centerPanel.add(removeButton);
|
centerPanel.add(removeButton);
|
||||||
centerPanel.add(removeAllButton);
|
centerPanel.add(removeAllButton);
|
||||||
|
|
||||||
orderedLabel = new JLabel("Selected Elements:");
|
orderedLabel = new FLabel.Builder().build();
|
||||||
|
orderedLabel.setText("Selected Elements:");
|
||||||
|
|
||||||
JPanel rightPanel = new JPanel(new BorderLayout());
|
FPanel rightPanel = new FPanel(new BorderLayout());
|
||||||
rightPanel.setSize(300, 300);
|
rightPanel.setSize(300, 300);
|
||||||
rightPanel.add(orderedLabel, BorderLayout.NORTH);
|
rightPanel.add(orderedLabel, BorderLayout.NORTH);
|
||||||
rightPanel.add(new JScrollPane(destList), BorderLayout.CENTER);
|
rightPanel.add(new FScrollPane(destList), BorderLayout.CENTER);
|
||||||
rightPanel.add(autoButton, BorderLayout.SOUTH);
|
rightPanel.add(autoButton, BorderLayout.SOUTH);
|
||||||
|
|
||||||
add(leftPanel);
|
add(leftPanel);
|
||||||
|
|||||||
Reference in New Issue
Block a user