1 package at.ac.tuwien.sbc.valesriegler.group.gui;
4 import javax.swing.border.TitledBorder;
6 import java.awt.event.ActionEvent;
7 import java.awt.event.ActionListener;
10 public class GroupCreationPanel extends JPanel {
12 private boolean withAddress;
14 public GroupCreationPanel(final boolean withAddress) {
15 this.withAddress = withAddress;
17 final JPanel chooseGroupSizePanel = new JPanel();
18 JLabel creationLabel = new JLabel("How many members should the group have?");
19 JButton next = new JButton("Next");
20 SpinnerNumberModel model = new SpinnerNumberModel(1, 1, 4, 1);
21 final JSpinner spinner = new JSpinner(model);
23 // When 'next' is clicked the second, final panel of the Group Creation
24 // Wizard should be shown
25 next.addActionListener(new ActionListener() {
27 public void actionPerformed(ActionEvent e) {
28 int numberMembers = (int) spinner.getValue();
29 GroupCreationPanel.this.withAddress = withAddress;
30 final GroupCreationDetailsPanel groupCreationDetailsPanel = new GroupCreationDetailsPanel(numberMembers, GroupCreationPanel.this.withAddress);
31 GroupCreationHandler groupCreationHandler = new GroupCreationHandler(GroupCreationPanel.this, chooseGroupSizePanel,
32 groupCreationDetailsPanel, GroupCreationPanel.this.withAddress);
34 groupCreationDetailsPanel.setCreateAndCancelHandler(groupCreationHandler);
35 groupCreationHandler.showGroupCreationDetailPanel();
40 GridLayout creationPanelLayout = new GridLayout(3, 1);
41 chooseGroupSizePanel.setLayout(creationPanelLayout);
42 final String title = withAddress ? "Create Delivery Groups" : "Create Normal Groups";
43 this.setBorder(new TitledBorder(title));
45 this.add(chooseGroupSizePanel);
46 chooseGroupSizePanel.add(creationLabel);
47 chooseGroupSizePanel.add(spinner);
48 chooseGroupSizePanel.add(next);