diff options
| author | bculkin2442 <bjculkin@mix.wvu.edu> | 2016-08-19 11:02:03 -0400 |
|---|---|---|
| committer | bculkin2442 <bjculkin@mix.wvu.edu> | 2016-08-19 11:02:03 -0400 |
| commit | 6d454caf2bfa5207957b5da775ece2a249857ddd (patch) | |
| tree | 130df7ff143f1dfce694d25e9537f3b0396c63fd /BJC-Utils2/src/main/java/bjc/utils/gui/DropdownListPanel.java | |
| parent | 092975de0acbe682a317b97c17c0fcc3933e88ee (diff) | |
GUI reorganization
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/gui/DropdownListPanel.java')
| -rw-r--r-- | BJC-Utils2/src/main/java/bjc/utils/gui/DropdownListPanel.java | 57 |
1 files changed, 0 insertions, 57 deletions
diff --git a/BJC-Utils2/src/main/java/bjc/utils/gui/DropdownListPanel.java b/BJC-Utils2/src/main/java/bjc/utils/gui/DropdownListPanel.java deleted file mode 100644 index 530fca2..0000000 --- a/BJC-Utils2/src/main/java/bjc/utils/gui/DropdownListPanel.java +++ /dev/null @@ -1,57 +0,0 @@ -package bjc.utils.gui; - -import java.awt.BorderLayout; - -import javax.swing.DefaultListModel; -import javax.swing.JButton; -import javax.swing.JComboBox; -import javax.swing.JList; -import javax.swing.JPanel; -import javax.swing.ListSelectionModel; - -import bjc.utils.funcdata.IList; -import bjc.utils.gui.layout.AutosizeLayout; -import bjc.utils.gui.layout.HLayout; - -public class DropdownListPanel extends JPanel { - private static final long serialVersionUID = 2719963952350133541L; - - @SuppressWarnings("unchecked") - public <T> DropdownListPanel(String itemType, - DefaultListModel<T> listModel, IList<T> choices) { - setLayout(new AutosizeLayout()); - - JPanel itemInputPanel = new JPanel(); - itemInputPanel.setLayout(new BorderLayout()); - - JPanel addItemPanel = new JPanel(); - addItemPanel.setLayout(new HLayout(2)); - - JComboBox<T> addItemBox = new JComboBox<>(); - choices.forEach(addItemBox::addItem); - - JButton addItemButton = new JButton("Add " + itemType); - - addItemPanel.add(addItemBox); - addItemPanel.add(addItemButton); - - JList<T> itemList = new JList<>(listModel); - itemList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - - JButton removeItemButton = new JButton("Remove " + itemType); - - addItemButton.addActionListener((ev) -> { - listModel.addElement((T) addItemBox.getSelectedItem()); - }); - - removeItemButton.addActionListener((ev) -> { - listModel.remove(itemList.getSelectedIndex()); - }); - - itemInputPanel.add(addItemPanel, BorderLayout.PAGE_START); - itemInputPanel.add(itemList, BorderLayout.CENTER); - itemInputPanel.add(removeItemButton, BorderLayout.PAGE_END); - - add(itemInputPanel); - } -} |
