/** * Sets the combo-boxes to a fixed size so they don't take up too much room that would be better * devoted to the test output box */ protected void setComboSizes() { m_DatasetKeyBut.setPreferredSize(COMBO_SIZE); m_RunCombo.setPreferredSize(COMBO_SIZE); m_ResultKeyBut.setPreferredSize(COMBO_SIZE); m_CompareCombo.setPreferredSize(COMBO_SIZE); m_SigTex.setPreferredSize(COMBO_SIZE); m_DatasetKeyBut.setMaximumSize(COMBO_SIZE); m_RunCombo.setMaximumSize(COMBO_SIZE); m_ResultKeyBut.setMaximumSize(COMBO_SIZE); m_CompareCombo.setMaximumSize(COMBO_SIZE); m_SigTex.setMaximumSize(COMBO_SIZE); m_DatasetKeyBut.setMinimumSize(COMBO_SIZE); m_RunCombo.setMinimumSize(COMBO_SIZE); m_ResultKeyBut.setMinimumSize(COMBO_SIZE); m_CompareCombo.setMinimumSize(COMBO_SIZE); m_SigTex.setMinimumSize(COMBO_SIZE); // =============== BEGIN EDIT melville =============== m_PrecTex.setPreferredSize(COMBO_SIZE); m_PrecTex.setMaximumSize(COMBO_SIZE); m_PrecTex.setMinimumSize(COMBO_SIZE); // =============== END EDIT melville =============== }
/** Initialisiert die Komponenten. */ private void initComponents() { setBorder(border); phone.setMinimumSize(new Dimension(120, 20)); phone.setPreferredSize(new Dimension(120, 20)); fax.setMinimumSize(new Dimension(120, 20)); fax.setPreferredSize(new Dimension(120, 20)); email.setMinimumSize(new Dimension(120, 20)); email.setPreferredSize(new Dimension(120, 20)); }
/** Initialise l'interface graphique */ public void initDialog() { content = new JPanel(); namepanel = new JPanel(); namepanel.setBorder(BorderFactory.createTitledBorder("Nom du Flux")); name = new JTextField(); name.setPreferredSize(new Dimension(300, 20)); name.setMaximumSize(new Dimension(300, 20)); name.setMinimumSize(new Dimension(200, 20)); namepanel.add(name); urlpanel = new JPanel(); urlpanel.setBorder(BorderFactory.createTitledBorder("URL du Flux")); url = new JTextField(); url.setPreferredSize(new Dimension(300, 20)); url.setMaximumSize(new Dimension(300, 20)); url.setMinimumSize(new Dimension(200, 20)); urlpanel.add(url); categorypanel = new JPanel(); categorypanel.setBorder(BorderFactory.createTitledBorder("Categories")); categorypanel.setPreferredSize(new Dimension(300, 70)); category = new JComboBox(); category.addItem(listeCategories.get(0)); newCategory = new JButton("Nouvelle Categorie"); newCategory.setActionCommand("NewCatAddSource"); categorypanel.add(category); categorypanel.add(newCategory); content.add(namepanel, BorderLayout.NORTH); content.add(urlpanel, BorderLayout.WEST); content.add(categorypanel, BorderLayout.EAST); control = new JPanel(); okbutton = new JButton("OK"); okbutton.setActionCommand("OkAddSource"); cancel = new JButton("Annuler"); cancel.setActionCommand("CancelAddSource"); defaultbutton = new JButton("Reinitialiser"); defaultbutton.setActionCommand("RenewAddSource"); control.add(okbutton); control.add(cancel); control.add(defaultbutton); this.getContentPane().add(content, BorderLayout.CENTER); this.getContentPane().add(control, BorderLayout.SOUTH); }
public void addGroupComponent(JComponent component) { handleComponentAdded(component); Insets insets; if (currentRow == 0) { insets = INSETS; } else if (component instanceof JRadioButton) { insets = INSETS; } else if (component instanceof JCheckBox) { insets = INSETS; } else { insets = new Insets(4, 0, 4, 0); } backingPanel.add( component, new GridBagConstraints( 1, currentRow, 2, 1, 100, 0, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.NONE, insets, 0, 0)); if (component instanceof JTextField) { JTextField field = (JTextField) component; field.setMinimumSize(field.getPreferredSize()); } currentRow++; }
private ControlSlider( String labelText, String unitText, int minVal, int maxVal, int defaultVal, JPanel myParent) { JPanel sliderPanel = new JPanel(); slider = new JSlider(JSlider.HORIZONTAL); field = new JTextField(); sliderPanel.add(new JLabel(labelText)); // int maxFeedrate = (int)machine.getModel().getMaximumFeedrates().axis(axis); // int currentFeedrate = Math.min(maxFeedrate, Base.preferences.getInt(getPrefName(),480)); slider.setMinimum(minVal); slider.setMaximum(maxVal); slider.setValue(defaultVal); slider.addChangeListener(this); slider.setPaintLabels(true); slider.setPaintTicks(true); slider.setMajorTickSpacing(100); sliderPanel.add(slider, "growx"); field.setMinimumSize(new Dimension(75, 22)); field.setEnabled(true); field.setText(Integer.toString(defaultVal)); field.addFocusListener(this); field.addActionListener(this); sliderPanel.add(field, "growx,wrap"); sliderPanel.add(new JLabel(unitText), "growx,wrap"); myParent.add(sliderPanel, "wrap"); }
protected JTextField createDisplayField() { int textBoxWidth = 160; JTextField tf = new JTextField(); tf.setMaximumSize(new Dimension(textBoxWidth, 25)); tf.setMinimumSize(new Dimension(textBoxWidth, 25)); tf.setPreferredSize(new Dimension(textBoxWidth, 25)); tf.setEnabled(false); return tf; }
/** * This method initializes txtDisplay * * @return javax.swing.JTextField */ JTextField getTxtDisplay() { if (txtDisplay == null) { txtDisplay = new JTextField(""); txtDisplay.setHorizontalAlignment(javax.swing.JTextField.LEFT); txtDisplay.setAlignmentX(0.0F); txtDisplay.setPreferredSize(new java.awt.Dimension(250, 20)); txtDisplay.setText(""); txtDisplay.setMinimumSize(new java.awt.Dimension(250, 20)); txtDisplay.setMaximumSize(new java.awt.Dimension(250, 20)); } return txtDisplay; }
private void initUI() { setTitle("Project Flacon! (Joe version)"); setSize(250, 150); setLayout(new BorderLayout()); add(new JLabel("PROJECT FALCON"), BorderLayout.NORTH); // title JLabel printed = new JLabel(); // output JTextField minTextBox = new JTextField(); minTextBox.setMinimumSize(new Dimension(10, 25)); JTextField maxTextBox = new JTextField(); maxTextBox.setMinimumSize(new Dimension(10, 25)); JButton btn = new JButton("Print Num"); // button, middle btn.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { String cell1text = minTextBox.getText(); String cell2text = maxTextBox.getText(); try { int min = Integer.parseInt(cell1text); int max = Integer.parseInt(cell2text); printed.setText((new Random().nextInt(max - min + 1) + min) + ""); } catch (Exception ex) { // do nothing } } }); JPanel textPanel = new JPanel(); textPanel.setLayout(new GridLayout(1, 2)); textPanel.add(minTextBox); textPanel.add(maxTextBox); add(textPanel, BorderLayout.CENTER); add(btn, BorderLayout.EAST); add(printed, BorderLayout.SOUTH); setLocationRelativeTo(null); setDefaultCloseOperation(EXIT_ON_CLOSE); }
@Override protected JComponent buildWidget() { widget = new JTextField(); widget.setPreferredSize(LABEL_DIM); widget.setMinimumSize(LABEL_DIM); widget.setBorder(ETCHED); widget.addFocusListener(this); widget.addKeyListener(this); updateWidget(); return widget; }
public void addItem(String name) { JTextField txtItem = new JTextField(); txtItem.setEditable(false); txtItem.setBorder(BorderFactory.createLoweredBevelBorder()); txtItem.setToolTipText(Messages.getString(name)); Dimension dim = new Dimension(100, 20); txtItem.setMinimumSize(dim); txtItem.setMaximumSize(dim); txtItem.setPreferredSize(dim); _items.put(name, txtItem); _statusPanel.add(txtItem); }
public ParamsPanel(String label) { super(); setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS)); add(Box.createRigidArea(DOUBLE_HSPACE)); add(new JLabel(label)); add(Box.createRigidArea(SINGLE_HSPACE)); textField = new JTextField(60); textField.setMinimumSize(textField.getPreferredSize()); add(textField); add(Box.createRigidArea(TRIPLE_HSPACE)); searchButton = new JButton("Search"); add(searchButton); }
/** * Creates a text field to display the directory path * * @return the text field */ public JTextField createTextField() { JTextField text = new JTextField(); text.setPreferredSize(favoriteDim); text.setMinimumSize(favoriteDim); text.setHorizontalAlignment(JTextField.LEFT); text.setEditable(true); text.setBackground(Color.white); text.setEditable(false); text.setInputVerifier( new InputVerifier() { public boolean verify(JComponent input) { return false; } }); return text; }
/** * Sets the combo-boxes to a fixed size so they don't take up too much room that would be better * devoted to the test output box. */ protected void setComboSizes() { m_TesterClasses.setPreferredSize(COMBO_SIZE); m_PanelDatasetResultKeys.setPreferredSize(COMBO_SIZE); m_CompareCombo.setPreferredSize(COMBO_SIZE); m_SigTex.setPreferredSize(COMBO_SIZE); m_SortCombo.setPreferredSize(COMBO_SIZE); m_TesterClasses.setMaximumSize(COMBO_SIZE); m_PanelDatasetResultKeys.setMaximumSize(COMBO_SIZE); m_CompareCombo.setMaximumSize(COMBO_SIZE); m_SigTex.setMaximumSize(COMBO_SIZE); m_SortCombo.setMaximumSize(COMBO_SIZE); m_TesterClasses.setMinimumSize(COMBO_SIZE); m_PanelDatasetResultKeys.setMinimumSize(COMBO_SIZE); m_CompareCombo.setMinimumSize(COMBO_SIZE); m_SigTex.setMinimumSize(COMBO_SIZE); m_SortCombo.setMinimumSize(COMBO_SIZE); }
public void addIndentedGroupComponent(JComponent component) { handleComponentAdded(component); backingPanel.add( component, new GridBagConstraints( 1, currentRow, 2, 1, 100, 0, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.NONE, new Insets(0, 50, 0, 0), 0, 0)); if (component instanceof JTextField) { JTextField field = (JTextField) component; field.setMinimumSize(field.getPreferredSize()); } currentRow++; }
/* * Create and set up a new CoreqPanel that is the correct size. Do not allow the user to modify any * of the characteristics of the panel; the panel will be the same for any course. */ public CoreqPanel() { this.setMinimumSize(new Dimension(800, 25)); this.setMaximumSize(new Dimension(2600, 26)); this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); coreqField = new JTextField(); coreqField.setMinimumSize(new Dimension(300, 20)); coreqField.setMaximumSize(new Dimension(2000, 21)); coreqType = new JComboBox(); coreqType.addItem("Credits"); coreqType.addItem("Course"); coreqType.addItem("Requirement"); coreqType.setMinimumSize(new Dimension(100, 20)); coreqType.setMaximumSize(new Dimension(100, 21)); JLabel coreqName = new JLabel("Name of Corequisite: "); this.add(coreqName); this.add(coreqField); this.add(Box.createRigidArea(new Dimension(10, 0))); this.add(coreqType); this.add(Box.createGlue()); }
/** * Création d'un dialogue avec message d'erreur. * * @param owner Fenetre parente. * @param message Titre * @param errorMessage Message d'erreur */ public ErrorDialog(final Window owner, final String message, final String errorMessage) { super(owner); setModal(true); setLayout(new BorderLayout()); final JLabel label = new JLabel(message); add(label, BorderLayout.NORTH); final JTextField myArea = new JTextField(errorMessage); myArea.setEditable(false); myArea.setMinimumSize(MINIMUM_SIZE); add(myArea, BorderLayout.CENTER); final JButton ok = new JButton("Ok"); add(ok, BorderLayout.SOUTH); ok.addActionListener( new ActionListener() { public void actionPerformed(final ActionEvent arg0) { dispose(); } }); pack(); }
void jbInit() throws Exception { this.setResizable(false); // Build headerPanel headerPanel.setBackground(Color.WHITE); headerPanel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); header.setFont(new java.awt.Font("Dialog", 0, 20)); header.setForeground(new Color(0, 0, 124)); header.setText(Local.getString("Event")); header.setIcon( new ImageIcon( net.sf.memoranda.ui.EventDialog.class.getResource("resources/icons/event48.png"))); headerPanel.add(header); // Build eventPanel lblTime.setText(Local.getString("Time")); lblTime.setMinimumSize(new Dimension(60, 24)); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.insets = new Insets(10, 10, 5, 10); gbc.anchor = GridBagConstraints.WEST; eventPanel.add(lblTime, gbc); timeSpin.setPreferredSize(new Dimension(60, 24)); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 0; gbc.insets = new Insets(10, 0, 5, 5); gbc.anchor = GridBagConstraints.WEST; eventPanel.add(timeSpin, gbc); lblText.setText(Local.getString("Text")); lblText.setMinimumSize(new Dimension(120, 24)); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 1; gbc.gridwidth = 3; gbc.insets = new Insets(5, 10, 5, 10); gbc.anchor = GridBagConstraints.WEST; eventPanel.add(lblText, gbc); textField.setMinimumSize(new Dimension(375, 24)); textField.setPreferredSize(new Dimension(375, 24)); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 2; gbc.gridwidth = 6; gbc.insets = new Insets(5, 10, 10, 10); gbc.anchor = GridBagConstraints.WEST; gbc.fill = GridBagConstraints.HORIZONTAL; eventPanel.add(textField, gbc); // Build RepeatPanel repeatBorder = new TitledBorder(BorderFactory.createLineBorder(Color.gray, 1), Local.getString("Repeat")); // Added by (jcscoobyrs) on 12-Nov-2003 at 15:34:27 PM // --------------------------------------------------- SimpleDateFormat sdf = new SimpleDateFormat(); sdf = (SimpleDateFormat) DateFormat.getDateInstance(DateFormat.SHORT); // Build ButtonsPanel okB.setMaximumSize(new Dimension(100, 26)); okB.setMinimumSize(new Dimension(100, 26)); okB.setPreferredSize(new Dimension(100, 26)); okB.setText(Local.getString("Ok")); okB.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { okB_actionPerformed(e); } }); this.getRootPane().setDefaultButton(okB); cancelB.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { cancelB_actionPerformed(e); } }); cancelB.setText(Local.getString("Cancel")); cancelB.setPreferredSize(new Dimension(100, 26)); cancelB.setMinimumSize(new Dimension(100, 26)); cancelB.setMaximumSize(new Dimension(100, 26)); buttonsPanel.add(okB); buttonsPanel.add(cancelB); // Finally build the Dialog topPanel.add(headerPanel, BorderLayout.NORTH); topPanel.add(eventPanel, BorderLayout.SOUTH); GridBagConstraints gbc_repeatPanel = new GridBagConstraints(); gbc_repeatPanel.insets = new Insets(0, 0, 0, 5); gbc_repeatPanel.gridx = 1; gbc_repeatPanel.gridy = 3; eventPanel.add(repeatPanel, gbc_repeatPanel); repeatPanel.setBorder(repeatBorder); noRepeatRB.setMaximumSize(new Dimension(80, 35)); noRepeatRB.setSelected(true); noRepeatRB.setText(Local.getString("No repeat")); noRepeatRB.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { noRepeatRB_actionPerformed(e); } }); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.gridwidth = 4; gbc.insets = new Insets(5, 5, 5, 0); gbc.anchor = GridBagConstraints.WEST; gbc.fill = GridBagConstraints.HORIZONTAL; repeatPanel.add(noRepeatRB, gbc); dailyRepeatRB.setActionCommand("daily"); dailyRepeatRB.setText(Local.getString("Every")); dailyRepeatRB.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { dailyRepeatRB_actionPerformed(e); } }); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 1; gbc.insets = new Insets(5, 5, 5, 0); gbc.anchor = GridBagConstraints.WEST; repeatPanel.add(dailyRepeatRB, gbc); daySpin.setPreferredSize(new Dimension(50, 24)); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 1; gbc.insets = new Insets(5, 5, 5, 0); gbc.anchor = GridBagConstraints.WEST; repeatPanel.add(daySpin, gbc); lblDays.setText(Local.getString("day(s)")); gbc = new GridBagConstraints(); gbc.gridx = 2; gbc.gridy = 1; gbc.gridwidth = 2; gbc.insets = new Insets(5, 5, 5, 40); gbc.anchor = GridBagConstraints.WEST; repeatPanel.add(lblDays, gbc); lblSince.setText(Local.getString("Since")); lblSince.setMinimumSize(new Dimension(70, 16)); gbc = new GridBagConstraints(); gbc.gridx = 4; gbc.gridy = 1; gbc.insets = new Insets(5, 0, 5, 5); gbc.anchor = GridBagConstraints.EAST; repeatPanel.add(lblSince, gbc); startDate.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { if (ignoreStartChanged) return; ignoreStartChanged = true; Date sd = (Date) startDate.getModel().getValue(); Date ed = (Date) endDate.getModel().getValue(); // Commented out, value was resetted to endDate !!! if (sd.after(ed)) { endDate.getModel().setValue(sd); ed = sd; } startCalFrame.cal.set(new CalendarDate(sd)); ignoreStartChanged = false; } }); startDate.setPreferredSize(new Dimension(80, 24)); startDate.setEditor(new JSpinner.DateEditor(startDate, sdf.toPattern())); // --------------------------------------------------- gbc = new GridBagConstraints(); gbc.gridx = 5; gbc.gridy = 1; gbc.insets = new Insets(5, 0, 5, 5); gbc.anchor = GridBagConstraints.WEST; repeatPanel.add(startDate, gbc); setStartDateB.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { setStartDateB_actionPerformed(e); } }); setStartDateB.setIcon( new ImageIcon( net.sf.memoranda.ui.AppFrame.class.getResource("resources/icons/calendar.png"))); setStartDateB.setText(""); setStartDateB.setPreferredSize(new Dimension(24, 24)); gbc = new GridBagConstraints(); gbc.gridx = 6; gbc.gridy = 1; gbc.insets = new Insets(5, 0, 5, 5); gbc.anchor = GridBagConstraints.WEST; repeatPanel.add(setStartDateB, gbc); weeklyRepeatRB.setActionCommand("weekly"); weeklyRepeatRB.setText(Local.getString("Every")); weeklyRepeatRB.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { weeklyRepeatRB_actionPerformed(e); } }); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 2; gbc.insets = new Insets(5, 5, 5, 5); gbc.anchor = GridBagConstraints.WEST; repeatPanel.add(weeklyRepeatRB, gbc); weekdaysCB.setPreferredSize(new Dimension(100, 25)); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 2; gbc.gridwidth = 2; gbc.insets = new Insets(5, 0, 5, 40); gbc.anchor = GridBagConstraints.WEST; repeatPanel.add(weekdaysCB, gbc); enableEndDateCB.setHorizontalAlignment(SwingConstants.RIGHT); enableEndDateCB.setText(Local.getString("Till")); enableEndDateCB.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { enableEndDateCB_actionPerformed(e); } }); gbc = new GridBagConstraints(); gbc.gridx = 4; gbc.gridy = 2; gbc.insets = new Insets(5, 0, 5, 5); gbc.anchor = GridBagConstraints.EAST; repeatPanel.add(enableEndDateCB, gbc); endDate.setPreferredSize(new Dimension(80, 24)); // Added by (jcscoobyrs) on 12-Nov-2003 at 15:34:27 PM // --------------------------------------------------- endDate.setEditor(new JSpinner.DateEditor(endDate, sdf.toPattern())); // --------------------------------------------------- endDate.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { if (ignoreEndChanged) return; ignoreEndChanged = true; Date sd = (Date) startDate.getModel().getValue(); Date ed = (Date) endDate.getModel().getValue(); if (sd.after(ed)) { endDate.getModel().setValue(sd); ed = sd; } endCalFrame.cal.set(new CalendarDate(ed)); ignoreEndChanged = false; } }); // working days workingDaysOnlyCB.setText(Local.getString("Working days only")); workingDaysOnlyCB.setHorizontalAlignment(SwingConstants.RIGHT); gbc = new GridBagConstraints(); gbc.gridx = 4; gbc.gridy = 3; gbc.gridwidth = 2; gbc.insets = new Insets(5, 0, 5, 5); gbc.anchor = GridBagConstraints.EAST; repeatPanel.add(workingDaysOnlyCB, gbc); // ------------------------------------- gbc = new GridBagConstraints(); gbc.gridx = 5; gbc.gridy = 2; gbc.insets = new Insets(5, 0, 5, 5); gbc.anchor = GridBagConstraints.WEST; repeatPanel.add(endDate, gbc); setEndDateB.setMinimumSize(new Dimension(24, 24)); setEndDateB.setPreferredSize(new Dimension(24, 24)); setEndDateB.setText(""); setEndDateB.setIcon( new ImageIcon( net.sf.memoranda.ui.AppFrame.class.getResource("resources/icons/calendar.png"))); setEndDateB.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { setEndDateB_actionPerformed(e); } }); gbc = new GridBagConstraints(); gbc.gridx = 6; gbc.gridy = 2; gbc.insets = new Insets(5, 0, 5, 5); gbc.anchor = GridBagConstraints.WEST; repeatPanel.add(setEndDateB, gbc); monthlyRepeatRB.setActionCommand("daily"); monthlyRepeatRB.setText(Local.getString("Every")); monthlyRepeatRB.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { monthlyRepeatRB_actionPerformed(e); } }); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 3; gbc.insets = new Insets(5, 5, 5, 5); gbc.anchor = GridBagConstraints.WEST; repeatPanel.add(monthlyRepeatRB, gbc); dayOfMonthSpin.setPreferredSize(new Dimension(50, 24)); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 3; gbc.insets = new Insets(5, 5, 5, 5); gbc.anchor = GridBagConstraints.WEST; repeatPanel.add(dayOfMonthSpin, gbc); lblDoM.setText(Local.getString("day of month")); gbc = new GridBagConstraints(); gbc.gridx = 2; gbc.gridy = 3; gbc.insets = new Insets(5, 5, 5, 5); gbc.anchor = GridBagConstraints.WEST; repeatPanel.add(lblDoM, gbc); yearlyRepeatRB.setActionCommand("yearly"); yearlyRepeatRB.setText(Local.getString("Yearly")); yearlyRepeatRB.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { yearlyRepeatRB_actionPerformed(e); } }); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 4; gbc.gridwidth = 5; gbc.insets = new Insets(5, 5, 5, 10); gbc.anchor = GridBagConstraints.WEST; repeatPanel.add(yearlyRepeatRB, gbc); // Exception label lblExceptions.setText("Specific days to not recur on (exceptions)"); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 5; gbc.gridwidth = 2; gbc.insets = new Insets(5, 5, 5, 10); gbc.anchor = GridBagConstraints.WEST; repeatPanel.add(lblExceptions, gbc); // Exception text field exceptionDate.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { if (ignoreExceptionChanged) return; ignoreExceptionChanged = true; Date exd = (Date) exceptionDate.getModel().getValue(); exceptionCalFrame.cal.set(new CalendarDate(exd)); ignoreExceptionChanged = false; } }); exceptionDate.setPreferredSize(new Dimension(80, 24)); exceptionDate.setEditor(new JSpinner.DateEditor(exceptionDate, sdf.toPattern())); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 6; gbc.insets = new Insets(5, 5, 5, 4); gbc.anchor = GridBagConstraints.WEST; repeatPanel.add(exceptionDate, gbc); // Exception Calendar Button setExceptionDateB.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { setExceptionDateB_actionPerformed(e); } }); setExceptionDateB.setIcon( new ImageIcon( net.sf.memoranda.ui.AppFrame.class.getResource("resources/icons/calendar.png"))); setExceptionDateB.setText(""); setExceptionDateB.setPreferredSize(new Dimension(24, 24)); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 6; gbc.insets = new Insets(5, 0, 5, 4); gbc.anchor = GridBagConstraints.WEST; repeatPanel.add(setExceptionDateB, gbc); // Exception date add button addExceptionDate.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { addExceptionDate_actionPerformed(e); } }); addExceptionDate.setText("Add"); addExceptionDate.setPreferredSize(new Dimension(80, 24)); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 6; gbc.insets = new Insets(2, 36, 5, 2); gbc.anchor = GridBagConstraints.WEST; repeatPanel.add(addExceptionDate, gbc); // Exception List exceptionPane.setPreferredSize(new Dimension(136, 96)); gbc = new GridBagConstraints(); gbc.gridx = 2; gbc.gridy = 6; gbc.gridwidth = 4; gbc.gridheight = 4; gbc.insets = new Insets(5, 5, 5, 5); gbc.anchor = GridBagConstraints.WEST; repeatPanel.add(exceptionPane, gbc); // Exception date remove button removeExceptionDate.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { removeExceptionDate_actionPerformed(e); } }); removeExceptionDate.setText("Remove"); removeExceptionDate.setPreferredSize(new Dimension(80, 24)); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 7; gbc.insets = new Insets(2, 36, 5, 2); gbc.anchor = GridBagConstraints.WEST; repeatPanel.add(removeExceptionDate, gbc); repeatRBGroup.add(noRepeatRB); repeatRBGroup.add(dailyRepeatRB); repeatRBGroup.add(weeklyRepeatRB); repeatRBGroup.add(monthlyRepeatRB); repeatRBGroup.add(yearlyRepeatRB); bottomPanel.add(buttonsPanel, BorderLayout.SOUTH); this.getContentPane().add(topPanel, BorderLayout.NORTH); this.getContentPane().add(bottomPanel, BorderLayout.SOUTH); // Do final things... startCalFrame.cal.addSelectionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (ignoreStartChanged) return; startDate.getModel().setValue(startCalFrame.cal.get().getCalendar().getTime()); } }); endCalFrame.cal.addSelectionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (ignoreEndChanged) return; endDate.getModel().setValue(endCalFrame.cal.get().getCalendar().getTime()); } }); exceptionCalFrame.cal.addSelectionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (ignoreExceptionChanged) return; exceptionDate.getModel().setValue(exceptionCalFrame.cal.get().getCalendar().getTime()); } }); disableElements(); ((JSpinner.DateEditor) timeSpin.getEditor()).getFormat().applyPattern("HH:mm"); enableEndDateCB_actionPerformed(null); }
void jbInit() throws Exception { titledBorder1 = new TitledBorder( BorderFactory.createLineBorder(new Color(153, 153, 153), 2), "Assembler messages"); this.getContentPane().setLayout(borderLayout1); this.setIconifiable(true); this.setMaximizable(true); this.setResizable(true); this.setTitle("EDIT"); splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT); splitPane.setDividerLocation(470); sourceArea.setFont(new java.awt.Font("Monospaced", 0, 12)); controlPanel.setLayout(gridBagLayout1); controlPanel.setBorder(BorderFactory.createLoweredBevelBorder()); positionPanel.setLayout(gridBagLayout2); fileLabel.setText("Source file:"); fileText.setEditable(false); browseButton.setSelected(false); browseButton.setText("Browse ..."); assembleButton.setEnabled(false); assembleButton.setText("Assemble file"); saveButton.setEnabled(false); saveButton.setText("Save file"); lineLabel.setText("Line:"); lineText.setMinimumSize(new Dimension(50, 20)); lineText.setPreferredSize(new Dimension(50, 20)); lineText.setEditable(false); columnLabel.setText("Column:"); columnText.setMinimumSize(new Dimension(41, 20)); columnText.setPreferredSize(new Dimension(41, 20)); columnText.setEditable(false); columnText.setText(""); messageScrollPane.setBorder(titledBorder1); messageScrollPane.setMinimumSize(new Dimension(33, 61)); messageScrollPane.setPreferredSize(new Dimension(60, 90)); optionsButton.setEnabled(false); optionsButton.setText("Assembler options ..."); messageScrollPane.getViewport().add(messageList, null); messageList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); this.getContentPane().add(splitPane, BorderLayout.CENTER); splitPane.add(textScrollPane, JSplitPane.TOP); splitPane.add(controlPanel, JSplitPane.BOTTOM); textScrollPane.getViewport().add(sourceArea, null); controlPanel.add( fileLabel, new GridBagConstraints( 0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 0, 0), 0, 0)); controlPanel.add( fileText, new GridBagConstraints( 1, 0, 3, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 0, 0), 0, 0)); controlPanel.add( browseButton, new GridBagConstraints( 4, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 0, 5), 0, 0)); controlPanel.add( optionsButton, new GridBagConstraints( 2, 1, 1, 1, 1.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 0), 0, 0)); controlPanel.add( assembleButton, new GridBagConstraints( 3, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 0), 0, 0)); controlPanel.add( saveButton, new GridBagConstraints( 4, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 0, 5), 0, 0)); controlPanel.add( positionPanel, new GridBagConstraints( 0, 1, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 5, 0, 0), 0, 0)); positionPanel.add( lineLabel, new GridBagConstraints( 0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); positionPanel.add( lineText, new GridBagConstraints( 1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 0), 0, 0)); positionPanel.add( columnLabel, new GridBagConstraints( 2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 10, 0, 0), 0, 0)); positionPanel.add( columnText, new GridBagConstraints( 3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 0), 0, 0)); controlPanel.add( messageScrollPane, new GridBagConstraints( 0, 2, 5, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0)); }
public JComponent createComponent() { myPanel = new JPanel(new GridBagLayout()); myStartIndex = new JTextField(5); myEndIndex = new JTextField(5); myEntriesLimit = new JTextField(5); final FontMetrics fontMetrics = myStartIndex.getFontMetrics(myStartIndex.getFont()); final Dimension minSize = new Dimension(myStartIndex.getPreferredSize()); //noinspection HardCodedStringLiteral minSize.width = fontMetrics.stringWidth("AAAAA"); myStartIndex.setMinimumSize(minSize); myEndIndex.setMinimumSize(minSize); myEntriesLimit.setMinimumSize(minSize); JLabel startIndexLabel = new JLabel(DebuggerBundle.message("label.array.renderer.configurable.start.index")); startIndexLabel.setLabelFor(myStartIndex); JLabel endIndexLabel = new JLabel(DebuggerBundle.message("label.array.renderer.configurable.end.index")); endIndexLabel.setLabelFor(myEndIndex); JLabel entriesLimitLabel = new JLabel(DebuggerBundle.message("label.array.renderer.configurable.max.count1")); entriesLimitLabel.setLabelFor(myEntriesLimit); myPanel.add( startIndexLabel, new GridBagConstraints( 0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 8), 0, 0)); myPanel.add( myStartIndex, new GridBagConstraints( 1, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 8), 0, 0)); myPanel.add( endIndexLabel, new GridBagConstraints( 2, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 8), 0, 0)); myPanel.add( myEndIndex, new GridBagConstraints( 3, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); myPanel.add( entriesLimitLabel, new GridBagConstraints( 0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(4, 0, 0, 8), 0, 0)); myPanel.add( myEntriesLimit, new GridBagConstraints( 1, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(4, 0, 0, 8), 0, 0)); myPanel.add( new JLabel(DebuggerBundle.message("label.array.renderer.configurable.max.count2")), new GridBagConstraints( 2, GridBagConstraints.RELATIVE, 2, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(4, 0, 0, 0), 0, 0)); // push other components up myPanel.add( new JLabel(), new GridBagConstraints( 0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); final DocumentListener listener = new DocumentListener() { private void updateEntriesLimit() { final boolean state = myIndexUpdateEnabled; myIndexUpdateEnabled = false; try { if (myEntriesLimitUpdateEnabled) { myEntriesLimit.setText( String.valueOf(getInt(myEndIndex) - getInt(myStartIndex) + 1)); } } finally { myIndexUpdateEnabled = state; } } public void changedUpdate(DocumentEvent e) { updateEntriesLimit(); } public void insertUpdate(DocumentEvent e) { updateEntriesLimit(); } public void removeUpdate(DocumentEvent e) { updateEntriesLimit(); } }; myStartIndex.getDocument().addDocumentListener(listener); myEndIndex.getDocument().addDocumentListener(listener); myEntriesLimit .getDocument() .addDocumentListener( new DocumentListener() { private void updateEndIndex() { final boolean state = myEntriesLimitUpdateEnabled; myEntriesLimitUpdateEnabled = false; try { if (myIndexUpdateEnabled) { myEndIndex.setText( String.valueOf(getInt(myEntriesLimit) + getInt(myStartIndex) - 1)); } } finally { myEntriesLimitUpdateEnabled = state; } } public void insertUpdate(DocumentEvent e) { updateEndIndex(); } public void removeUpdate(DocumentEvent e) { updateEndIndex(); } public void changedUpdate(DocumentEvent e) { updateEndIndex(); } }); return myPanel; }
void jbInit() throws Exception { border1 = BorderFactory.createEmptyBorder(10, 10, 5, 5); panel1.setLayout(borderLayout1); jPanel1.setLayout(borderLayout2); jScrollPane1.getViewport().setBackground(Color.white); jPanel2.setLayout(gridBagLayout1); jLabel1.setText("Profile Name : "); nameTextField.setMinimumSize(new Dimension(4, 18)); nameTextField.setPreferredSize(new Dimension(63, 18)); jLabel2.setText("Profile Type : "); openButton.setMaximumSize(new Dimension(73, 24)); openButton.setMinimumSize(new Dimension(73, 24)); openButton.setPreferredSize(new Dimension(73, 24)); openButton.setText("Open"); openButton.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { openButton_actionPerformed(e); } }); cancelButton.setMaximumSize(new Dimension(73, 24)); cancelButton.setMinimumSize(new Dimension(73, 24)); cancelButton.setPreferredSize(new Dimension(73, 24)); cancelButton.setMargin(new Insets(0, 5, 0, 5)); cancelButton.setText("Cancel"); cancelButton.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { cancelButton_actionPerformed(e); } }); profileList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); profileList.addMouseListener( new java.awt.event.MouseAdapter() { public void mouseClicked(MouseEvent e) { profileList_mouseClicked(e); } }); jPanel2.setBorder(border1); typeComboBox.setMaximumSize(new Dimension(32767, 18)); typeComboBox.setMinimumSize(new Dimension(122, 18)); typeComboBox.setPreferredSize(new Dimension(176, 18)); getContentPane().add(panel1); panel1.add(jPanel1, BorderLayout.CENTER); jPanel1.add(jScrollPane1, BorderLayout.CENTER); panel1.add(jPanel2, BorderLayout.SOUTH); jPanel2.add( jLabel1, new GridBagConstraints( 0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 7, 0), 0, 0)); jPanel2.add( nameTextField, new GridBagConstraints( 1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 11, 7, 0), 0, 0)); jPanel2.add( jLabel2, new GridBagConstraints( 0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 17, 0), 0, 0)); jScrollPane1.getViewport().add(profileList, null); jPanel2.add( openButton, new GridBagConstraints( 3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 11, 2, 10), 0, 0)); jPanel2.add( cancelButton, new GridBagConstraints( 3, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 11, 9, 10), 0, 0)); jPanel2.add( typeComboBox, new GridBagConstraints( 1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 11, 17, 0), 0, 0)); }
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { final java.awt.GridBagConstraints gridBagConstraints; scpMain = new javax.swing.JScrollPane(); tblIntermed = new javax.swing.JTable(); jPanel1 = new javax.swing.JPanel(); jPanel2 = new javax.swing.JPanel(); lblRowCount = new javax.swing.JLabel(); jPanel3 = new javax.swing.JPanel(); jButton1 = new javax.swing.JButton(); jTextField1 = new javax.swing.JTextField(); jButton2 = new javax.swing.JButton(); setLayout(new java.awt.BorderLayout()); tblIntermed.setModel( new javax.swing.table.DefaultTableModel(new Object[][] {{}, {}, {}, {}}, new String[] {})); tblIntermed.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF); scpMain.setViewportView(tblIntermed); add(scpMain, java.awt.BorderLayout.CENTER); jPanel1.setLayout(new java.awt.BorderLayout()); jPanel2.setLayout(new java.awt.BorderLayout()); lblRowCount.setText( org.openide.util.NbBundle.getMessage( OutputIntermedTable.class, "OutputIntermedTable.lblRowCount.text")); // NOI18N jPanel2.add(lblRowCount, java.awt.BorderLayout.EAST); jPanel1.add(jPanel2, java.awt.BorderLayout.EAST); jPanel3.setLayout(new java.awt.GridBagLayout()); jButton1.setText( org.openide.util.NbBundle.getMessage( OutputIntermedTable.class, "OutputIntermedTable.jButton1.text")); // NOI18N jButton1.addActionListener( new java.awt.event.ActionListener() { @Override public void actionPerformed(final java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); jPanel3.add(jButton1, new java.awt.GridBagConstraints()); jTextField1.setText( org.openide.util.NbBundle.getMessage( OutputIntermedTable.class, "OutputIntermedTable.jTextField1.text")); // NOI18N jTextField1.setMinimumSize(new java.awt.Dimension(100, 20)); jTextField1.setPreferredSize(new java.awt.Dimension(100, 20)); jTextField1.addActionListener( new java.awt.event.ActionListener() { @Override public void actionPerformed(final java.awt.event.ActionEvent evt) { jTextField1ActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; jPanel3.add(jTextField1, gridBagConstraints); jButton2.setText( org.openide.util.NbBundle.getMessage( OutputIntermedTable.class, "OutputIntermedTable.jButton2.text")); // NOI18N jButton2.addActionListener( new java.awt.event.ActionListener() { @Override public void actionPerformed(final java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt); } }); jPanel3.add(jButton2, new java.awt.GridBagConstraints()); jPanel1.add(jPanel3, java.awt.BorderLayout.WEST); add(jPanel1, java.awt.BorderLayout.PAGE_END); } // </editor-fold>//GEN-END:initComponents
public void show(List<Rule> rules) { if (original != null) config.restoreState(original); dialog = new JDialog(owner, true); dialog.setTitle(messages.getString("guiConfigWindowTitle")); Collections.sort(rules, new CategoryComparator()); // close dialog when user presses Escape key: final KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0); final ActionListener actionListener = new ActionListener() { @Override public void actionPerformed(@SuppressWarnings("unused") ActionEvent actionEvent) { dialog.setVisible(false); } }; final JRootPane rootPane = dialog.getRootPane(); rootPane.registerKeyboardAction(actionListener, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW); // JPanel final JPanel checkBoxPanel = new JPanel(); checkBoxPanel.setLayout(new GridBagLayout()); GridBagConstraints cons = new GridBagConstraints(); cons.anchor = GridBagConstraints.NORTHWEST; cons.gridx = 0; cons.weightx = 1.0; cons.weighty = 1.0; cons.fill = GridBagConstraints.BOTH; DefaultMutableTreeNode rootNode = createTree(rules); DefaultTreeModel treeModel = new DefaultTreeModel(rootNode); treeModel.addTreeModelListener( new TreeModelListener() { @Override public void treeNodesChanged(TreeModelEvent e) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) e.getTreePath().getLastPathComponent(); int index = e.getChildIndices()[0]; node = (DefaultMutableTreeNode) (node.getChildAt(index)); if (node instanceof RuleNode) { RuleNode o = (RuleNode) node; if (o.getRule().isDefaultOff()) { if (o.isEnabled()) { config.getEnabledRuleIds().add(o.getRule().getId()); } else { config.getEnabledRuleIds().remove(o.getRule().getId()); } } else { if (o.isEnabled()) { config.getDisabledRuleIds().remove(o.getRule().getId()); } else { config.getDisabledRuleIds().add(o.getRule().getId()); } } } if (node instanceof CategoryNode) { CategoryNode o = (CategoryNode) node; if (o.isEnabled()) { config.getDisabledCategoryNames().remove(o.getCategory().getName()); } else { config.getDisabledCategoryNames().add(o.getCategory().getName()); } } } @Override public void treeNodesInserted(TreeModelEvent e) {} @Override public void treeNodesRemoved(TreeModelEvent e) {} @Override public void treeStructureChanged(TreeModelEvent e) {} }); configTree = new JTree(treeModel); configTree.setRootVisible(false); configTree.setEditable(false); configTree.setCellRenderer(new CheckBoxTreeCellRenderer()); TreeListener.install(configTree); checkBoxPanel.add(configTree, cons); MouseAdapter ma = new MouseAdapter() { private void handlePopupEvent(MouseEvent e) { final JTree tree = (JTree) e.getSource(); TreePath path = tree.getPathForLocation(e.getX(), e.getY()); if (path == null) { return; } DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent(); TreePath[] paths = tree.getSelectionPaths(); boolean isSelected = false; if (paths != null) { for (TreePath selectionPath : paths) { if (selectionPath.equals(path)) { isSelected = true; } } } if (!isSelected) { tree.setSelectionPath(path); } if (node.isLeaf()) { JPopupMenu popup = new JPopupMenu(); final JMenuItem aboutRuleMenuItem = new JMenuItem(messages.getString("guiAboutRuleMenu")); aboutRuleMenuItem.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { RuleNode node = (RuleNode) tree.getSelectionPath().getLastPathComponent(); Rule rule = node.getRule(); Language lang = config.getLanguage(); if (lang == null) { lang = Language.getLanguageForLocale(Locale.getDefault()); } Tools.showRuleInfoDialog( tree, messages.getString("guiAboutRuleTitle"), rule.getDescription(), rule, messages, lang.getShortNameWithCountryAndVariant()); } }); popup.add(aboutRuleMenuItem); popup.show(tree, e.getX(), e.getY()); } } @Override public void mousePressed(MouseEvent e) { if (e.isPopupTrigger()) { handlePopupEvent(e); } } @Override public void mouseReleased(MouseEvent e) { if (e.isPopupTrigger()) { handlePopupEvent(e); } } }; configTree.addMouseListener(ma); final JPanel treeButtonPanel = new JPanel(); cons = new GridBagConstraints(); cons.gridx = 0; cons.gridy = 0; final JButton expandAllButton = new JButton(messages.getString("guiExpandAll")); treeButtonPanel.add(expandAllButton, cons); expandAllButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { TreeNode root = (TreeNode) configTree.getModel().getRoot(); TreePath parent = new TreePath(root); for (Enumeration categ = root.children(); categ.hasMoreElements(); ) { TreeNode n = (TreeNode) categ.nextElement(); TreePath child = parent.pathByAddingChild(n); configTree.expandPath(child); } } }); cons.gridx = 1; cons.gridy = 0; final JButton collapseAllbutton = new JButton(messages.getString("guiCollapseAll")); treeButtonPanel.add(collapseAllbutton, cons); collapseAllbutton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { TreeNode root = (TreeNode) configTree.getModel().getRoot(); TreePath parent = new TreePath(root); for (Enumeration categ = root.children(); categ.hasMoreElements(); ) { TreeNode n = (TreeNode) categ.nextElement(); TreePath child = parent.pathByAddingChild(n); configTree.collapsePath(child); } } }); final JPanel motherTonguePanel = new JPanel(); motherTonguePanel.add(new JLabel(messages.getString("guiMotherTongue")), cons); motherTongueBox = new JComboBox(getPossibleMotherTongues()); if (config.getMotherTongue() != null) { motherTongueBox.setSelectedItem(config.getMotherTongue().getTranslatedName(messages)); } motherTongueBox.addItemListener( new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { Language motherTongue; if (motherTongueBox.getSelectedItem() instanceof String) { motherTongue = getLanguageForLocalizedName(motherTongueBox.getSelectedItem().toString()); } else { motherTongue = (Language) motherTongueBox.getSelectedItem(); } config.setMotherTongue(motherTongue); } } }); motherTonguePanel.add(motherTongueBox, cons); final JPanel portPanel = new JPanel(); portPanel.setLayout(new GridBagLayout()); // TODO: why is this now left-aligned?!?! cons = new GridBagConstraints(); cons.insets = new Insets(0, 4, 0, 0); cons.gridx = 0; cons.gridy = 0; cons.anchor = GridBagConstraints.WEST; cons.fill = GridBagConstraints.NONE; cons.weightx = 0.0f; if (!insideOOo) { serverCheckbox = new JCheckBox(Tools.getLabel(messages.getString("guiRunOnPort"))); serverCheckbox.setMnemonic(Tools.getMnemonic(messages.getString("guiRunOnPort"))); serverCheckbox.setSelected(config.getRunServer()); portPanel.add(serverCheckbox, cons); serverCheckbox.addActionListener( new ActionListener() { @Override public void actionPerformed(@SuppressWarnings("unused") ActionEvent e) { serverPortField.setEnabled(serverCheckbox.isSelected()); serverSettingsCheckbox.setEnabled(serverCheckbox.isSelected()); } }); serverCheckbox.addItemListener( new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { config.setRunServer(serverCheckbox.isSelected()); } }); serverPortField = new JTextField(Integer.toString(config.getServerPort())); serverPortField.setEnabled(serverCheckbox.isSelected()); serverSettingsCheckbox = new JCheckBox(Tools.getLabel(messages.getString("useGUIConfig"))); // TODO: without this the box is just a few pixels small, but why??: serverPortField.setMinimumSize(new Dimension(100, 25)); cons.gridx = 1; portPanel.add(serverPortField, cons); serverPortField .getDocument() .addDocumentListener( new DocumentListener() { @Override public void insertUpdate(DocumentEvent e) { changedUpdate(e); } @Override public void removeUpdate(DocumentEvent e) { changedUpdate(e); } @Override public void changedUpdate(DocumentEvent e) { try { int serverPort = Integer.parseInt(serverPortField.getText()); if (serverPort > -1 && serverPort < 65536) { serverPortField.setForeground(null); config.setServerPort(serverPort); } else { serverPortField.setForeground(Color.RED); } } catch (NumberFormatException ex) { serverPortField.setForeground(Color.RED); } } }); cons.gridx = 0; cons.gridy = 10; serverSettingsCheckbox.setMnemonic(Tools.getMnemonic(messages.getString("useGUIConfig"))); serverSettingsCheckbox.setSelected(config.getUseGUIConfig()); serverSettingsCheckbox.setEnabled(config.getRunServer()); serverSettingsCheckbox.addItemListener( new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { config.setUseGUIConfig(serverSettingsCheckbox.isSelected()); } }); portPanel.add(serverSettingsCheckbox, cons); } final JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new GridBagLayout()); okButton = new JButton(Tools.getLabel(messages.getString("guiOKButton"))); okButton.setMnemonic(Tools.getMnemonic(messages.getString("guiOKButton"))); okButton.addActionListener(this); cancelButton = new JButton(Tools.getLabel(messages.getString("guiCancelButton"))); cancelButton.setMnemonic(Tools.getMnemonic(messages.getString("guiCancelButton"))); cancelButton.addActionListener(this); cons = new GridBagConstraints(); cons.insets = new Insets(0, 4, 0, 0); buttonPanel.add(okButton, cons); buttonPanel.add(cancelButton, cons); final Container contentPane = dialog.getContentPane(); contentPane.setLayout(new GridBagLayout()); cons = new GridBagConstraints(); cons.insets = new Insets(4, 4, 4, 4); cons.gridx = 0; cons.gridy = 0; cons.weightx = 10.0f; cons.weighty = 10.0f; cons.fill = GridBagConstraints.BOTH; contentPane.add(new JScrollPane(checkBoxPanel), cons); cons.gridx = 0; cons.gridy = 1; cons.weightx = 0.0f; cons.weighty = 0.0f; cons.fill = GridBagConstraints.NONE; cons.anchor = GridBagConstraints.LINE_END; contentPane.add(treeButtonPanel, cons); cons.gridx = 0; cons.gridy = 2; cons.weightx = 0.0f; cons.weighty = 0.0f; cons.fill = GridBagConstraints.NONE; cons.anchor = GridBagConstraints.WEST; contentPane.add(motherTonguePanel, cons); cons.gridx = 0; cons.gridy = 3; cons.weightx = 0.0f; cons.weighty = 0.0f; cons.fill = GridBagConstraints.NONE; cons.anchor = GridBagConstraints.WEST; contentPane.add(portPanel, cons); cons.gridx = 0; cons.gridy = 4; cons.weightx = 0.0f; cons.weighty = 0.0f; cons.fill = GridBagConstraints.NONE; cons.anchor = GridBagConstraints.EAST; contentPane.add(buttonPanel, cons); dialog.pack(); dialog.setSize(500, 500); // center on screen: final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); final Dimension frameSize = dialog.getSize(); dialog.setLocation( screenSize.width / 2 - frameSize.width / 2, screenSize.height / 2 - frameSize.height / 2); dialog.setLocationByPlatform(true); dialog.setVisible(true); }
public void init() { subMultipleTransfersLabel1.setFont(new java.awt.Font("Dialog", 0, 9)); subMultipleTransfersLabel1.setText( "(unchecked: # of instances where SC happened / # of instances"); subMultipleTransfersLabel2.setFont(new java.awt.Font("Dialog", 0, 9)); subMultipleTransfersLabel2.setText( " checked: # of SCs between originators / # of possible SCs)"); this.setLayout(gridBagLayout2); subConsiderCausality.setText("Consider causality"); subConsiderCausality.setSelected(true); subConsiderMultipleTransfers.setText("Consider multiple transfers within one instance"); subConsiderMultipleTransfers.setSelected(true); subDepthLabel.setText("Depth of calculation:"); subBetaLabel.setText("Beta:"); subDepth.setText("5"); subDepth.setPreferredSize(new Dimension(40, 21)); subConsiderDirectSuccession.setText("Consider only direct subcontract"); subConsiderDirectSuccession.setSelected(true); subBeta.setText("0.5"); subBeta.setPreferredSize(new Dimension(40, 21)); subBeta.setMinimumSize(new Dimension(6, 21)); subBeta.setEnabled(!subConsiderDirectSuccession.isSelected()); subDepth.setEnabled(!subConsiderDirectSuccession.isSelected()); subBetaLabel.setEnabled(!subConsiderDirectSuccession.isSelected()); subDepthLabel.setEnabled(!subConsiderDirectSuccession.isSelected()); this.add( subConsiderCausality, new GridBagConstraints( 0, 0, 2, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); this.add( subConsiderMultipleTransfers, new GridBagConstraints( 0, 1, 2, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); this.add( subConsiderDirectSuccession, new GridBagConstraints( 0, 4, 2, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); this.add( subBetaLabel, new GridBagConstraints( 0, 5, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 40, 0, 0), 0, 0)); this.add( subDepth, new GridBagConstraints( 1, 6, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(3, 5, 0, 0), 0, 0)); this.add( subDepthLabel, new GridBagConstraints( 0, 6, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(3, 40, 0, 0), 0, 0)); this.add( subBeta, new GridBagConstraints( 1, 5, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 0), 0, 0)); this.add( subMultipleTransfersLabel1, new GridBagConstraints( 0, 2, 2, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 25, 0, 0), 0, 0)); this.add( subMultipleTransfersLabel2, new GridBagConstraints( 0, 3, 2, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 25, 0, 0), 0, 0)); subConsiderDirectSuccession.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { subBeta.setEnabled(!subConsiderDirectSuccession.isSelected()); subDepth.setEnabled(!subConsiderDirectSuccession.isSelected()); subBetaLabel.setEnabled(!subConsiderDirectSuccession.isSelected()); subDepthLabel.setEnabled(!subConsiderDirectSuccession.isSelected()); } }); }
/** * Adds a new cost unit line to the form. */ private void addNewCostUnit() { GridBagConstraints gridBagConstraints; JLabel lblCostUnit = new JLabel(); lblCostUnit.setText(_("Cost unit")); gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = GridBagConstraints.RELATIVE; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10); add(lblCostUnit, gridBagConstraints); lblCostUnit.getAccessibleContext() .setAccessibleDescription("costUnits"); ComboBoxModel costUnitModel = new ComboBoxModel(DataType.CostUnit); List<CostUnit> costUnits = (new CostUnit()).getAll(); for(CostUnit costUnit : costUnits) { costUnitModel.addModel(costUnit); } JComboBox cmbCostUnit = new JComboBox(); cmbCostUnit.setModel(costUnitModel); if(cmbCostUnit.getItemCount() > 0) cmbCostUnit.setSelectedItem(null); tab.getListModels().add(costUnitModel); gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = GridBagConstraints.RELATIVE; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10); add(cmbCostUnit, gridBagConstraints); JLabel lblBudgetCosts = new JLabel(); lblBudgetCosts.setText(_("Budget Costs")); gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = GridBagConstraints.RELATIVE; gridBagConstraints.anchor = GridBagConstraints.WEST; gridBagConstraints.insets = new java.awt.Insets(10, 35, 10, 10); add(lblBudgetCosts, gridBagConstraints); lblBudgetCosts.getAccessibleContext().setAccessibleDescription( "budgetCosts"); JTextField txtBudgetCosts = new JTextField(); txtBudgetCosts.setMinimumSize(new java.awt.Dimension(200, 25)); txtBudgetCosts.setPreferredSize(new java.awt.Dimension(200, 25)); gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridx = 3; gridBagConstraints.gridy = GridBagConstraints.RELATIVE; gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10); add(txtBudgetCosts, gridBagConstraints); InputPatternFilter.addFilter(txtBudgetCosts, "[0-9]+"); HelpLabel hlpBudgetCosts = new HelpLabel(); gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridx = 4; gridBagConstraints.gridy = GridBagConstraints.RELATIVE; gridBagConstraints.fill = java.awt.GridBagConstraints.WEST; gridBagConstraints.insets = new java.awt.Insets(10, 0, 10, 10); add(hlpBudgetCosts, gridBagConstraints); hlpBudgetCosts.setToolTipText(_("Only a number is allowed.")); JButton btnPlusMinus = new JButton(); gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridx = 5; CostUnitLine fl = new CostUnitLine(lblCostUnit, cmbCostUnit, lblBudgetCosts, txtBudgetCosts, hlpBudgetCosts, btnPlusMinus); if (costUnitLines.isEmpty()) { btnPlusMinus.setIcon(new ImageIcon(getClass().getResource( "/de/aidger/res/icons/plus-small.png"))); gridBagConstraints.gridy = 1; btnPlusMinus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { addNewCostUnit(); } }); } else { gridBagConstraints.gridy = GridBagConstraints.RELATIVE; btnPlusMinus.setAction(new RemoveCostUnitAction(fl)); } add(btnPlusMinus, gridBagConstraints); costUnitLines.add(fl); }
public TextBox(int position) { super(); fieldNumber = position; this.setLayout(new GridLayout(1, 2)); fieldTitle = new JLabel(); fieldTitle.setAlignmentX(LEFT_ALIGNMENT); text = new JTextField(20); text.setMinimumSize(text.getPreferredSize()); text.setAlignmentX(LEFT_ALIGNMENT); text.addFocusListener( new FocusListener() { @Override public void focusLost(FocusEvent e) { String temp = text.getText(); batchState.addText(fieldNumber - 1, batchState.getCurrentCell().getRecordNum(), temp); } @Override public void focusGained(FocusEvent e) { // TODO Auto-generated method stub batchState.updateCell(fieldNumber, -1); } }); text.addMouseListener( new MouseListener() { @Override public void mouseReleased(MouseEvent e) { // TODO Auto-generated method stub } @Override public void mousePressed(MouseEvent e) { // TODO Auto-generated method stub } @Override public void mouseExited(MouseEvent e) { // TODO Auto-generated method stub } @Override public void mouseEntered(MouseEvent e) { // TODO Auto-generated method stub } @Override public void mouseClicked(MouseEvent e) { if (e.getButton() == 3) { if (text.getBackground() == Color.RED) { final JPopupMenu suggestion = new JPopupMenu(); JMenuItem item = new JMenuItem("see suggestion"); item.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ArrayList<String> list = batchState.getSuggestions(text.getText(), fieldNumber - 1); int column = fieldNumber; int row = recordList.getSelectedIndex(); SuggestionWindow suggestionWindow = new SuggestionWindow(list, column, row, batchState); suggestionWindow.setSize(new Dimension(300, 200)); suggestionWindow.setResizable(false); suggestionWindow.setLocationRelativeTo(null); suggestionWindow.setVisible(true); } }); suggestion.add(item); suggestion.show(e.getComponent(), e.getX(), e.getY()); } } } }); this.add(fieldTitle); this.add(text); }
private void initComponents() { ResourceBundle resourceMap = ResourceBundle.getBundle("mekhq.resources.PartsStoreDialog"); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setName("Form"); // NOI18N setTitle(resourceMap.getString("Form.title")); getContentPane().setLayout(new BorderLayout()); partsTable = new JTable(partsModel); partsTable.setName("partsTable"); // NOI18N partsSorter = new TableRowSorter<PartsTableModel>(partsModel); partsSorter.setComparator(PartsTableModel.COL_TARGET, new TargetSorter()); partsSorter.setComparator(PartsTableModel.COL_COST, new FormattedNumberSorter()); partsSorter.setComparator(PartsTableModel.COL_DETAIL, new PartsDetailSorter()); partsTable.setRowSorter(partsSorter); TableColumn column = null; for (int i = 0; i < PartsTableModel.N_COL; i++) { column = partsTable.getColumnModel().getColumn(i); column.setPreferredWidth(partsModel.getColumnWidth(i)); column.setCellRenderer(partsModel.getRenderer()); } partsTable.setIntercellSpacing(new Dimension(0, 0)); partsTable.setShowGrid(false); scrollPartsTable = new JScrollPane(); scrollPartsTable.setName("scrollPartsTable"); // NOI18N scrollPartsTable.setViewportView(partsTable); getContentPane().add(scrollPartsTable, BorderLayout.CENTER); GridBagConstraints c = new GridBagConstraints(); panFilter = new JPanel(); lblPartsChoice = new JLabel(resourceMap.getString("lblPartsChoice.text")); // NOI18N DefaultComboBoxModel<String> partsGroupModel = new DefaultComboBoxModel<String>(); for (int i = 0; i < SG_NUM; i++) { partsGroupModel.addElement(getPartsGroupName(i)); } choiceParts = new JComboBox<String>(partsGroupModel); choiceParts.setName("choiceParts"); // NOI18N choiceParts.setSelectedIndex(0); choiceParts.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { filterParts(); } }); panFilter.setLayout(new GridBagLayout()); c.gridx = 0; c.gridy = 0; c.weightx = 0.0; c.anchor = java.awt.GridBagConstraints.WEST; c.insets = new Insets(5, 5, 5, 5); panFilter.add(lblPartsChoice, c); c.gridx = 1; c.weightx = 1.0; panFilter.add(choiceParts, c); lblFilter = new JLabel(resourceMap.getString("lblFilter.text")); // NOI18N lblFilter.setName("lblFilter"); // NOI18N c.gridx = 0; c.gridy = 1; c.weightx = 0.0; panFilter.add(lblFilter, c); txtFilter = new javax.swing.JTextField(); txtFilter.setText(""); // NOI18N txtFilter.setMinimumSize(new java.awt.Dimension(200, 28)); txtFilter.setName("txtFilter"); // NOI18N txtFilter.setPreferredSize(new java.awt.Dimension(200, 28)); txtFilter .getDocument() .addDocumentListener( new DocumentListener() { public void changedUpdate(DocumentEvent e) { filterParts(); } public void insertUpdate(DocumentEvent e) { filterParts(); } public void removeUpdate(DocumentEvent e) { filterParts(); } }); c.gridx = 1; c.gridy = 1; c.weightx = 1.0; panFilter.add(txtFilter, c); getContentPane().add(panFilter, BorderLayout.PAGE_START); panButtons = new JPanel(); if (addToCampaign) { btnAdd = new JButton(resourceMap.getString("btnAdd.text")); btnAdd.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { addPart(false, false); } }); btnAdd.setEnabled(campaign.isGM()); btnBuyBulk = new JButton(resourceMap.getString("btnBuyBulk.text")); btnBuyBulk.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { addPart(true, true); partsModel.fireTableCellUpdated( partsTable.convertRowIndexToModel(partsTable.getSelectedRow()), PartsTableModel.COL_TARGET); partsModel.fireTableCellUpdated( partsTable.convertRowIndexToModel(partsTable.getSelectedRow()), PartsTableModel.COL_TRANSIT); partsModel.fireTableCellUpdated( partsTable.convertRowIndexToModel(partsTable.getSelectedRow()), PartsTableModel.COL_SUPPLY); partsModel.fireTableCellUpdated( partsTable.convertRowIndexToModel(partsTable.getSelectedRow()), PartsTableModel.COL_QUEUE); } }); btnBuy = new JButton(resourceMap.getString("btnBuy.text")); btnBuy.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { addPart(true, false); partsModel.fireTableCellUpdated( partsTable.convertRowIndexToModel(partsTable.getSelectedRow()), PartsTableModel.COL_TARGET); partsModel.fireTableCellUpdated( partsTable.convertRowIndexToModel(partsTable.getSelectedRow()), PartsTableModel.COL_TRANSIT); partsModel.fireTableCellUpdated( partsTable.convertRowIndexToModel(partsTable.getSelectedRow()), PartsTableModel.COL_SUPPLY); partsModel.fireTableCellUpdated( partsTable.convertRowIndexToModel(partsTable.getSelectedRow()), PartsTableModel.COL_QUEUE); } }); btnUseBonusPart = new JButton(); if (campaign.getCampaignOptions().getUseAtB()) { int numBonusParts = campaign.totalBonusParts(); btnUseBonusPart.setText("Use Bonus Part (" + numBonusParts + ")"); btnUseBonusPart.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { addPart(true, false, true); partsModel.fireTableCellUpdated( partsTable.convertRowIndexToModel(partsTable.getSelectedRow()), PartsTableModel.COL_TARGET); partsModel.fireTableCellUpdated( partsTable.convertRowIndexToModel(partsTable.getSelectedRow()), PartsTableModel.COL_TRANSIT); partsModel.fireTableCellUpdated( partsTable.convertRowIndexToModel(partsTable.getSelectedRow()), PartsTableModel.COL_SUPPLY); partsModel.fireTableCellUpdated( partsTable.convertRowIndexToModel(partsTable.getSelectedRow()), PartsTableModel.COL_QUEUE); int numBonusParts = campaign.totalBonusParts(); btnUseBonusPart.setText("Use Bonus Part (" + numBonusParts + ")"); btnUseBonusPart.setVisible(numBonusParts > 0); } }); btnUseBonusPart.setVisible(numBonusParts > 0); } btnClose = new JButton(resourceMap.getString("btnClose.text")); btnClose.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { setVisible(false); } }); panButtons.setLayout(new GridBagLayout()); panButtons.add(btnBuyBulk, new GridBagConstraints()); panButtons.add(btnBuy, new GridBagConstraints()); if (campaign.getCampaignOptions().getUseAtB()) { panButtons.add(btnUseBonusPart, new GridBagConstraints()); } panButtons.add(btnAdd, new GridBagConstraints()); panButtons.add(btnClose, new GridBagConstraints()); } else { // if we arent adding the unit to the campaign, then different buttons btnAdd = new JButton("Add"); btnAdd.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { setSelectedPart(); setVisible(false); } }); panButtons.add(btnAdd, new GridBagConstraints()); btnClose = new JButton("Cancel"); // NOI18N btnClose.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { selectedPart = null; setVisible(false); } }); panButtons.add(btnClose, new GridBagConstraints()); } getContentPane().add(panButtons, BorderLayout.PAGE_END); this.setPreferredSize(new Dimension(700, 600)); pack(); }
/** * This method represents the window in which the preferred parameters for the obix components can * be chosen. * * @param chosenComponents The list of {@link ObixObject} which have been chosen in the previous * window. * @return The container in which the preferred parameters for the obix components can be chosen. */ private Container chooseParameters(List<ObixObject> chosenComponents) { Container pane = new Container(); pane.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); pane.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); Font titelF = new Font("Courier", Font.BOLD, 30); title = new JLabel("Please choose the appropriate Parameters for the datapoints"); title.setFont(titelF); c.fill = GridBagConstraints.HORIZONTAL; c.gridwidth = 10; c.gridx = 0; c.gridy = 0; pane.add(title, c); List<String> parametersList = Configurator.getInstance().getAvailableParameterTypes(); String[] parameterTypes = new String[parametersList.size()]; parameterTypes = parametersList.toArray(parameterTypes); for (ObixObject o : chosenComponents) { c.gridy++; c.insets = new Insets(30, 10, 0, 0); JLabel uriLabel = new JLabel(o.getObixUri()); uriLabel.setFont(new Font("Courier", Font.ITALIC, 15)); c.gridx = 0; c.gridwidth = 10; pane.add(uriLabel, c); c.gridwidth = 1; c.insets = new Insets(10, 10, 0, 0); JLabel parameter1Label = new JLabel("Parameter 1 Type:"); c.gridy++; pane.add(parameter1Label, c); JLabel parameter1ObixUnitLabel = new JLabel("OBIX unit: " + o.getObixUnitUri()); c.gridx++; pane.add(parameter1ObixUnitLabel, c); JComboBox parameter1comboBox = new JComboBox(parameterTypes); c.gridx++; pane.add(parameter1comboBox, c); JButton param1AddStateButton = new JButton("Add State"); Box vBox1 = Box.createVerticalBox(); vBox1.setBorder(BorderFactory.createLineBorder(Color.black)); JLabel parameter1UnitLabel = new JLabel("Set Parameter 1 Unit:"); c.gridx++; pane.add(parameter1UnitLabel, c); JTextField parameter1UnitTextField = new JTextField(o.getParameter1().getParameterUnit()); parameter1UnitTextField.setPreferredSize(new Dimension(500, 20)); parameter1UnitTextField.setMinimumSize(new Dimension(500, 20)); c.gridx++; pane.add(parameter1UnitTextField, c); JLabel parameter1ValueTypeLabel = new JLabel("valueType: " + o.getParameter1().getValueType()); c.gridx++; pane.add(parameter1ValueTypeLabel, c); int param1UnitLabelxPosition = c.gridx; int param1UnitLabelyPosition = c.gridy; for (StateDescription s : o.getParameter1().getStateDescriptions()) { JLabel stateNameLabel = new JLabel("State Name: "); JTextField stateNameTextfield = new JTextField(20); stateNameTextfield.setText(s.getName().getName()); vBox1.add(stateNameLabel); vBox1.add(stateNameTextfield); JLabel stateValueLabel = new JLabel("State Value: "); JTextField stateValueTextfield = new JTextField(20); stateValueTextfield.setText(s.getValue().getValue()); vBox1.add(stateValueLabel); vBox1.add(stateValueTextfield); JLabel stateURILabel = new JLabel("State URI: "); JTextField stateURITextfield = new JTextField(20); stateURITextfield.setText(s.getStateDescriptionUri()); vBox1.add(stateURILabel); vBox1.add(stateURITextfield); JButton deleteStateButton = new JButton("Delete State"); vBox1.add(deleteStateButton); JSeparator horizontalLine = new JSeparator(JSeparator.HORIZONTAL); vBox1.add(horizontalLine); vBox1.add(horizontalLine); StateRepresentation stateRepresentation = (new StateRepresentation( param1AddStateButton, deleteStateButton, stateNameLabel, stateNameTextfield, stateValueLabel, stateValueTextfield, stateURILabel, stateURITextfield, horizontalLine, vBox1, o.getParameter1())); addDeleteStateListener(stateRepresentation); listOfStateRepresentations.add(stateRepresentation); pane.revalidate(); pane.repaint(); } addParameterBoxListener( parameter1comboBox, param1UnitLabelxPosition, param1UnitLabelyPosition, parameter1UnitLabel, parameter1UnitTextField, pane, param1AddStateButton, vBox1); /** Add state to parameter 1 function listener */ param1AddStateButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JLabel stateNameLabel = new JLabel("State Name: "); JTextField stateNameTextfield = new JTextField(20); vBox1.add(stateNameLabel); vBox1.add(stateNameTextfield); JLabel stateValueLabel = new JLabel("State Value: "); JTextField stateValueTextfield = new JTextField(20); vBox1.add(stateValueLabel); vBox1.add(stateValueTextfield); JLabel stateURILabel = new JLabel("State URI: "); JTextField stateURITextfield = new JTextField(20); vBox1.add(stateURILabel); vBox1.add(stateURITextfield); JButton deleteStateButton = new JButton("Delete State"); vBox1.add(deleteStateButton); JSeparator horizontalLine = new JSeparator(JSeparator.HORIZONTAL); vBox1.add(horizontalLine); vBox1.add(horizontalLine); StateRepresentation stateRepresentation = (new StateRepresentation( param1AddStateButton, deleteStateButton, stateNameLabel, stateNameTextfield, stateValueLabel, stateValueTextfield, stateURILabel, stateURITextfield, horizontalLine, vBox1, o.getParameter1())); addDeleteStateListener(stateRepresentation); listOfStateRepresentations.add(stateRepresentation); pane.revalidate(); pane.repaint(); } }); c.gridy++; c.gridx = 0; JLabel parameter2Label = new JLabel("Parameter 2 Type:"); pane.add(parameter2Label, c); JComboBox parameter2comboBox = new JComboBox(parameterTypes); c.gridx++; c.gridx++; pane.add(parameter2comboBox, c); JLabel parameter2UnitLabel = new JLabel("Set Parameter 2 Unit: "); c.gridx++; pane.add(parameter2UnitLabel, c); JTextField parameter2UnitTextField = new JTextField(o.getParameter2().getParameterUnit()); parameter2UnitTextField.setPreferredSize(new Dimension(500, 20)); parameter2UnitTextField.setMinimumSize(new Dimension(500, 20)); c.gridx++; pane.add(parameter2UnitTextField, c); JLabel parameter2ValueTypeLabel = new JLabel("valueType: " + o.getParameter2().getValueType()); c.gridx++; pane.add(parameter2ValueTypeLabel, c); JButton param2AddStateButton = new JButton("Add State"); Box vBox2 = Box.createVerticalBox(); vBox2.setBorder(BorderFactory.createLineBorder(Color.black)); int param2UnitLabelxPosition = c.gridx; int param2UnitLabelyPosition = c.gridy; addParameterBoxListener( parameter2comboBox, param2UnitLabelxPosition, param2UnitLabelyPosition, parameter2UnitLabel, parameter2UnitTextField, pane, param2AddStateButton, vBox2); /** Add state to parameter 2 function listener */ param2AddStateButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JLabel stateNameLabel = new JLabel("State Name: "); JTextField stateNameTextfield = new JTextField(20); vBox2.add(stateNameLabel); vBox2.add(stateNameTextfield); JLabel stateValueLabel = new JLabel("State Value: "); JTextField stateValueTextfield = new JTextField(20); vBox2.add(stateValueLabel); vBox2.add(stateValueTextfield); JLabel stateURILabel = new JLabel("State URI: "); JTextField stateURITextfield = new JTextField(20); vBox2.add(stateURILabel); vBox2.add(stateURITextfield); JButton deleteStateButton = new JButton("Delete State"); vBox2.add(deleteStateButton); JSeparator horizontalLine = new JSeparator(JSeparator.HORIZONTAL); vBox2.add(horizontalLine); vBox2.add(horizontalLine); StateRepresentation stateRepresentation = (new StateRepresentation( param2AddStateButton, deleteStateButton, stateNameLabel, stateNameTextfield, stateValueLabel, stateValueTextfield, stateURILabel, stateURITextfield, horizontalLine, vBox2, o.getParameter2())); addDeleteStateListener(stateRepresentation); listOfStateRepresentations.add(stateRepresentation); pane.revalidate(); pane.repaint(); } }); parameter1comboBox.setSelectedItem(o.getParameter1().getParameterType()); parameter2comboBox.setSelectedItem(o.getParameter2().getParameterType()); representationRows.add( new RepresentationRow( o, parameter1comboBox, parameter2comboBox, parameter1UnitTextField, parameter2UnitTextField)); } JButton acceptButton = new JButton("Accept"); c.insets = new Insets(50, 0, 0, 0); c.gridwidth = 10; c.gridx = 0; c.gridy++; pane.add(acceptButton, c); /** Accept button listener */ Action acceptAction = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { for (StateRepresentation s : listOfStateRepresentations) { if (s.getStateNameTextField().getText().isEmpty() || s.getStateUriTextField().getText().isEmpty() || s.getStateValueTextField().getText().isEmpty()) { JOptionPane.showMessageDialog( null, "Each state parameter field must contain a text! " + "There are some empty parameter fields, please change them before proceeding."); return; } } for (ObixObject o : chosenComponents) { o.getParameter1().getStateDescriptions().clear(); o.getParameter2().getStateDescriptions().clear(); } for (StateRepresentation s : listOfStateRepresentations) { // Save created State ArrayList<String> types = new ArrayList<String>(); types.add("&colibri;AbsoluteState"); types.add("&colibri;DiscreteState"); Value val = new Value(); val.setValue(s.getStateValueTextField().getText()); val.setDatatype(s.getParameter().getValueType()); Name name = new Name(); name.setName(s.getStateNameTextField().getText()); StateDescription state = new StateDescription(s.getStateUriTextField().getText(), types, val, name); s.getParameter().addStateDescription(state); } List<ObixObject> chosenObjects = Collections.synchronizedList(new ArrayList<>()); for (RepresentationRow r : GuiUtility.this.getRepresentationRows()) { r.getObixObject() .getParameter1() .setParameterType((String) r.getParam1TypeComboBox().getSelectedItem()); r.getObixObject() .getParameter2() .setParameterType((String) r.getParam2TypeComboBox().getSelectedItem()); chosenObjects.add(r.getObixObject()); if (!r.getParam1UnitTextField().getText().isEmpty()) { r.getObixObject() .getParameter1() .setParameterUnit(r.getParam1UnitTextField().getText()); } if (!r.getParam2UnitTextField().getText().isEmpty()) { r.getObixObject() .getParameter2() .setParameterUnit(r.getParam2UnitTextField().getText()); } } representationRows.clear(); cards.removeAll(); JScrollPane scrollPane = new JScrollPane(interactionWindow(chosenObjects)); scrollPane.getVerticalScrollBar().setUnitIncrement(16); scrollPane.setBorder(new EmptyBorder(20, 20, 20, 20)); cards.add(scrollPane); // Display the window. mainFrame.pack(); } }; acceptButton.addActionListener(acceptAction); return pane; }
/** * This method is called from within the constructor to initialize the form. WARNING: Do NOT * modify this code. The content of this method is always regenerated by the Form Editor. */ private void initComponents() { // GEN-BEGIN:initComponents java.awt.GridBagConstraints gridBagConstraints; jSeparator1 = new javax.swing.JSeparator(); jLabel2 = new javax.swing.JLabel(); jSeparator2 = new javax.swing.JSeparator(); jLabel3 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel(); tbHitPoints = new javax.swing.JTextField(); tbNumber = new javax.swing.JTextField(); setLayout(new java.awt.GridBagLayout()); jSeparator1.setOrientation(javax.swing.SwingConstants.VERTICAL); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 1; gridBagConstraints.gridheight = 5; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.ipadx = 8; gridBagConstraints.ipady = 260; gridBagConstraints.insets = new java.awt.Insets(8, 17, 0, 0); add(jSeparator1, gridBagConstraints); jLabel2.setFont(new java.awt.Font("Dialog", 1, 18)); jLabel2.setText("Misc"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.gridwidth = 4; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.insets = new java.awt.Insets(10, 10, 0, 0); add(jLabel2, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 1; gridBagConstraints.gridwidth = 6; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.ipadx = 400; gridBagConstraints.ipady = 8; gridBagConstraints.insets = new java.awt.Insets(6, 0, 0, 0); add(jSeparator2, gridBagConstraints); jLabel3.setText("Max Hit Points"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 3; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.insets = new java.awt.Insets(0, 10, 0, 0); add(jLabel3, gridBagConstraints); jLabel4.setText("Max Number to add"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 4; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.insets = new java.awt.Insets(0, 10, 0, 0); add(jLabel4, gridBagConstraints); tbHitPoints.setMinimumSize(new java.awt.Dimension(20, 20)); tbHitPoints.setPreferredSize(new java.awt.Dimension(20, 20)); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 3; gridBagConstraints.gridwidth = 5; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.insets = new java.awt.Insets(0, 25, 0, 0); add(tbHitPoints, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 4; gridBagConstraints.gridwidth = 5; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.insets = new java.awt.Insets(0, 25, 0, 0); add(tbNumber, gridBagConstraints); }
/** Initializes the GUI. Auto-generated code - any changes you make will disappear. */ public void initGUI() { try { preInitGUI(); containerTabbedPane = new JTabbedPane(); tbDirectedGraph = new JPanel(); btnFilterDirectedGraph = new JButton(); dirVertexDegreePanel = new JPanel(); lblMinInDegree = new JLabel(); lblMaxInDegree = new JLabel(); lblMinOutDegree = new JLabel(); lblMaxOutDegree = new JLabel(); tfInDegreeMin = new JTextField(); tfInDegreeMax = new JTextField(); tfOutDegreeMin = new JTextField(); tfOutDegreeMax = new JTextField(); lblIinstructions = new JLabel(); tbUndirectedGraph = new JPanel(); unDirVertexDegreePanel = new JPanel(); lblMinDegree = new JLabel(); lblMaxDegree = new JLabel(); tfMinDegree = new JTextField(); tfMaxDegree = new JTextField(); lblInstructionsDir = new JLabel(); btnFilterUndirectedGraph = new JButton(); BorderLayout thisLayout = new BorderLayout(); this.getContentPane().setLayout(thisLayout); thisLayout.setHgap(0); thisLayout.setVgap(0); this.setTitle("Pruning"); this.setSize(new java.awt.Dimension(316, 267)); containerTabbedPane.setPreferredSize(new java.awt.Dimension(309, 265)); this.getContentPane().add(containerTabbedPane, BorderLayout.CENTER); GridBagLayout tbDirectedGraphLayout = new GridBagLayout(); tbDirectedGraph.setLayout(tbDirectedGraphLayout); tbDirectedGraphLayout.columnWidths = new int[] {1}; tbDirectedGraphLayout.rowHeights = new int[] {1, 1, 1}; tbDirectedGraphLayout.columnWeights = new double[] {0.1}; tbDirectedGraphLayout.rowWeights = new double[] {0.1, 0.1, 0.1}; tbDirectedGraph.setPreferredSize(new java.awt.Dimension(304, 242)); containerTabbedPane.add(tbDirectedGraph); containerTabbedPane.setTitleAt(0, "Directed Graph"); btnFilterDirectedGraph.setText("Filter Graph"); tbDirectedGraph.add( btnFilterDirectedGraph, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, 17, 0, new Insets(0, 5, 0, 5), 0, 0)); btnFilterDirectedGraph.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent evt) { btnFilterDirectedGraphActionPerformed(evt); } }); GridBagLayout dirVertexDegreePanelLayout = new GridBagLayout(); dirVertexDegreePanel.setLayout(dirVertexDegreePanelLayout); dirVertexDegreePanelLayout.columnWidths = new int[] {1, 1}; dirVertexDegreePanelLayout.rowHeights = new int[] {1, 1, 1, 1, 1}; dirVertexDegreePanelLayout.columnWeights = new double[] {0.1, 0.1}; dirVertexDegreePanelLayout.rowWeights = new double[] {0.1, 0.1, 0.1, 0.1, 0.1}; dirVertexDegreePanel.setBorder( new TitledBorder( new LineBorder(new java.awt.Color(0, 0, 0), 1, false), "Vertex Degree", TitledBorder.LEADING, TitledBorder.TOP, new java.awt.Font("Dialog", 1, 12), new java.awt.Color(0, 0, 0))); tbDirectedGraph.add( dirVertexDegreePanel, new GridBagConstraints(0, 0, 1, 3, 0.0, 0.0, 10, 1, new Insets(0, 0, 0, 0), 0, 0)); lblMinInDegree.setText("In-Degree Minimum"); dirVertexDegreePanel.add( lblMinInDegree, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, 17, 0, new Insets(0, 5, 0, 5), 0, 0)); lblMaxInDegree.setText("In-Degree Maximum"); dirVertexDegreePanel.add( lblMaxInDegree, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, 17, 0, new Insets(0, 5, 0, 5), 0, 0)); lblMinOutDegree.setText("Out-Degree Minimum"); dirVertexDegreePanel.add( lblMinOutDegree, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, 17, 0, new Insets(0, 5, 0, 5), 0, 0)); lblMaxOutDegree.setText("Out-Degree Maximum"); dirVertexDegreePanel.add( lblMaxOutDegree, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, 17, 0, new Insets(0, 5, 0, 5), 0, 0)); tfInDegreeMin.setMinimumSize(new java.awt.Dimension(40, 20)); dirVertexDegreePanel.add( tfInDegreeMin, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, 10, 2, new Insets(0, 0, 0, 0), 0, 0)); tfInDegreeMax.setMinimumSize(new java.awt.Dimension(40, 20)); dirVertexDegreePanel.add( tfInDegreeMax, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, 10, 2, new Insets(0, 0, 0, 0), 0, 0)); tfOutDegreeMin.setMinimumSize(new java.awt.Dimension(40, 20)); dirVertexDegreePanel.add( tfOutDegreeMin, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, 10, 2, new Insets(0, 0, 0, 0), 0, 0)); tfOutDegreeMax.setMinimumSize(new java.awt.Dimension(40, 20)); dirVertexDegreePanel.add( tfOutDegreeMax, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0, 10, 2, new Insets(0, 0, 0, 0), 0, 0)); lblIinstructions.setText( "<html>Enter degree values by which to filter graph. Leave blank to use minimum or maximum value.</html>"); lblIinstructions.setHorizontalAlignment(SwingConstants.LEADING); lblIinstructions.setHorizontalTextPosition(SwingConstants.TRAILING); lblIinstructions.setVerticalAlignment(SwingConstants.TOP); lblIinstructions.setVerticalTextPosition(SwingConstants.CENTER); lblIinstructions.setPreferredSize(new java.awt.Dimension(60, 40)); lblIinstructions.setMinimumSize(new java.awt.Dimension(60, 40)); dirVertexDegreePanel.add( lblIinstructions, new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0, 10, 1, new Insets(0, 0, 0, 0), 0, 0)); GridBagLayout tbUndirectedGraphLayout = new GridBagLayout(); tbUndirectedGraph.setLayout(tbUndirectedGraphLayout); tbUndirectedGraphLayout.columnWidths = new int[] {1}; tbUndirectedGraphLayout.rowHeights = new int[] {1, 1, 1}; tbUndirectedGraphLayout.columnWeights = new double[] {0.1}; tbUndirectedGraphLayout.rowWeights = new double[] {0.1, 0.1, 0.1}; tbUndirectedGraph.setPreferredSize(new java.awt.Dimension(304, 212)); containerTabbedPane.add(tbUndirectedGraph); containerTabbedPane.setTitleAt(1, "Undirected Graph"); GridBagLayout unDirVertexDegreePanelLayout = new GridBagLayout(); unDirVertexDegreePanel.setLayout(unDirVertexDegreePanelLayout); unDirVertexDegreePanelLayout.columnWidths = new int[] {1, 1}; unDirVertexDegreePanelLayout.rowHeights = new int[] {1, 1, 1, 1}; unDirVertexDegreePanelLayout.columnWeights = new double[] {0.1, 0.1}; unDirVertexDegreePanelLayout.rowWeights = new double[] {0.1, 0.1, 0.1, 0.1}; unDirVertexDegreePanel.setBorder( new TitledBorder( new LineBorder(new java.awt.Color(0, 0, 0), 1, false), "Vertex Degree", TitledBorder.LEADING, TitledBorder.TOP, new java.awt.Font("Dialog", 1, 12), new java.awt.Color(0, 0, 0))); tbUndirectedGraph.add( unDirVertexDegreePanel, new GridBagConstraints(0, 0, 1, 2, 0.0, 0.0, 10, 1, new Insets(0, 0, 0, 0), 0, 0)); lblMinDegree.setText("Minimum Degree"); unDirVertexDegreePanel.add( lblMinDegree, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, 17, 0, new Insets(0, 5, 0, 5), 0, 0)); lblMaxDegree.setText("Maximum Degree"); unDirVertexDegreePanel.add( lblMaxDegree, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, 17, 0, new Insets(0, 5, 0, 5), 0, 0)); tfMinDegree.setMinimumSize(new java.awt.Dimension(40, 20)); unDirVertexDegreePanel.add( tfMinDegree, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, 10, 0, new Insets(0, 0, 0, 0), 0, 0)); tfMaxDegree.setMinimumSize(new java.awt.Dimension(40, 20)); unDirVertexDegreePanel.add( tfMaxDegree, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, 10, 0, new Insets(0, 0, 0, 0), 0, 0)); lblInstructionsDir.setText( "<html>Enter degree values by which to filter graph. Leave blank to use minimum or maximum value.</html>"); unDirVertexDegreePanel.add( lblInstructionsDir, new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0, 10, 1, new Insets(0, 0, 0, 0), 0, 0)); btnFilterUndirectedGraph.setText("Filter Graph"); tbUndirectedGraph.add( btnFilterUndirectedGraph, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, 17, 0, new Insets(5, 5, 5, 5), 0, 0)); btnFilterUndirectedGraph.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent evt) { btnFilterUndirectedGraphActionPerformed(evt); } }); postInitGUI(); } catch (Exception e) { e.printStackTrace(); } }
public WizStepManyTextFields(Wizard w, String instr, Vector strings) { // store wizard? _instructions.setText(instr); _instructions.setWrapStyleWord(true); _instructions.setEditable(false); _instructions.setBorder(null); _instructions.setBackground(_mainPanel.getBackground()); _mainPanel.setBorder(new EtchedBorder()); GridBagLayout gb = new GridBagLayout(); _mainPanel.setLayout(gb); GridBagConstraints c = new GridBagConstraints(); c.ipadx = 3; c.ipady = 3; c.weightx = 0.0; c.weighty = 0.0; c.anchor = GridBagConstraints.EAST; JLabel image = new JLabel(""); // image.setMargin(new Insets(0, 0, 0, 0)); image.setIcon(WIZ_ICON); image.setBorder(null); c.gridx = 0; c.gridheight = GridBagConstraints.REMAINDER; c.gridy = 0; c.anchor = GridBagConstraints.NORTH; gb.setConstraints(image, c); _mainPanel.add(image); c.weightx = 0.0; c.gridx = 2; c.gridheight = 1; c.gridwidth = 3; c.gridy = 0; c.fill = GridBagConstraints.NONE; gb.setConstraints(_instructions, c); _mainPanel.add(_instructions); c.gridx = 1; c.gridy = 1; c.weightx = 0.0; c.gridwidth = 1; c.fill = GridBagConstraints.NONE; SpacerPanel spacer = new SpacerPanel(); gb.setConstraints(spacer, c); _mainPanel.add(spacer); c.gridx = 2; c.weightx = 1.0; c.anchor = GridBagConstraints.WEST; c.gridwidth = 1; int size = strings.size(); for (int i = 0; i < size; i++) { c.gridy = 2 + i; String s = (String) strings.elementAt(i); JTextField tf = new JTextField(s, 50); tf.setMinimumSize(new Dimension(200, 20)); tf.getDocument().addDocumentListener(this); _fields.addElement(tf); gb.setConstraints(tf, c); _mainPanel.add(tf); } c.gridx = 1; c.gridy = 3 + strings.size(); c.weightx = 0.0; c.gridwidth = 1; c.fill = GridBagConstraints.NONE; SpacerPanel spacer2 = new SpacerPanel(); gb.setConstraints(spacer2, c); _mainPanel.add(spacer2); }