public TriggerPanel(TriggersPackage pak, T trigger) { super(new BorderLayout()); this.pak = pak; this.trigger = trigger; this.tree_root = new DefaultMutableTreeNode(trigger.getName()); this.group_events = new TriggerEventRoot(); this.group_conditions = new TriggerConditionsRoot(); this.group_actions = new TriggerActionRoot(); this.tree_root.add(group_events); this.tree_root.add(group_conditions); this.tree_root.add(group_actions); this.tree_view = new TriggerTreeView(); this.comment.setText(trigger.comment); split.setTopComponent(split_h); split.setBottomComponent(south_h); JScrollPane left = new JScrollPane(tree_view); left.setMinimumSize(new Dimension(200, 120)); split_h.setLeftComponent(left); split_h.setRightComponent(new JScrollPane(comment)); split_h.setMinimumSize(new Dimension(200, 160)); tree_view.expandAll(); this.add(split); super.addAncestorListener(this); }
public void setup(ISettingsManager settingsManager, BattleProperties battleProperties) { this.settingsManager = settingsManager; this.battleProperties = battleProperties; EventHandler eventHandler = new EventHandler(); battlefieldWidthSlider = createBattlefieldSizeSlider(); battlefieldWidthSlider.setOrientation(SwingConstants.HORIZONTAL); battlefieldHeightSlider = createBattlefieldSizeSlider(); battlefieldHeightSlider.setOrientation(SwingConstants.VERTICAL); battlefieldHeightSlider.setInverted(true); battlefieldSizeLabel = new BattlefieldSizeLabel(); battlefieldSizeLabel.setHorizontalAlignment(SwingConstants.CENTER); battlefieldSizeLabel.setMinimumSize(new Dimension(50, 50)); battlefieldSizeLabel.setMaximumSize(new Dimension(500, 500)); battlefieldWidthSlider.addChangeListener(eventHandler); battlefieldHeightSlider.addChangeListener(eventHandler); JPanel rulesPanel = createRulesPanel(); rulesPanel.addAncestorListener(eventHandler); restoreDefaultsButton.addActionListener(eventHandler); setLayout(new BorderLayout()); add(rulesPanel, BorderLayout.WEST); add(restoreDefaultsButton, BorderLayout.SOUTH); add(createBattlefieldSizePanel(), BorderLayout.CENTER); }
private JPanel createBattlefieldSizePanel() { JPanel panel = new JPanel(); panel.addAncestorListener(eventHandler); Border border = BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), "Battlefield Size"), BorderFactory.createEmptyBorder(10, 10, 10, 10)); panel.setBorder(border); panel.setLayout(new BorderLayout()); JPanel sliderPanel = createBattlefieldSlidersPanel(); panel.add(sliderPanel, BorderLayout.CENTER); JPanel buttonsPanel = createPredefinedSizesPanel(); panel.add(buttonsPanel, BorderLayout.EAST); return panel; }
private JPanel createRulesPanel() { JPanel panel = new JPanel(); panel.addAncestorListener(new EventHandler()); panel.setBorder(BorderFactory.createEtchedBorder()); GroupLayout layout = new GroupLayout(panel); layout.setAutoCreateContainerGaps(true); layout.setAutoCreateGaps(true); panel.setLayout(layout); GroupLayout.SequentialGroup leftToRight = layout.createSequentialGroup(); GroupLayout.ParallelGroup left = layout.createParallelGroup(); left.addComponent(numberOfRoundsLabel); left.addComponent(gunCoolingRateLabel); left.addComponent(inactivityTimeLabel); left.addComponent(sentryBorderSizeLabel); left.addComponent(hideEnemyNamesLabel); leftToRight.addGroup(left); GroupLayout.ParallelGroup right = layout.createParallelGroup(); right.addComponent(getNumberOfRoundsTextField()); right.addComponent(getGunCoolingRateTextField()); right.addComponent(getInactivityTimeTextField()); right.addComponent(getSentryBorderSizeTextField()); right.addComponent(hideEnemyNamesCheckBox); leftToRight.addGroup(right); GroupLayout.SequentialGroup topToBottom = layout.createSequentialGroup(); GroupLayout.ParallelGroup row0 = layout.createParallelGroup(Alignment.BASELINE); row0.addComponent(numberOfRoundsLabel); row0.addComponent(numberOfRoundsTextField); topToBottom.addGroup(row0); GroupLayout.ParallelGroup row1 = layout.createParallelGroup(Alignment.BASELINE); row1.addComponent(gunCoolingRateLabel); row1.addComponent(getGunCoolingRateTextField()); topToBottom.addGroup(row1); GroupLayout.ParallelGroup row2 = layout.createParallelGroup(Alignment.BASELINE); row2.addComponent(inactivityTimeLabel); row2.addComponent(inactivityTimeTextField); topToBottom.addGroup(row2); GroupLayout.ParallelGroup row3 = layout.createParallelGroup(Alignment.BASELINE); row3.addComponent(sentryBorderSizeLabel); row3.addComponent(sentryBorderSizeTextField); topToBottom.addGroup(row3); GroupLayout.ParallelGroup row4 = layout.createParallelGroup(Alignment.CENTER); row4.addComponent(hideEnemyNamesLabel); row4.addComponent(hideEnemyNamesCheckBox); topToBottom.addGroup(row4); layout.setHorizontalGroup(leftToRight); layout.setVerticalGroup(topToBottom); return panel; }