private static JPanel createLinePanel(String name, JTextField lineTextField, JComboBox linePlacementCombo, JComboBox lineAlignmentCombo) { JPanel panel = new JPanel(); panel.setBorder(IdeBorderFactory.createTitledBorder(name, true)); panel.setLayout(new GridBagLayout()); GridBagConstraints gbConstraints = new GridBagConstraints(); gbConstraints.gridy = 0; gbConstraints.gridx = 0; gbConstraints.gridwidth = 1; gbConstraints.gridheight = 1; gbConstraints.weightx = 0; gbConstraints.fill = GridBagConstraints.BOTH; gbConstraints.insets = new Insets(0, 0, 6, 0); panel.add(new MyLabel(CodeEditorBundle.message("print.header.text.line.editbox")), gbConstraints); gbConstraints.gridx = 1; gbConstraints.gridwidth = 4; gbConstraints.weightx = 1; panel.add(lineTextField, gbConstraints); gbConstraints.gridwidth = 1; gbConstraints.gridy++; gbConstraints.gridx = 0; gbConstraints.weightx = 0; panel.add(new MyLabel(CodeEditorBundle.message("print.header.placement.combobox")), gbConstraints); linePlacementCombo.addItem(PrintSettings.HEADER); linePlacementCombo.addItem(PrintSettings.FOOTER); linePlacementCombo.setRenderer(new MappingListCellRenderer(linePlacementCombo.getRenderer(), PLACEMENT_MAP)); gbConstraints.gridx = 1; gbConstraints.weightx = 0; panel.add(linePlacementCombo, gbConstraints); gbConstraints.gridx = 2; gbConstraints.weightx = 1; panel.add(new MyTailPanel(), gbConstraints); gbConstraints.gridx = 3; gbConstraints.weightx = 0; panel.add(new MyLabel(CodeEditorBundle.message("print.header.alignment.combobox")), gbConstraints); linePlacementCombo.setRenderer(new MappingListCellRenderer(linePlacementCombo.getRenderer(), ALIGNMENT_MAP)); lineAlignmentCombo.addItem(PrintSettings.LEFT); lineAlignmentCombo.addItem(PrintSettings.CENTER); lineAlignmentCombo.addItem(PrintSettings.RIGHT); gbConstraints.gridx = 4; gbConstraints.weightx = 0; panel.add(lineAlignmentCombo, gbConstraints); return panel; }
public FormLayoutColumnProperties() { @NonNls String[] unitNames = new String[]{"px", "dlu", "pt", "in", "cm", "mm"}; myConstantSizeUnitsCombo.setModel(new DefaultComboBoxModel(unitNames)); myMinSizeUnitsCombo.setModel(new DefaultComboBoxModel(unitNames)); myMaxSizeUnitsCombo.setModel(new DefaultComboBoxModel(unitNames)); myConstantSizeUnitsCombo.setRenderer(new MappingListCellRenderer(myConstantSizeUnitsCombo.getRenderer(), UNITS_MAP)); myMinSizeUnitsCombo.setRenderer(new MappingListCellRenderer(myMinSizeUnitsCombo.getRenderer(), UNITS_MAP)); myMaxSizeUnitsCombo.setRenderer(new MappingListCellRenderer(myMaxSizeUnitsCombo.getRenderer(), UNITS_MAP)); final MyRadioListener listener = new MyRadioListener(); myDefaultRadioButton.addActionListener(listener); myPreferredRadioButton.addActionListener(listener); myMinimumRadioButton.addActionListener(listener); myConstantRadioButton.addActionListener(listener); myMinimumCheckBox.addChangeListener(new MyCheckboxListener(myMinimumCheckBox, myMinSizeUnitsCombo, myMinSizeSpinner)); myMaximumCheckBox.addChangeListener(new MyCheckboxListener(myMaximumCheckBox, myMaxSizeUnitsCombo, myMaxSizeSpinner)); myConstantRadioButton.addChangeListener(new MyCheckboxListener(myConstantRadioButton, myConstantSizeUnitsCombo, myConstantSizeSpinner)); updateOnRadioChange(); myGrowCheckBox.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { myGrowSpinner.setEnabled(myGrowCheckBox.isSelected()); updateSpec(); } }); final MyChangeListener changeListener = new MyChangeListener(); myGrowSpinner.setModel(new SpinnerNumberModel(1.0, 0.0, 10.0, 0.1)); myGrowSpinner.addChangeListener(changeListener); myMinSizeSpinner.addChangeListener(changeListener); myMaxSizeSpinner.addChangeListener(changeListener); myConstantSizeSpinner.addChangeListener(changeListener); myLeftRadioButton.addChangeListener(changeListener); myCenterRadioButton.addChangeListener(changeListener); myRightRadioButton.addChangeListener(changeListener); myFillRadioButton.addChangeListener(changeListener); final MyItemListener itemListener = new MyItemListener(); myMinSizeUnitsCombo.addItemListener(itemListener); myMaxSizeUnitsCombo.addItemListener(itemListener); myConstantSizeUnitsCombo.addItemListener(itemListener); }