package net.pterodactylus.sonitus.gui;
-import javax.swing.Box;
-import javax.swing.BoxLayout;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Insets;
+import javax.swing.BorderFactory;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
import net.pterodactylus.sonitus.data.Controlled;
import net.pterodactylus.sonitus.data.Controller;
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
-public class ControlledPane extends Box {
+public class ControlledPane extends JPanel {
/**
* Creates a new controlled pane.
* The controlled whose controllers to display
*/
public ControlledPane(Controlled controlled) {
- super(BoxLayout.Y_AXIS);
+ super(new GridBagLayout());
+ setBorder(BorderFactory.createEmptyBorder(6, 12, 12, 12));
+
+ int controllerIndex = 0;
for (Controller controller : controlled.controllers()) {
+ add(new JLabel(controller.name()), new GridBagConstraints(0, controllerIndex, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(6, 0, 0, 6), 0, 0));
if (controller instanceof Fader) {
- add(new FaderPanel((Fader) controller));
+ add(new FaderPanel((Fader) controller), new GridBagConstraints(1, controllerIndex, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(6, 0, 0, 0), 0, 0));
} else if (controller instanceof Switch) {
- add(new SwitchPanel((Switch) controller));
+ add(new SwitchPanel((Switch) controller), new GridBagConstraints(1, controllerIndex, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(6, 0, 0, 0), 0, 0));
}
+ ++controllerIndex;
}
- add(Box.createGlue());
+ add(new JPanel(), new GridBagConstraints(0, controllerIndex, 2, 1, 0.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(6, 0, 0, 0), 0, 0));
}
}
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
-import javax.swing.BorderFactory;
import javax.swing.DefaultBoundedRangeModel;
import javax.swing.JLabel;
import javax.swing.JPanel;
*/
public FaderPanel(final Fader fader) {
super(new GridBagLayout());
- setBorder(BorderFactory.createEmptyBorder(12, 12, 12, 12));
-
- /* create label. */
- JLabel label = new JLabel(fader.name());
- add(label, new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
/* create fader labels. */
- add(new JLabel("-∞"), new GridBagConstraints(1, 0, 1, 1, 0, 0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(0, 6, 0, 0), 0, 0));
- add(new JLabel("0"), new GridBagConstraints(3, 0, 1, 1, 0, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 6, 0, 0), 0, 0));
+ add(new JLabel("-∞"), new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(0, 6, 0, 0), 0, 0));
+ add(new JLabel("0"), new GridBagConstraints(2, 0, 1, 1, 0, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 6, 0, 0), 0, 0));
/* create fader. */
JSlider slider = new JSlider(new DefaultBoundedRangeModel((int) (fader.value() * Integer.MAX_VALUE), 0, 0, Integer.MAX_VALUE));
fader.value(((JSlider) changeEvent.getSource()).getValue() / (double) Integer.MAX_VALUE);
}
});
- add(slider, new GridBagConstraints(2, 0, 1, 1, 1, 1, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
+ add(slider, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
}
}
*/
public SwitchPanel(final Switch switchController) {
super(new GridBagLayout());
- setBorder(BorderFactory.createEmptyBorder(12, 12, 12, 12));
-
- /* create label. */
- JLabel label = new JLabel(switchController.name());
- add(label, new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
/* create checkbox. */
JCheckBox checkBox = new JCheckBox();
switchController.value(((JCheckBox) actionEvent.getSource()).isSelected());
}
});
- add(checkBox, new GridBagConstraints(1, 0, 1, 1, 1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
+ add(checkBox, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
}
}