List of usage examples for javax.swing JComboBox JComboBox
public JComboBox()
JComboBox
with a default data model. From source file:gda.gui.beans.EnumPositionerComboBean.java
/** * Must be called after the positions array has been populated. * /* ww w .ja v a 2 s. co m*/ * @return JComboBox */ private JComboBox getCmbChoices() { if (cmbChoices == null && commandPositions != null) { ComboBoxModel cmbChoicesModel = new DefaultComboBoxModel(commandPositions); cmbChoices = new JComboBox(); cmbChoices.setModel(cmbChoicesModel); cmbChoices.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { uk.ac.gda.util.ThreadManager.getThread(new Runnable() { @Override public void run() { cmbChoicesActionPerformed(); } }).start(); } }); } return cmbChoices; }
From source file:dbmods.InsertTemplateName.java
private void addUserName() { //START >> jTechnologyLabel jTechnologyLabel = new JLabel(); getContentPane().add(jTechnologyLabel); jTechnologyLabel.setText("Technology"); jTechnologyLabel.setBounds(28, 78, 152, 16); //END << jTechnologyLabel //START >> jUserList ComboBoxModel<String> jUserListModel = new DefaultComboBoxModel<String>(USERS); jUserList = new JComboBox<String>(); getContentPane().add(jUserList);// w ww . j a va2 s .c o m jUserList.setModel(jUserListModel); jUserList.setBounds(192, 110, 118, 23); //END << jUserList }
From source file:coolmap.canvas.datarenderer.renderer.impl.NumberComposite.java
public NumberComposite() { setName("Number to Composite"); // System.out.println("Created a new NumberComposite"); setDescription("A renderer that can be used to assign renderers to different aggregations"); configUI.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 0;/*from w w w . j av a 2 s . c om*/ c.gridy = 0; c.ipadx = 5; c.ipady = 5; c.insets = new Insets(2, 2, 2, 2); c.gridwidth = 1; //This combo box will need to be able to add registered singleComboBox = new JComboBox(); rowComboBox = new JComboBox(); columnComboBox = new JComboBox(); rowColumnComboBox = new JComboBox(); singleLegend = new JLabel(); rowLegend = new JLabel(); columnLegend = new JLabel(); rowColumnLegend = new JLabel(); singleLegend.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); rowLegend.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); columnLegend.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); rowColumnLegend.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); //Add them JLabel label = new JLabel("Default:"); label.setToolTipText("Default renderer"); c.gridx = 0; c.gridy++; configUI.add(label, c); c.gridx = 1; configUI.add(singleComboBox, c); singleComboBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { updateRenderer(); } } }); c.gridx = 2; JButton config = new JButton(UI.getImageIcon("gear")); configUI.add(config, c); config.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (singleRenderer == null) { return; } // JOptionPane.showmess int returnVal = JOptionPane.showConfirmDialog(CoolMapMaster.getCMainFrame(), singleRenderer.getConfigUI(), "Default Renderer Config", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null); if (returnVal == JOptionPane.OK_OPTION) { updateRenderer(); } } }); c.gridx = 1; c.gridy++; c.gridwidth = 1; configUI.add(singleLegend, c); ////////////////////////////////////////////////////////////// c.gridx = 0; c.gridy++; c.gridwidth = 1; label = new JLabel("Row Group:"); label.setToolTipText("Renderer for row ontology nodes"); configUI.add(label, c); c.gridx = 1; configUI.add(rowComboBox, c); c.gridx++; config = new JButton(UI.getImageIcon("gear")); configUI.add(config, c); config.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (rowGroupRenderer == null) { return; } // JOptionPane.showmess int returnVal = JOptionPane.showConfirmDialog(CoolMapMaster.getCMainFrame(), rowGroupRenderer.getConfigUI(), "Row Group Renderer Config", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null); if (returnVal == JOptionPane.OK_OPTION) { updateRenderer(); } } }); rowComboBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { updateRenderer(); } } }); c.gridx = 1; c.gridy++; c.gridwidth = 1; configUI.add(rowLegend, c); c.gridx = 0; c.gridy++; c.gridwidth = 1; label = new JLabel("Column Group:"); label.setToolTipText("Renderer for column ontology nodes"); configUI.add(label, c); c.gridx = 1; configUI.add(columnComboBox, c); c.gridx++; config = new JButton(UI.getImageIcon("gear")); configUI.add(config, c); config.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (columnGroupRenderer == null) { return; } // JOptionPane.showmess int returnVal = JOptionPane.showConfirmDialog(CoolMapMaster.getCMainFrame(), columnGroupRenderer.getConfigUI(), "Column Group Renderer Config", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null); if (returnVal == JOptionPane.OK_OPTION) { updateRenderer(); } } }); c.gridx = 1; c.gridy++; c.gridwidth = 1; configUI.add(columnLegend, c); columnComboBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { updateRenderer(); } } }); c.gridx = 0; c.gridy++; c.gridwidth = 1; label = new JLabel("Row & Column Group:"); label.setToolTipText("Renderer for row and column ontology nodes"); configUI.add(label, c); c.gridx = 1; configUI.add(rowColumnComboBox, c); c.gridx++; config = new JButton(UI.getImageIcon("gear")); configUI.add(config, c); config.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (rowColumnGroupRenderer == null) { return; } // JOptionPane.showmess int returnVal = JOptionPane.showConfirmDialog(CoolMapMaster.getCMainFrame(), rowColumnGroupRenderer.getConfigUI(), "Row + Column Group Renderer Config", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null); if (returnVal == JOptionPane.OK_OPTION) { updateRenderer(); } } }); rowColumnComboBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { updateRenderer(); } } }); c.gridx = 1; c.gridy++; c.gridwidth = 1; configUI.add(rowColumnLegend, c); JButton button = new JButton("Apply Changes", UI.getImageIcon("refresh")); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { updateRenderer(); } }); c.gridx = 0; c.gridy++; c.gridwidth = 2; configUI.add(button, c); singleComboBox.setRenderer(new ComboRenderer()); rowComboBox.setRenderer(new ComboRenderer()); columnComboBox.setRenderer(new ComboRenderer()); rowColumnComboBox.setRenderer(new ComboRenderer()); _updateLists(); }
From source file:gtu._work.ui.ObnfExceptionLogDownloadUI.java
private void initGUI() { try {/* ww w .j av a2s . c o m*/ JCommonUtil.frameCloseConfirm(this); BorderLayout thisLayout = new BorderLayout(); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); getContentPane().setLayout(thisLayout); { jTabbedPane1 = new JTabbedPane(); getContentPane().add(jTabbedPane1, BorderLayout.CENTER); { jPanel1 = new JPanel(); FlowLayout jPanel1Layout = new FlowLayout(); jTabbedPane1.addTab("", null, jPanel1, null); jPanel1.setLayout(jPanel1Layout); { jLabel1 = new JLabel(); jPanel1.add(jLabel1); jLabel1.setText("\u532f\u51fa\u76ee\u9304"); } { exportTextField = new JTextField(); JCommonUtil.jTextFieldSetFilePathMouseEvent(exportTextField, true); jPanel1.add(exportTextField); exportTextField.setPreferredSize(new java.awt.Dimension(187, 22)); } { jLabel2 = new JLabel(); jPanel1.add(jLabel2); jLabel2.setText("domainJar"); jLabel2.setPreferredSize(new java.awt.Dimension(56, 15)); } { domainJarText = new JTextField(); ObnfRepairDBBatch batch = new ObnfRepairDBBatch(); domainJarText.setText(batch.fetchDomainJar()); JCommonUtil.jTextFieldSetFilePathMouseEvent(domainJarText, false); jPanel1.add(domainJarText); domainJarText.setPreferredSize(new java.awt.Dimension(185, 22)); } { jScrollPane1 = new JScrollPane(); jPanel1.add(jScrollPane1); jScrollPane1.setPreferredSize(new java.awt.Dimension(512, 262)); { messageIdArea = new JTextArea(); jScrollPane1.setViewportView(messageIdArea); } } { DefaultComboBoxModel jComboBox1Model = new DefaultComboBoxModel(); for (FtpSite f : FtpSite.values()) { jComboBox1Model.addElement(f); } siteFtpComboBox = new JComboBox(); jPanel1.add(siteFtpComboBox); siteFtpComboBox.setModel(jComboBox1Model); } { downloadBtn = new JButton(); jPanel1.add(downloadBtn); downloadBtn.setText("\u4e0b\u8f09"); downloadBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { downloadBtnAction(); } }); } { makeReportBtn = new JButton(); jPanel1.add(makeReportBtn); makeReportBtn.setText("\u7522\u751f\u5831\u8868"); makeReportBtn.setPreferredSize(new java.awt.Dimension(102, 22)); makeReportBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { makeReportBtnPerformed(); } }); } } { jPanel2 = new JPanel(); BorderLayout jPanel2Layout = new BorderLayout(); jPanel2.setLayout(jPanel2Layout); jTabbedPane1.addTab("log", null, jPanel2, null); { jScrollPane2 = new JScrollPane(); jPanel2.add(jScrollPane2, BorderLayout.CENTER); jScrollPane2.setPreferredSize(new java.awt.Dimension(529, 340)); { logArea = new JTextArea(); jScrollPane2.setViewportView(logArea); } } } } pack(); this.setSize(542, 394); } catch (Exception e) { //add your error handling code here e.printStackTrace(); } }
From source file:edu.harvard.mcz.imagecapture.SpecimenPartAttributeDialog.java
private void init() { thisDialog = this; setBounds(100, 100, 820, 335);//from w ww . ja va2s . com getContentPane().setLayout(new BorderLayout()); contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); getContentPane().add(contentPanel, BorderLayout.CENTER); JPanel panel = new JPanel(); panel.setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, })); { JLabel lblAttributeType = new JLabel("Attribute Type"); panel.add(lblAttributeType, "2, 2, right, default"); } { comboBoxType = new JComboBox(); comboBoxType.setModel(new DefaultComboBoxModel( new String[] { "caste", "scientific name", "sex", "life stage", "part association" })); comboBoxType.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String item = comboBoxType.getSelectedItem().toString(); if (item != null) { comboBoxValue.setEditable(false); if (item.equals("scientific name")) { comboBoxValue.setEditable(true); } if (item.equals("sex")) { comboBoxValue.setModel(new DefaultComboBoxModel(Sex.getSexValues())); } if (item.equals("life stage")) { comboBoxValue.setModel(new DefaultComboBoxModel(LifeStage.getLifeStageValues())); } if (item.equals("caste")) { comboBoxValue.setModel(new DefaultComboBoxModel(Caste.getCasteValues())); } if (item.equals("part association")) { comboBoxValue .setModel(new DefaultComboBoxModel(PartAssociation.getPartAssociationValues())); } } } }); panel.add(comboBoxType, "4, 2, fill, default"); } { JLabel lblValue = new JLabel("Value"); panel.add(lblValue, "2, 4, right, default"); } { comboBoxValue = new JComboBox(); comboBoxValue.setModel(new DefaultComboBoxModel(Caste.getCasteValues())); panel.add(comboBoxValue, "4, 4, fill, default"); } { JLabel lblUnits = new JLabel("Units"); panel.add(lblUnits, "2, 6, right, default"); } { textFieldUnits = new JTextField(); panel.add(textFieldUnits, "4, 6, fill, default"); textFieldUnits.setColumns(10); } { JLabel lblRemarks = new JLabel("Remarks"); panel.add(lblRemarks, "2, 8, right, default"); } contentPanel.setLayout(new BorderLayout(0, 0)); contentPanel.add(panel, BorderLayout.WEST); { textFieldRemarks = new JTextField(); panel.add(textFieldRemarks, "4, 8, fill, default"); textFieldRemarks.setColumns(10); } { JButton btnAdd = new JButton("Add"); btnAdd.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SpecimenPartAttribute newAttribs = new SpecimenPartAttribute(); newAttribs.setAttributeType(comboBoxType.getSelectedItem().toString()); newAttribs.setAttributeValue(comboBoxValue.getSelectedItem().toString()); newAttribs.setAttributeUnits(textFieldUnits.getText()); newAttribs.setAttributeRemark(textFieldRemarks.getText()); newAttribs.setSpecimenPartId(parentPart); newAttribs.setAttributeDeterminer(Singleton.getSingletonInstance().getUserFullName()); parentPart.getAttributeCollection().add(newAttribs); SpecimenPartAttributeLifeCycle sls = new SpecimenPartAttributeLifeCycle(); try { sls.attachDirty(newAttribs); } catch (SaveFailedException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } ((AbstractTableModel) table.getModel()).fireTableDataChanged(); } }); panel.add(btnAdd, "4, 10"); } try { JLabel lblNewLabel = new JLabel(parentPart.getSpecimenId().getBarcode() + ":" + parentPart.getPartName() + " " + parentPart.getPreserveMethod() + " (" + parentPart.getLotCount() + ") Right click on table to edit attributes."); contentPanel.add(lblNewLabel, BorderLayout.NORTH); } catch (Exception e) { JLabel lblNewLabel = new JLabel("No Specimen"); contentPanel.add(lblNewLabel, BorderLayout.NORTH); } JComboBox comboBox = new JComboBox(); comboBox.addItem("caste"); JComboBox comboBox1 = new JComboBox(); for (int i = 0; i < Caste.getCasteValues().length; i++) { comboBox1.addItem(Caste.getCasteValues()[i]); } JScrollPane scrollPane = new JScrollPane(); table = new JTable(new SpecimenPartsAttrTableModel( (Collection<SpecimenPartAttribute>) parentPart.getAttributeCollection())); //table.getColumnModel().getColumn(0).setCellEditor(new DefaultCellEditor(comboBox)); table.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { if (e.isPopupTrigger()) { clickedOnRow = ((JTable) e.getComponent()).getSelectedRow(); popupMenu.show(e.getComponent(), e.getX(), e.getY()); } } @Override public void mouseReleased(MouseEvent e) { if (e.isPopupTrigger()) { clickedOnRow = ((JTable) e.getComponent()).getSelectedRow(); popupMenu.show(e.getComponent(), e.getX(), e.getY()); } } }); popupMenu = new JPopupMenu(); JMenuItem mntmCloneRow = new JMenuItem("Edit Row"); mntmCloneRow.setMnemonic(KeyEvent.VK_E); mntmCloneRow.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { // Launch a dialog to edit the selected row. SpecimenPartAttribEditDialog popup = new SpecimenPartAttribEditDialog( ((SpecimenPartsAttrTableModel) table.getModel()).getRowObject(clickedOnRow)); popup.setVisible(true); } catch (Exception ex) { log.error(ex.getMessage()); JOptionPane.showMessageDialog(thisDialog, "Failed to edit a part attribute row. " + ex.getMessage()); } } }); popupMenu.add(mntmCloneRow); JMenuItem mntmDeleteRow = new JMenuItem("Delete Row"); mntmDeleteRow.setMnemonic(KeyEvent.VK_D); mntmDeleteRow.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { if (clickedOnRow >= 0) { ((SpecimenPartsAttrTableModel) table.getModel()).deleteRow(clickedOnRow); } } catch (Exception ex) { log.error(ex.getMessage()); JOptionPane.showMessageDialog(thisDialog, "Failed to delete a part attribute row. " + ex.getMessage()); } } }); popupMenu.add(mntmDeleteRow); // TODO: Enable controlled value editing of selected row. // table.getColumnModel().getColumn(1).setCellEditor(new DefaultCellEditor(comboBox1)); scrollPane.setViewportView(table); contentPanel.add(scrollPane, BorderLayout.EAST); { JPanel buttonPane = new JPanel(); buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); getContentPane().add(buttonPane, BorderLayout.SOUTH); { okButton = new JButton("OK"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { okButton.grabFocus(); thisDialog.setVisible(false); } }); okButton.setActionCommand("OK"); buttonPane.add(okButton); getRootPane().setDefaultButton(okButton); } { JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { thisDialog.setVisible(false); } }); cancelButton.setActionCommand("Cancel"); buttonPane.add(cancelButton); } } }
From source file:com.projity.dialog.ResourceMappingDialog.java
/** * Creates, intializes and configures the UI components. Real applications * may further bind the components to underlying models. *//* w w w . j av a2 s.c o m*/ protected void initControls() { editorCombo = new JComboBox(); associationTable = new AssociationTable(); // field1=new JComboBox(form.getMergeFields()); // field1.setSelectedItem(form.getMergeField()); field1 = new JComboBox(); field1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { form.setMergeField((ResourceMappingForm.MergeField) field1.getSelectedItem()); ((AssociationTableModel) associationTable.getModel()).update(); } }); field1Label = new JLabel(Messages.getString("ResourceMappingDialog.MergeResourcesUsingField")); //$NON-NLS-1$ localProject = new JCheckBox(Messages.getString("ResourceMappingDialog.DontMergeOpenProjectReadOnly")); //$NON-NLS-1$ accessControlLabel = new JLabel(Messages.getString("ResourceMappingDialog.ProjectTeam")); //$NON-NLS-1$ accessControl = new JComboBox( new Object[] { Messages.getString("ResourceMappingDialog.AllResourcesExceptCustomerPartner"), //$NON-NLS-1$ Messages.getString("ResourceMappingDialog.BasedOnProjectRoleInResourcesView") }); //$NON-NLS-1$ HelpUtil.addDocHelp(accessControl, "Project_Team"); // localProject.addItemListener(new ItemListener(){ // public void itemStateChanged(ItemEvent e) { // accessControl.setEnabled(!accessControl.isEnabled()); // } // }); // localProject.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setLocal(localProject.isSelected()); if (masterProject != null && localProject.isSelected()) { form.setMaster(false); masterProject.setSelected(false); } } }); }
From source file:net.sf.jclal.gui.view.components.chart.ExternalBasicChart.java
/** * * @param windowsTitleParam The title of the window. * @param chartTitleParam The title of the chart panel. * @param xTitleParam The X-axis label./* w w w . j a va2 s. c o m*/ */ public ExternalBasicChart(String windowsTitleParam, String chartTitleParam, String xTitleParam) { reportFrecuency = 1; menubar = new JMenuBar(); menubar.add(createMenu()); max = -1; windowsTitle = windowsTitleParam; chartTitle = chartTitleParam; xTitle = xTitleParam; queryNames = new ArrayList<String>(); evaluationsCollection = new ArrayList<List<AbstractEvaluation>>(); controlCurveColor = new HashMap<String, Color>(); set = new HashSet<Integer>(); setSeries = new HashSet<String>(); colors = new ArrayList<Color>(); chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new Dimension(640, 480)); chartPanel.setFillZoomRectangle(true); chartPanel.setMouseWheelEnabled(true); slider = new JSlider(JSlider.HORIZONTAL); slider.setPaintTicks(true); slider.setPaintLabels(true); slider.setToolTipText("Changes the report frecuency"); slider.setSnapToTicks(true); slider.setMinimum(1); slider.setMinorTickSpacing(1); slider.addChangeListener(new ChangeListener() { @Override public void stateChanged(javax.swing.event.ChangeEvent evt) { reportFrecuency = ((JSlider) evt.getSource()).getValue(); slider.setToolTipText(String.valueOf(reportFrecuency)); jComboBoxItemStateChanged(); } }); comboBox = new JComboBox<String>(); comboBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent evt) { jComboBoxItemStateChanged(); } }); content = new JPanel(new BorderLayout()); content.add(comboBox, BorderLayout.NORTH); content.add(chartPanel, BorderLayout.CENTER); content.add(slider, BorderLayout.SOUTH); setJMenuBar(menubar); setTitle(windowsTitle); setContentPane(this.content); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); }
From source file:au.org.ala.delta.intkey.ui.TaxonInformationDialog.java
public TaxonInformationDialog(Frame owner, List<Item> taxa, IntkeyContext context, boolean imageDisplayEnabled) { super(owner, false); setPreferredSize(new Dimension(550, 280)); setMinimumSize(new Dimension(550, 280)); ResourceMap resourceMap = Application.getInstance().getContext() .getResourceMap(TaxonInformationDialog.class); resourceMap.injectFields(this); ActionMap actionMap = Application.getInstance().getContext().getActionMap(TaxonInformationDialog.class, this); setTitle(title);/*from w ww .j a va 2 s .c om*/ getContentPane().setLayout(new BorderLayout(0, 0)); _mainPanel = new JPanel(); getContentPane().add(_mainPanel, BorderLayout.CENTER); _mainPanel.setLayout(new BorderLayout(0, 0)); _comboPanel = new JPanel(); _comboPanel.setBorder(new EmptyBorder(10, 10, 10, 10)); _mainPanel.add(_comboPanel, BorderLayout.NORTH); _comboPanel.setLayout(new BorderLayout(0, 0)); _comboBox = new JComboBox(); _comboBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { displayTaxon(_comboBox.getSelectedIndex()); } }); _comboPanel.add(_comboBox, BorderLayout.CENTER); _btnPanel = new JPanel(); _btnPanel.setBorder(new EmptyBorder(0, 0, 10, 0)); _mainPanel.add(_btnPanel, BorderLayout.SOUTH); _btnDisplay = new JButton(); _btnDisplay.setAction(actionMap.get("displaySelectedTaxonInformation")); _btnPanel.add(_btnDisplay); _btnMultipleImages = new JButton(); _btnMultipleImages.setAction(actionMap.get("displayMultipleImages")); _btnMultipleImages.setEnabled(!context.displayContinuous() && imageDisplayEnabled); _btnPanel.add(_btnMultipleImages); _btnWebSearch = new JButton(); _btnWebSearch.setAction(actionMap.get("webSearch")); _btnWebSearch.setEnabled(true); _btnPanel.add(_btnWebSearch); _btnDeselectAll = new JButton(); _btnDeselectAll.setAction(actionMap.get("deselectAllTaxonInformation")); _btnPanel.add(_btnDeselectAll); _btnDone = new JButton(); _btnDone.setAction(actionMap.get("done")); _btnPanel.add(_btnDone); _pnlCenter = new JPanel(); _mainPanel.add(_pnlCenter, BorderLayout.CENTER); _pnlCenter.setLayout(new BorderLayout(0, 0)); _pnlNavigationButtons = new JPanel(); _pnlCenter.add(_pnlNavigationButtons, BorderLayout.NORTH); _btnStart = new JButton(); _btnStart.setAction(actionMap.get("firstTaxon")); _pnlNavigationButtons.add(_btnStart); _btnPrevious = new JButton(); _btnPrevious.setAction(actionMap.get("previousTaxon")); _pnlNavigationButtons.add(_btnPrevious); _btnForward = new JButton(); _btnForward.setAction(actionMap.get("nextTaxon")); _pnlNavigationButtons.add(_btnForward); _btnEnd = new JButton(); _btnEnd.setAction(actionMap.get("lastTaxon")); _pnlNavigationButtons.add(_btnEnd); _pnlLists = new JPanel(); _pnlCenter.add(_pnlLists, BorderLayout.CENTER); _pnlLists.setLayout(new GridLayout(0, 2, 0, 0)); _pnlListOther = new JPanel(); _pnlListOther.setBorder(new EmptyBorder(5, 5, 5, 5)); _pnlLists.add(_pnlListOther); _pnlListOther.setLayout(new BorderLayout(0, 0)); _listOther = new JList(); _listOther.addMouseListener(new MouseInputAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() >= 2) { int selectedIndex = _listOther.getSelectedIndex(); _cmds.get(selectedIndex).execute(); } } }); _sclPnOther = new JScrollPane(); _sclPnOther.setViewportView(_listOther); _pnlListOther.add(_sclPnOther, BorderLayout.CENTER); _lblOther = new JLabel(); _pnlListOther.add(_lblOther, BorderLayout.NORTH); _pnlListIllustrations = new JPanel(); _pnlListIllustrations.setBorder(new EmptyBorder(5, 5, 5, 5)); _pnlLists.add(_pnlListIllustrations); _pnlListIllustrations.setLayout(new BorderLayout(0, 0)); _lblIllustrations = new JLabel(); _pnlListIllustrations.add(_lblIllustrations, BorderLayout.NORTH); _listIllustrations = new JList(); _listIllustrations.addMouseListener(new MouseInputAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() >= 2) { if (_imageDisplayEnabled) { int selectedListIndex = _listIllustrations.getSelectedIndex(); displaySelectedTaxonImage(selectedListIndex, true); } else { _context.getUI() .displayErrorMessage(UIUtils.getResourceString("ImageDisplayDisabled.error")); } } } }); _sclPnIllustrations = new JScrollPane(); _sclPnIllustrations.setViewportView(_listIllustrations); _pnlListIllustrations.add(_sclPnIllustrations); _context = context; _imageDisplayEnabled = imageDisplayEnabled; _definedDirectiveCommands = _context.getTaxonInformationDialogCommands(); _infoSettings = _context.getInfoSettings(); _imageSettings = _context.getImageSettings(); _itemFormatter = new ItemFormatter(_context.displayNumbering(), CommentStrippingMode.RETAIN, AngleBracketHandlingMode.REMOVE, true, false, false); _imageDescriptionFormatter = new Formatter(CommentStrippingMode.RETAIN, AngleBracketHandlingMode.RETAIN, true, false); int totalNumberImages = 0; _taxa = taxa; _taxaWithImages = new ArrayList<Item>(); for (Item taxon : taxa) { totalNumberImages += taxon.getImageCount(); if (taxon.getImageCount() > 0) { _taxaWithImages.add(taxon); } } if (totalNumberImages < 2) { _btnMultipleImages.setEnabled(false); } initialize(); loadDesktopInBackground(); this.pack(); }
From source file:com.floreantpos.ui.forms.CustomerForm.java
private void createCustomerForm() { setOpaque(true);//from ww w .j a va 2s.c o m setLayout(new MigLayout("", "[][][grow][][grow]", "[][][][][][][][][][][][][][][][][]")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ picturePanel = new JPanel(new MigLayout()); lblPicture = new JLabel(""); //$NON-NLS-1$ lblPicture.setIconTextGap(0); lblPicture.setHorizontalAlignment(SwingConstants.CENTER); picturePanel.setBorder(new TitledBorder(null, Messages.getString("CustomerForm.10"), TitledBorder.LEADING, //$NON-NLS-1$ TitledBorder.TOP, null, null)); picturePanel.add(lblPicture, "wrap,center"); //$NON-NLS-1$ btnSelectImage = new PosSmallButton(); btnSelectImage.setText(Messages.getString("CustomerForm.44")); //$NON-NLS-1$ picturePanel.add(btnSelectImage, "split 2"); //$NON-NLS-1$ btnClearImage = new PosSmallButton(); btnClearImage.setText(Messages.getString("CustomerForm.45")); //$NON-NLS-1$ picturePanel.add(btnClearImage); add(picturePanel, "cell 0 0 0 8"); //$NON-NLS-1$ JLabel lblSalutation = new JLabel(Messages.getString("CustomerForm.0")); //$NON-NLS-1$ add(lblSalutation, "cell 1 0,right"); //$NON-NLS-1$ cbSalutation = new JComboBox(); cbSalutation.addItem(Messages.getString("CustomerForm.2")); //$NON-NLS-1$ cbSalutation.addItem(Messages.getString("CustomerForm.4")); //$NON-NLS-1$ cbSalutation.addItem(Messages.getString("CustomerForm.5")); //$NON-NLS-1$ cbSalutation.addItem(Messages.getString("CustomerForm.6")); //$NON-NLS-1$ cbSalutation.setPreferredSize(new Dimension(100, 0)); add(cbSalutation, "cell 2 0,grow"); //$NON-NLS-1$ JLabel lblFirstName = new JLabel(Messages.getString("CustomerForm.3")); //$NON-NLS-1$ add(lblFirstName, "cell 1 1,right "); //$NON-NLS-1$ tfFirstName = new FixedLengthTextField(30); add(tfFirstName, "cell 2 1,grow"); //$NON-NLS-1$ //tfFirstName.setFocusTraversalPolicy(policy) JLabel lblLastName = new JLabel(Messages.getString("CustomerForm.11")); //$NON-NLS-1$ add(lblLastName, "cell 1 2,right"); //$NON-NLS-1$ tfLastName = new FixedLengthTextField(); add(tfLastName, "cell 2 2,grow"); //$NON-NLS-1$ lblDob = new JLabel("DoB (MM-DD-YYYY)"); //$NON-NLS-1$ add(lblDob, "cell 1 3,right"); //$NON-NLS-1$ tfDoB = new FixedLengthTextField(); add(tfDoB, "cell 2 3,grow"); //$NON-NLS-1$ JLabel lblAddress = new JLabel(Messages.getString("CustomerForm.18")); //$NON-NLS-1$ add(lblAddress, "cell 1 4,right"); //$NON-NLS-1$ tfAddress = new JTextField(); add(tfAddress, "cell 2 4,grow"); //$NON-NLS-1$ JLabel lblZip = new JLabel(Messages.getString("CustomerForm.21")); //$NON-NLS-1$ add(lblZip, "cell 1 5,right"); //$NON-NLS-1$ tfZip = new FixedLengthTextField(); add(tfZip, "cell 2 5,grow"); //$NON-NLS-1$ lblSocialSecurityNumber = new JLabel(Messages.getString("CustomerForm.22")); //$NON-NLS-1$ add(lblSocialSecurityNumber, "cell 3 0,right"); //$NON-NLS-1$ tfSocialSecurityNumber = new FixedLengthTextField(); add(tfSocialSecurityNumber, "cell 4 0,grow"); //$NON-NLS-1$ JLabel lblCitytown = new JLabel(Messages.getString("CustomerForm.24")); //$NON-NLS-1$ add(lblCitytown, "cell 3 1,right"); //$NON-NLS-1$ // tfCity = new FixedLengthTextField(); add(tfCity, "cell 4 1,grow"); //$NON-NLS-1$ JLabel lblCountry = new JLabel(Messages.getString("CustomerForm.27")); //$NON-NLS-1$ add(lblCountry, "cell 3 2,right"); //$NON-NLS-1$ tfCountry = new FixedLengthTextField(); tfCountry.setText(Messages.getString("CustomerForm.29")); //$NON-NLS-1$ add(tfCountry, "cell 4 2,grow"); //$NON-NLS-1$ lblMobile = new JLabel(Messages.getString("CustomerForm.32")); //$NON-NLS-1$ add(lblMobile, "cell 3 3 ,right"); //$NON-NLS-1$ tfMobile = new IntegerTextField(10); add(tfMobile, "cell 4 3,grow"); //$NON-NLS-1$ lblHomePhone = new JLabel("Home Phone");//$NON-NLS-1$ add(lblHomePhone, "cell 3 4,right"); //$NON-NLS-1$ tfHomePhone = new FixedLengthTextField(); add(tfHomePhone, "cell 4 4,grow"); //$NON-NLS-1$ lblWorkPhone = new JLabel(Messages.getString("CustomerForm.39")); //$NON-NLS-1$ add(lblWorkPhone, "cell 3 5,right"); //$NON-NLS-1$ tfWorkPhone = new FixedLengthTextField(); add(tfWorkPhone, "cell 4 5,grow"); //$NON-NLS-1$ JLabel lblEmail = new JLabel(Messages.getString("CustomerForm.15")); //$NON-NLS-1$ add(lblEmail, "cell 3 6 ,right"); //$NON-NLS-1$ tfEmail = new FixedLengthTextField(); add(tfEmail, "cell 4 6,grow"); //$NON-NLS-1$ lblLoyaltyPoint = new JLabel(Messages.getString("CustomerForm.34")); //$NON-NLS-1$ add(lblLoyaltyPoint, "cell 3 7,right"); //$NON-NLS-1$ tfLoyaltyPoint = new IntegerTextField(); add(tfLoyaltyPoint, "cell 4 7,grow"); //$NON-NLS-1$ cbVip = new JCheckBox(Messages.getString("CustomerForm.41")); //$NON-NLS-1$ cbVip.setFocusable(false); add(cbVip, "cell 4 8,wrap"); //$NON-NLS-1$ JLabel lblLoyaltyNo = new JLabel(Messages.getString("CustomerForm.31")); //$NON-NLS-1$ add(lblLoyaltyNo, "cell 1 6,right"); //$NON-NLS-1$ tfLoyaltyNo = new FixedLengthTextField(); tfLoyaltyNo.setLength(8); add(tfLoyaltyNo, "cell 2 6,grow"); //$NON-NLS-1$ JLabel lblCreditLimit = new JLabel(Messages.getString("CustomerForm.37")); //$NON-NLS-1$ add(lblCreditLimit, "cell 1 7,right"); //$NON-NLS-1$ tfCreditLimit = new DoubleTextField(); tfCreditLimit.setText("500.00"); //$NON-NLS-1$ add(tfCreditLimit, "cell 2 7,grow"); //$NON-NLS-1$ qwertyKeyPad = new QwertyKeyPad(); if (isKeypad) { add(qwertyKeyPad, "cell 0 10 5 5,grow"); //$NON-NLS-1$ } btnSelectImage.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { BufferedImage tmpImage; tmpImage = PosGuiUtil.selectImageFile(); if (tmpImage != null) { image = tmpImage; } if (image == null) { return; } ImageIcon imageIcon = new ImageIcon(image); lblPicture.setIcon(imageIcon); } catch (Exception e1) { PosLog.error(getClass(), e1); } } }); btnClearImage.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setDefaultCustomerPicture(); } }); setDefaultCustomerPicture(); enableCustomerFields(false); callOrderController(); }
From source file:EHRAppointment.ChartPanelDraw.java
private JComboBox createDate() { // to change the vertical and horizontal data final JComboBox date = new JComboBox(); final String[] dateCmds = { "Horizontal Dates", "Vertical Dates" }; date.setModel(new DefaultComboBoxModel(dateCmds)); date.addActionListener(new ActionListener() { @Override//from w w w. ja v a2 s. c om public void actionPerformed(ActionEvent e) { JFreeChart chart = chartPanel.getChart(); XYPlot plot = (XYPlot) chart.getPlot(); DateAxis domain = (DateAxis) plot.getDomainAxis(); if (dateCmds[0].equals(date.getSelectedItem())) { domain.setVerticalTickLabels(false); } else { domain.setVerticalTickLabels(true); } } }); return date; }