Move auto-scan/activate checkboxes into Options window

This commit is contained in:
Ash 2017-04-12 16:18:12 +10:00
parent d56b344a88
commit dd9386f0ed
2 changed files with 33 additions and 44 deletions

View File

@ -30,7 +30,6 @@ import java.awt.event.ActionListener;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
@ -60,19 +59,6 @@ public final class GuiInputControls extends JPanel {
final JButton connectButton = new JButton(CONNECT);
connectButton.setAlignmentX(Component.CENTER_ALIGNMENT);
final JCheckBox cbautoScanForController = new JCheckBox();
cbautoScanForController.setSelected(Settings.SCAN_AUTOMATICALLY_FOR_CONTROLLERS);
cbautoScanForController.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
boolean selected = ((JCheckBox) e.getSource()).isSelected();
Settings.SCAN_AUTOMATICALLY_FOR_CONTROLLERS = selected;
cbautoScanForController.setSelected(selected);
}
});
final JButton scanButton = new JButton("Scan for Controllers");
scanButton.setAlignmentX(Component.CENTER_ALIGNMENT);
scanButton.addActionListener(new ActionListener() {
@ -98,12 +84,6 @@ public final class GuiInputControls extends JPanel {
});
}
});
JPanel scanWrap = new JPanel();
scanWrap.setLayout(new BoxLayout(scanWrap, BoxLayout.X_AXIS));
JLabel label = new JLabel("Auto Scan for Controllers: ");
scanWrap.add(label);
scanWrap.add(cbautoScanForController);
ipTextBox = new JTextField();
ipTextBox.setColumns(15);
@ -113,23 +93,6 @@ public final class GuiInputControls extends JPanel {
ipTextBoxWrap.add(ipTextBox);
ipTextBoxWrap.setMaximumSize(new Dimension(1000, 20));
final JCheckBox cbautoActivateController = new JCheckBox();
cbautoActivateController.setSelected(Settings.AUTO_ACTIVATE_CONTROLLER);
cbautoActivateController.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
boolean selected = ((JCheckBox) e.getSource()).isSelected();
Settings.AUTO_ACTIVATE_CONTROLLER = selected;
cbautoActivateController.setSelected(selected);
}
});
JPanel autoActivateWrap = new JPanel();
autoActivateWrap.setLayout(new BoxLayout(autoActivateWrap, BoxLayout.X_AXIS));
autoActivateWrap.add(new JLabel("Auto Activate Controller: "));
autoActivateWrap.add(cbautoActivateController);
add(Box.createVerticalGlue());
add(ipTextBoxWrap);
@ -140,10 +103,6 @@ public final class GuiInputControls extends JPanel {
add(scanButton);
add(Box.createRigidArea(new Dimension(1, 4)));
add(optionsButton);
add(Box.createRigidArea(new Dimension(1, 4)));
add(scanWrap);
add(Box.createRigidArea(new Dimension(1, 4)));
add(autoActivateWrap);
add(Box.createVerticalGlue());
add(Box.createVerticalGlue());

View File

@ -82,7 +82,7 @@ public class GuiOptionsWindow extends JPanel {
log.info("Hello from the Options window!");
setPreferredSize(new Dimension(600, 300));
setPreferredSize(new Dimension(600, 200));
JTabbedPane tabPane = new JTabbedPane();
tabPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
@ -102,6 +102,8 @@ public class GuiOptionsWindow extends JPanel {
private static final long serialVersionUID = 1L;
private final ControllerFilteringList cFilterList;
private final JCheckBox cBoxScanForControllers;
private final JCheckBox cBoxAutoActivateControllers;
private ControllerTab() {
super(new GridLayout(1, 2));
@ -115,7 +117,34 @@ public class GuiOptionsWindow extends JPanel {
add(cFilterList);
add(new JPanel()); //TODO right side controls
JPanel rightSideControls = new JPanel();
rightSideControls.setLayout(new BoxLayout(rightSideControls, BoxLayout.PAGE_AXIS));
rightSideControls.add(Box.createVerticalGlue());
cBoxScanForControllers = new JCheckBox("Automatically scan for controllers");
cBoxScanForControllers.setAlignmentX(Component.CENTER_ALIGNMENT);
cBoxScanForControllers.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
Settings.SCAN_AUTOMATICALLY_FOR_CONTROLLERS = cBoxScanForControllers.isSelected();
}
});
rightSideControls.add(cBoxScanForControllers);
rightSideControls.add(Box.createVerticalStrut(2));
cBoxAutoActivateControllers = new JCheckBox("Automatically activate controllers");
cBoxAutoActivateControllers.setAlignmentX(Component.CENTER_ALIGNMENT);
cBoxAutoActivateControllers.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
Settings.AUTO_ACTIVATE_CONTROLLER = cBoxAutoActivateControllers.isSelected();
}
});
rightSideControls.add(cBoxAutoActivateControllers);
rightSideControls.add(Box.createVerticalGlue());
add(rightSideControls);
}
@Override
@ -123,6 +152,8 @@ public class GuiOptionsWindow extends JPanel {
for (ControllerFilteringListItem c : cFilterList.items) {
c.updateItem();
}
cBoxScanForControllers.setSelected(Settings.SCAN_AUTOMATICALLY_FOR_CONTROLLERS);
cBoxAutoActivateControllers.setSelected(Settings.AUTO_ACTIVATE_CONTROLLER);
}
private class ControllerFilteringList extends JPanel {
@ -165,7 +196,6 @@ public class GuiOptionsWindow extends JPanel {
cBox = new JCheckBox(type.getName());
cBox.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
cBox.setSelected(Settings.ControllerFiltering.getFilterState(type));
cBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {