@Override public void stateChanged(ChangeEvent event) { if (event.getSource() == spaceSpinner) { int space = (Integer) spaceSpinner.getValue(); SINGLE_COLUMN.setSpace(space); SINGLE_ROW.setSpace(space); sectionViewer.updateUI(); } }
@Override public void actionPerformed(ActionEvent event) { if (event.getSource() == addSection) { LocalSection section = new LocalSection(id++); sectionViewer.addSection(section); } else if (event.getSource() == addGlue) { // panel.addComp(panel.getLayoutOrganizer() == SINGLE_COLUMN ? // Box.createVerticalGlue() : Box.createHorizontalGlue()); } else if (event.getSource() == addTextField0) { for (Component component : sectionViewer.getSections()) System.out.println( String.format( "%s: [%d;%d] w:%d h:%d", component, component.getX(), component.getY(), component.getWidth(), component.getHeight())); System.out.println(); // panel.addComp(new JTextField("This is a text field")); } else if (event.getSource() == addTextField1) { // JTextField textField = new JTextField(10); // textField.setText("Text field with 10 columns"); // panel.addComp(textField); } else if (event.getSource() == removeLast) { int total = sectionViewer.getSectionsAmount(); if (total > 0) { LocalSection section = sectionViewer.getSections().get(total - 1); sectionViewer.removeSection(section); } } else if (event.getSource() == changeBackground) sectionViewer.setBackground(new Color(rand.nextInt(0xFFFFFF))); else if (event.getSource() == columnStrategy) sectionViewer.setLayoutOrganizer(SINGLE_COLUMN); else if (event.getSource() == rowStrategy) sectionViewer.setLayoutOrganizer(SINGLE_ROW); else if (event.getSource() == alignmentCombo) { Alignment alignment = (Alignment) alignmentCombo.getSelectedItem(); SINGLE_COLUMN.setAlignment(alignment.value); SINGLE_ROW.setAlignment(alignment.value); sectionViewer.updateUI(); } }