List of usage examples for java.awt.event ItemEvent getItem
public Object getItem()
From source file:op.care.med.inventory.DlgNewStocks.java
private void initDialog() { ignoreEvent = true;//from w w w . j a va 2s . co m expiry = null; logicalPrinter = OPDE.getPrintProcessor().getSelectedLogicalPrinter(); printForm = OPDE.getPrintProcessor().getSelectedForm(); if (logicalPrinter != null && printForm != null) { btnPrint.setEnabled(true); SYSPropsTools.restoreState(this.getClass().getName() + "::btnPrint", btnPrint); } else { btnPrint.setSelected(false); } lblPZN.setText(SYSTools.xx("newstocks.lblPZN")); lblProd.setText(SYSTools.xx("newstocks.lblProd")); lblPack.setText(SYSTools.xx("newstocks.lblPack")); lblAmount.setText(SYSTools.xx("newstocks.lblAmount")); lblInventory.setText(SYSTools.xx("newstocks.lblInventory")); lblRemark.setText(SYSTools.xx("misc.msg.comment")); lblExpires.setText(SYSTools.xx("misc.msg.expires")); lblResident.setText(SYSTools.xx("misc.msg.resident")); amount = null; cmbMProdukt.setRenderer(TradeFormTools.getRenderer(TradeFormTools.LONG)); attentionIconVorrat = new JLabel( OverlayableUtils.getPredefinedOverlayIcon(OverlayableIconsFactory.ATTENTION)); infoIconVorrat = new JLabel(OverlayableUtils.getPredefinedOverlayIcon(OverlayableIconsFactory.INFO)); correctIconVorrat = new JLabel(OverlayableUtils.getPredefinedOverlayIcon(OverlayableIconsFactory.CORRECT)); questionIconVorrat = new JLabel( OverlayableUtils.getPredefinedOverlayIcon(OverlayableIconsFactory.QUESTION)); cmbVorrat = new OverlayComboBox(); cmbVorrat.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent itemEvent) { inventory = (MedInventory) itemEvent.getItem(); } }); cmbVorrat.setFont(SYSConst.ARIAL14); ovrVorrat = new DefaultOverlayable(cmbVorrat); mainPane.add(ovrVorrat, CC.xywh(5, 13, 4, 1)); attentionIconBW = new JLabel(OverlayableUtils.getPredefinedOverlayIcon(OverlayableIconsFactory.ATTENTION)); cmbBW = new OverlayComboBox(); cmbBW.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent itemEvent) { cmbBWItemStateChanged(itemEvent); } }); cmbBW.setFont(SYSConst.ARIAL14); ovrBW = new DefaultOverlayable(cmbBW); mainPane.add(ovrBW, CC.xywh(7, 17, 2, 1)); if (resident == null) { ovrBW.addOverlayComponent(attentionIconBW, DefaultOverlayable.SOUTH_WEST); attentionIconBW.setToolTipText(SYSTools.xx("misc.msg.emptyselection")); } else { txtBWSuche.setEnabled(false); cmbBW.setModel(new DefaultComboBoxModel(new Resident[] { resident })); } attentionIconMenge = new JLabel( OverlayableUtils.getPredefinedOverlayIcon(OverlayableIconsFactory.ATTENTION)); correctIconMenge = new JLabel(OverlayableUtils.getPredefinedOverlayIcon(OverlayableIconsFactory.CORRECT)); txtMenge = new OverlayTextField(); txtMenge.addCaretListener(new CaretListener() { @Override public void caretUpdate(CaretEvent caretEvent) { txtMengeCaretUpdate(caretEvent); } }); txtMenge.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent focusEvent) { txtMengeFocusGained(focusEvent); } }); txtMenge.setFont(SYSConst.ARIAL14); ovrMenge = new DefaultOverlayable(txtMenge); mainPane.add(ovrMenge, CC.xy(5, 11)); lblWeightControl.setText(SYSTools.xx("opde.medication.tx.controlWeight")); lblWeightControl.setToolTipText(SYSTools.xx("opde.medication.controlWeight.newBottle.bottle.only")); weight = null; txtWeightControl.setVisible(false); txtWeightControl.setText(""); lblWeightControl.setVisible(false); ignoreEvent = false; setVisible(true); }
From source file:it.cnr.icar.eric.client.ui.swing.AdhocQuerySearchPanel.java
@SuppressWarnings({ "rawtypes", "unchecked" }) private JPanel createQuerySelectionPanel() { JPanel querySelectionPanel = new JPanel(); GridBagLayout gbl = new GridBagLayout(); querySelectionPanel.setLayout(gbl);//from w ww. j ava 2s . co m //The selectQueryCombo selectQueryLabel = new JLabel(resourceBundle.getString("title.selectQuery"), SwingConstants.LEADING); c.gridx = 0; c.gridy = 0; c.gridwidth = 1; c.gridheight = 1; c.weightx = 0.0; c.weighty = 0.0; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(4, 4, 0, 4); gbl.setConstraints(selectQueryLabel, c); querySelectionPanel.add(selectQueryLabel); //TODO: SwingBoost: localize this: selectQueryCombo = new JComboBox(new String[] { "loading queries..." }); selectQueryCombo.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent ev) { RegistryBrowser.setWaitCursor(); if (ev.getStateChange() == ItemEvent.DESELECTED) { return; } @SuppressWarnings("unused") String item = (String) ev.getItem(); int index = ((JComboBox) ev.getSource()).getSelectedIndex(); QueryType uiQueryType = queries.get(index); try { setQuery(uiQueryType); } catch (JAXRException e) { RegistryBrowser.setDefaultCursor(); throw new UndeclaredThrowableException(e); } RegistryBrowser.setDefaultCursor(); } }); c.gridx = 0; c.gridy = 1; c.gridwidth = 1; c.gridheight = 1; c.weightx = 0.5; c.weighty = 0.0; c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.LINE_END; c.insets = new Insets(4, 4, 4, 4); gbl.setConstraints(selectQueryCombo, c); querySelectionPanel.add(selectQueryCombo); //The nameTextField queryNameLabel = new JLabel(resourceBundle.getString("title.name"), SwingConstants.LEADING); c.gridx = 0; c.gridy = 2; c.gridwidth = 1; c.gridheight = 1; c.weightx = 0.0; c.weighty = 0.0; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(4, 4, 0, 4); gbl.setConstraints(queryNameLabel, c); querySelectionPanel.add(queryNameLabel); queryNameText = new JTextField(); queryNameText.setEditable(false); c.gridx = 0; c.gridy = 3; c.gridwidth = 1; c.gridheight = 1; c.weightx = 0.5; c.weighty = 0.0; c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.LINE_END; c.insets = new Insets(4, 4, 4, 4); gbl.setConstraints(queryNameText, c); querySelectionPanel.add(queryNameText); //The description TextArea queryDescLabel = new JLabel(resourceBundle.getString("title.description"), SwingConstants.LEADING); c.gridx = 0; c.gridy = 4; c.gridwidth = 1; c.gridheight = 1; c.weightx = 0.0; c.weighty = 0.0; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(4, 4, 0, 4); gbl.setConstraints(queryDescLabel, c); querySelectionPanel.add(queryDescLabel); queryDescText = new JTextArea(4, 25); queryDescText.setLineWrap(true); queryDescText.setEditable(false); c.gridx = 0; c.gridy = 5; c.gridwidth = 1; c.gridheight = 1; c.weightx = 0.5; c.weighty = 0.5; c.fill = GridBagConstraints.BOTH; c.anchor = GridBagConstraints.LINE_END; c.insets = new Insets(4, 4, 4, 4); gbl.setConstraints(queryDescText, c); querySelectionPanel.add(queryDescText); return querySelectionPanel; }
From source file:com.microsoft.intellij.forms.CreateWebSiteForm.java
public CreateWebSiteForm(@org.jetbrains.annotations.Nullable Project project, List<WebSite> webSiteList) { super(project, true, IdeModalityType.PROJECT); this.project = project; for (WebSite ws : webSiteList) { webSiteNames.add(ws.getName());/*from w w w.j a va2 s .c o m*/ } setTitle("New Web App Container"); subscriptionComboBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent itemEvent) { if (itemEvent.getItem() instanceof Subscription) { subscription = (Subscription) itemEvent.getItem(); fillResourceGroups(""); } } }); groupComboBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent itemEvent) { if (itemEvent.getStateChange() == ItemEvent.SELECTED) { if (createResGrpLabel.equals(itemEvent.getItem())) { resourceGroup = null; showcreateResourceGroupForm(); } else if (itemEvent.getItem() instanceof String) { resourceGroup = (String) itemEvent.getItem(); fillWebHostingPlans(""); } } } }); webHostingPlanComboBoxItemListner = new ItemListener() { @Override public void itemStateChanged(ItemEvent itemEvent) { if (itemEvent.getStateChange() == ItemEvent.SELECTED) { String selectedItem = (String) itemEvent.getItem(); if (selectedItem.equals(createWebHostingPlanLabel)) { showCreateWebHostingPlanForm(); } else { WebHostingPlanCache plan = hostingPlanMap.get(selectedItem); pupulateServicePlanDetails(plan); } } } }; defaultJDK.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { enableCustomJDK(false); enableCustomJDKUser(false); customJDK.setSelected(false); customJDKUser.setSelected(false); } }); customJDK.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { enableCustomJDK(true); enableCustomJDKUser(false); defaultJDK.setSelected(false); customJDKUser.setSelected(false); } }); customJDKUser.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { enableCustomJDK(false); enableCustomJDKUser(true); defaultJDK.setSelected(false); customJDK.setSelected(false); } }); storageNames.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { storageComboListener(); } }); customUrl.getDocument().addDocumentListener(createServerUrlListener()); accLink.setAction(new AccountsAction()); defaultJDK.setSelected(true); enableCustomJDK(false); enableCustomJDKUser(false); List<String> containerList = new ArrayList<String>(); for (WebAppsContainers type : WebAppsContainers.values()) { containerList.add(type.getName()); } webContainerComboBox.setModel(new DefaultComboBoxModel(containerList.toArray())); linkPrice.setURI(URI.create(message("lnkWebAppPrice"))); linkPrice.setText("Pricing"); init(); webAppCreated = ""; fillSubscriptions(); }
From source file:sms.ViewResults.java
private void jComboBoxStreamsItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jComboBoxStreamsItemStateChanged if (evt.getItem() != "" && evt.getStateChange() == ItemEvent.SELECTED && evt.getItem() != "Streams") { stream = evt.getItem().toString(); //int y=getIndex(x); // orderBy=String.valueOf(y+3); // subjectNameToId(exam); } else {/*from w ww. j a v a2s . c o m*/ stream = ""; } }
From source file:sms.ViewResults.java
private void jComboBoxSubjectsItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jComboBoxSubjectsItemStateChanged if (evt.getItem() != "" && evt.getStateChange() == ItemEvent.SELECTED && evt.getItem() != "Total") { String x = evt.getItem().toString(); int y = getIndex(x); orderBy = String.valueOf(y + 5); // subjectNameToId(exam); } else {// w w w.j av a 2 s.c o m orderBy = "2"; } }
From source file:edu.ku.brc.af.ui.forms.formatters.UIFormatterEditorDlg.java
/** * /*from ww w . ja va 2s .co m*/ */ private void hookByYearCheckBoxListener() { ItemListener il = new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getItem() == byYearCB) { // do nothing if format is new because it will be destroyed when the next key is pressed // the correct byYear state of newly created formatters is corrected when the ok button is pressed if (selectedFormat != null) { selectedFormat.setByYear(e.getStateChange() == ItemEvent.SELECTED); } } } }; byYearCB.addItemListener(il); }
From source file:sms.ViewResults.java
private void jComboBoxExamItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jComboBoxExamItemStateChanged Form1Exams n = new Form1Exams(); if (evt.getItem() != "" && evt.getStateChange() == ItemEvent.SELECTED && evt.getItem() != "Choose Exam") { examid = n.getExamId(evt.getItem().toString()); // subjectNameToId(exam); } else {//from w w w. ja v a2s. com examid = 0; } }
From source file:sms.ViewResults.java
private void jComboBoxTermsItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jComboBoxTermsItemStateChanged String[] terms = { "Term 1", "Term 2", "Term 3" }; if (evt.getItem() == terms[0] && evt.getStateChange() == ItemEvent.SELECTED) { termid = 1;/*w w w .j a v a 2s .c o m*/ // JOptionPane.showMessageDialog(null, term); } else if (evt.getItem() == terms[1] && evt.getStateChange() == ItemEvent.SELECTED) { termid = 2; // JOptionPane.showMessageDialog(null, term); } else if (evt.getItem() == terms[2] && evt.getStateChange() == ItemEvent.SELECTED) { termid = 3; // JOptionPane.showMessageDialog(null, term); } }
From source file:sms.Form1Exams.java
private void jComboBoxExamItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jComboBoxExamItemStateChanged if (evt.getItem() != "" && evt.getStateChange() == ItemEvent.SELECTED && evt.getItem() != "Choose Exam") { examid = getExamId(evt.getItem().toString()); // subjectNameToId(exam); } else {/*w ww. jav a2s.c o m*/ examid = 0; } }
From source file:com.intuit.tank.tools.debugger.AgentDebuggerFrame.java
/** * @throws HeadlessException// w ww . jav a 2 s. c o m */ public AgentDebuggerFrame(final boolean isStandalone, String serviceUrl) throws HeadlessException { super("Intuit Tank Agent Debugger"); workingDir = PanelBuilder.createWorkingDir(this, serviceUrl); setSize(new Dimension(1024, 800)); setBounds(new Rectangle(getSize())); setPreferredSize(getSize()); setDefaultCloseOperation(DISPOSE_ON_CLOSE); setLayout(new BorderLayout()); this.standalone = isStandalone; addWindowListener(new WindowAdapter() { public void windowClosed(WindowEvent e) { quit(); } }); errorIcon = ActionProducer.getIcon("bullet_error.png", IconSize.SMALL); modifiedIcon = ActionProducer.getIcon("bullet_code_change.png", IconSize.SMALL); skippedIcon = ActionProducer.getIcon("skip.png", IconSize.SMALL); this.glassPane = new InfiniteProgressPanel(); setGlassPane(glassPane); debuggerActions = new ActionProducer(this, serviceUrl); requestResponsePanel = new RequestResponsePanel(this); requestResponsePanel.init(); testPlanChooser = new JComboBox(); testPlanChooser.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent event) { if (event.getItem() != null) { HDTestPlan selected = (HDTestPlan) event.getItem(); if (!selected.equals(currentTestPlan)) { setCurrentTestPlan(selected); } } } }); tankClientChooser = new JComboBox<TankClientChoice>(); debuggerActions.setChoiceComboBoxOptions(tankClientChooser); actionComponents = new ActionComponents(standalone, testPlanChooser, tankClientChooser, debuggerActions); addScriptChangedListener(actionComponents); setJMenuBar(actionComponents.getMenuBar()); Component topPanel = PanelBuilder.createTopPanel(actionComponents); Component bottomPanel = PanelBuilder.createBottomPanel(this); Component contentPanel = PanelBuilder.createContentPanel(this); final JPopupMenu popup = actionComponents.getPopupMenu(); scriptEditorTA.setPopupMenu(null); scriptEditorTA.addMouseListener(new MouseAdapter() { int lastHash; @Override public void mousePressed(MouseEvent e) { maybeShow(e); } @Override public void mouseReleased(MouseEvent e) { maybeShow(e); } private void maybeShow(MouseEvent e) { if (lastHash == getHash(e)) { return; } if (e.isPopupTrigger()) { // select the line try { int offset = scriptEditorTA.viewToModel(e.getPoint()); Rectangle modelToView = scriptEditorTA.modelToView(offset); Point point = new Point(modelToView.x + 1, e.getPoint().y); if (modelToView.contains(point)) { if (!multiSelect) { int line = scriptEditorTA.getLineOfOffset(offset); scriptEditorTA.setCurrentLine(line); } popup.show(e.getComponent(), e.getX(), e.getY()); } } catch (BadLocationException e1) { e1.printStackTrace(); } } else if (e.isShiftDown()) { int line = scriptEditorTA.getCaretLineNumber(); int start = Math.min(line, lastLine); int end = Math.max(line, lastLine); multiSelect = end - start > 1; if (multiSelect) { multiSelectStart = start; multiSelectEnd = end; try { scriptEditorTA.setEnabled(true); scriptEditorTA.select(scriptEditorTA.getLineStartOffset(start), scriptEditorTA.getLineEndOffset(end)); scriptEditorTA.setEnabled(false); } catch (BadLocationException e1) { e1.printStackTrace(); multiSelect = false; } } } else { multiSelect = false; lastLine = scriptEditorTA.getCaretLineNumber(); } lastHash = getHash(e); } private int getHash(MouseEvent e) { return new HashCodeBuilder().append(e.getButton()).append(e.getSource().hashCode()) .append(e.getPoint()).toHashCode(); } }); JSplitPane mainSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT); mainSplit.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); mainSplit.setTopComponent(contentPanel); mainSplit.setBottomComponent(bottomPanel); mainSplit.setDividerLocation(600); mainSplit.setResizeWeight(0.8D); mainSplit.setDividerSize(5); add(topPanel, BorderLayout.NORTH); add(mainSplit, BorderLayout.CENTER); WindowUtil.centerOnScreen(this); pack(); KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager(); manager.addKeyEventDispatcher(new KeyEventDispatcher() { @Override public boolean dispatchKeyEvent(KeyEvent e) { if (e.getID() == KeyEvent.KEY_PRESSED) { handleKeyEvent(e); } return false; } }); }