public void actionPerformed(ActionEvent e) { texta.setText( lblName.getText() + text0.getText() + '\n' + lblSex.getText() + ((JRadioButton) e.getSource()).getText()); }
public void stateChanged(ChangeEvent e) { texta.setText( lblName.getText() + text0.getText() + '\n' + lblAge.getText() + ((JSpinner) e.getSource()).getValue()); }
private void resetPanel() { cal = new GregorianCalendar( Integer.parseInt(yearSpi.getValue().toString()), monthBox.getSelectedIndex(), Integer.parseInt(lastLabel.getText())); startPoint_x = 20; startPoint_y = 10; panel.removeAll(); panel.repaint(); initCalPanel(); }
private JPanel makeSlider(JLabel label, JSlider slider, JLabel value, String color) { JPanel p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); label.setDisplayedMnemonic(label.getText().charAt(0)); label.setLabelFor(slider); String tip = color + " color component slider"; label.setToolTipText(tip); slider.setToolTipText(tip); value.setToolTipText(tip); p.add(label); slider.setMaximumSize(new Dimension(128, slider.getMaximumSize().height)); slider.addChangeListener(this); p.add(slider); p.add(value); return p; }
/** * A helper function that obtains the total number of hours for the selected period. * * @return Total number of hours. * @throws InsufficientDataException Thrown if the total is zero. */ private double checkTotal() throws InsufficientDataException { double total = Double.parseDouble(totalLabel.getText()); if (total == 0) throw new InsufficientDataException("Cannot submit data with no logged hours."); return total; }
/** * Edit row * * @param paramInfo param info * @param removeOnCancel Should remove param info if user presses cancel_ * @return ok */ public boolean editRow(ParamInfo paramInfo, boolean removeOnCancel) { List comps = new ArrayList(); ParamField nameFld = new ParamField(null, true); nameFld.setText(paramInfo.getName()); JPanel topPanel = GuiUtils.hbox(GuiUtils.lLabel("Parameter: "), nameFld); topPanel = GuiUtils.inset(topPanel, 5); comps.add(GuiUtils.inset(new JLabel("Defined"), new Insets(5, 0, 0, 0))); comps.add(GuiUtils.filler()); comps.add(GuiUtils.filler()); final JLabel ctPreviewLbl = new JLabel(""); final JLabel ctLbl = new JLabel(""); if (paramInfo.hasColorTableName()) { ctLbl.setText(paramInfo.getColorTableName()); ColorTable ct = getIdv().getColorTableManager().getColorTable(paramInfo.getColorTableName()); if (ct != null) { ctPreviewLbl.setIcon(ColorTableCanvas.getIcon(ct)); } else { ctPreviewLbl.setIcon(null); } } String cbxLabel = ""; final ArrayList menus = new ArrayList(); getIdv() .getColorTableManager() .makeColorTableMenu( new ObjectListener(null) { public void actionPerformed(ActionEvent ae, Object data) { ctLbl.setText(data.toString()); ColorTable ct = getIdv().getColorTableManager().getColorTable(ctLbl.getText()); if (ct != null) { ctPreviewLbl.setIcon(ColorTableCanvas.getIcon(ct)); } else { ctPreviewLbl.setIcon(null); } } }, menus); JCheckBox ctUseCbx = new JCheckBox(cbxLabel, paramInfo.hasColorTableName()); final JButton ctPopup = new JButton("Change"); ctPopup.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent ae) { GuiUtils.showPopupMenu(menus, ctPopup); } }); addEditComponents( comps, "Color Table:", ctUseCbx, GuiUtils.hbox(ctPopup, GuiUtils.vbox(ctLbl, ctPreviewLbl), 5)); JCheckBox rangeUseCbx = new JCheckBox(cbxLabel, paramInfo.hasRange()); JTextField minFld = new JTextField("" + paramInfo.getMin(), 4); JTextField maxFld = new JTextField("" + paramInfo.getMax(), 4); JPanel rangePanel = GuiUtils.hbox(minFld, maxFld, 5); addEditComponents(comps, "Range:", rangeUseCbx, rangePanel); JCheckBox unitUseCbx = new JCheckBox(cbxLabel, paramInfo.hasDisplayUnit()); String unitLabel = ""; Unit unit = null; if (paramInfo.hasDisplayUnit()) { unit = paramInfo.getDisplayUnit(); } JComboBox unitFld = getIdv().getDisplayConventions().makeUnitBox(unit, null); // JTextField unitFld = new JTextField(unitLabel, 15); addEditComponents(comps, "Unit:", unitUseCbx, unitFld); ContourInfo ci = paramInfo.getContourInfo(); JCheckBox contourUseCbx = new JCheckBox(cbxLabel, ci != null); if (ci == null) { ci = new ContourInfo(); } ContourInfoDialog contDialog = new ContourInfoDialog("Edit Contour Defaults", false, null, false); contDialog.setState(ci); addEditComponents(comps, "Contour:", contourUseCbx, contDialog.getContents()); GuiUtils.tmpInsets = new Insets(5, 5, 5, 5); JComponent contents = GuiUtils.doLayout(comps, 3, GuiUtils.WT_NNY, GuiUtils.WT_N); contents = GuiUtils.topCenter(topPanel, contents); contents = GuiUtils.inset(contents, 5); while (true) { if (!GuiUtils.showOkCancelDialog(null, "Parameter Defaults", contents, null)) { if (removeOnCancel) { myParamInfos.remove(paramInfo); tableChanged(); } return false; } String what = ""; try { if (contourUseCbx.isSelected()) { what = "setting contour defaults"; contDialog.doApply(); ci.set(contDialog.getInfo()); paramInfo.setContourInfo(ci); } else { paramInfo.clearContourInfo(); } if (unitUseCbx.isSelected()) { what = "setting display unit"; Object selected = unitFld.getSelectedItem(); String unitName = TwoFacedObject.getIdString(selected); if ((unitName == null) || unitName.trim().equals("")) { paramInfo.setDisplayUnit(null); } else { paramInfo.setDisplayUnit(ucar.visad.Util.parseUnit(unitName)); } } else { paramInfo.setDisplayUnit(null); } if (ctUseCbx.isSelected()) { paramInfo.setColorTableName(ctLbl.getText()); } else { paramInfo.clearColorTableName(); } if (rangeUseCbx.isSelected()) { what = "setting range"; paramInfo.setRange( new Range(Misc.parseNumber(minFld.getText()), Misc.parseNumber(maxFld.getText()))); } else { paramInfo.clearRange(); } paramInfo.setName(nameFld.getText().trim()); break; } catch (Exception exc) { errorMsg("An error occurred " + what + "\n " + exc.getMessage()); // exc.printStackTrace(); } } repaint(); saveData(); return true; }
public void actionPerformed(ActionEvent e) { texta.setText(lblName.getText() + text0.getText()); }
public void valueChanged(ListSelectionEvent e) { Object[] values = ((JList) e.getSource()).getSelectedValues(); String txtItem = ""; for (int i = 0; i < values.length; i++) txtItem += values[i].toString(); texta.setText(lblName.getText() + text0.getText() + '\n' + lblPlace.getText() + txtItem); }
public void itemStateChanged(ItemEvent e) { texta.setText( lblName.getText() + text0.getText() + '\n' + lblAcad.getText() + e.getItem()); }
public void actionPerformed(ActionEvent e) { String txt = lblInter.getText(); for (int i = 0; i < check.length; i++) if (check[i].isSelected()) txt += check[i].getText(); texta.setText(lblName.getText() + text0.getText() + '\n' + txt); }
public String getLabelText() { return label.getText(); }