public void itemStateChanged(ItemEvent e) { Checkbox currentCheckbox = shapeActions.getSelectedCheckbox(); boolean CheckboxState = currentCheckbox.getState(); String currentAction = currentCheckbox.getLabel(); if (CheckboxState) { myAction = currentAction; } else { myAction = "DRAW"; } applet.repaint(); }
/** Returns the selected item in the next radio button group. */ public String getNextRadioButton() { if (radioButtonGroups == null) return null; CheckboxGroup cg = (CheckboxGroup) (radioButtonGroups.elementAt(radioButtonIndex)); radioButtonIndex++; Checkbox checkbox = cg.getSelectedCheckbox(); String item = "null"; if (checkbox != null) item = checkbox.getLabel(); if (macro) { String label = (String) labels.get((Object) cg); item = Macro.getValue(macroOptions, label, item); } if (recorderOn) recordOption(cg, item); return item; }
/** Récupère les preférences manquants et ferme la fenêtre */ public void fermer() { // noms des joueurs String nom = txt_joueur0.getText(); if (nom.compareTo("") == 0) noms[0] = "J1"; else noms[0] = nom; nom = txt_joueur1.getText(); if (nom.compareTo("") == 0) noms[1] = "J2"; else noms[1] = nom; // nombre de vies nb_vies = new Integer(cbg_vies.getSelectedCheckbox().getLabel()).intValue(); aleatoire = cb_aleatoire.getState(); setVisible(false); } // fermer()
/*------------------------------------------------------------------*/ public void itemStateChanged(ItemEvent ie) { if (choice.getSelectedCheckbox().getLabel().equals("Gradient Magnitude")) { operation = Differentials_.GRADIENT_MAGNITUDE; } else if (choice.getSelectedCheckbox().getLabel().equals("Gradient Direction")) { operation = Differentials_.GRADIENT_DIRECTION; } else if (choice.getSelectedCheckbox().getLabel().equals("Laplacian")) { operation = Differentials_.LAPLACIAN; } else if (choice.getSelectedCheckbox().getLabel().equals("Largest Hessian")) { operation = Differentials_.LARGEST_HESSIAN; } else if (choice.getSelectedCheckbox().getLabel().equals("Smallest Hessian")) { operation = Differentials_.SMALLEST_HESSIAN; } else if (choice.getSelectedCheckbox().getLabel().equals("Hessian Orientation")) { operation = Differentials_.HESSIAN_ORIENTATION; } else { cancel = true; operation = Differentials_.LAPLACIAN; IJ.error("Unexpected checkbox ID"); this.setVisible(false); } repaint(); } /* end itemStateChanged */
public void read() { try { // patient.dt=""+tdt.getText(); patient.pid = Integer.parseInt(tpid.getText()); patient.pfnm = tpfnm.getText(); patient.pmnm = tpmnm.getText(); patient.plnm = tplnm.getText(); patient.gen = cbg.getSelectedCheckbox().getLabel(); try { patient.age = Integer.parseInt(tage.getText()); tage.setText("" + patient.age); } catch (Exception e) { JOptionPane.showMessageDialog(null, "Invalid age inputed."); patient.age = Integer.parseInt(JOptionPane.showInputDialog("Please enter valid age:")); tage.setText("" + patient.age); } try { int wet = Integer.parseInt(twt.getText()); twt.setText("" + wet); } catch (Exception e) { JOptionPane.showMessageDialog(null, "Invalid weight inputed."); int wet = Integer.parseInt(JOptionPane.showInputDialog("Please enter valid weight:")); twt.setText("" + wet); } patient.wt = twt.getText(); patient.addr = tadd.getText(); this.ad = tadd.getText(); System.out.println(tadd.getText()); while (true) { patient.cno = tcno.getText(); if (patient.cno.length() == 10) break; else { JOptionPane.showMessageDialog(null, "Invalid Phone No."); patient.cno = JOptionPane.showInputDialog("Please enter valid 10-digit Phone No.:"); tcno.setText(patient.cno); } } patient.dnm = tdnm.getText(); patient.sym = tsym.getText(); System.out.println(tsym.getText()); patient.dig = tdig.getText(); try { patient.fee = Integer.parseInt(tfee.getText()); tfee.setText("" + patient.fee); } catch (Exception e) { JOptionPane.showMessageDialog(null, "Invalid Fee inputed."); patient.fee = Integer.parseInt(JOptionPane.showInputDialog("Please enter valid Fee:")); tfee.setText("" + patient.fee); } patient.bg = tbg.getText(); patient.path = str; } catch (Exception e) { } }
public void itemStateChanged(ItemEvent e) { msg = "currnet selection "; msg += cbg.getSelectedCheckbox().getLabel(); l.setText(msg); }
public void itemStateChanged(ItemEvent e) { // choice=MALE if (cbg.getSelectedCheckbox().getLabel().equals("Male")) { if (gross < 160000) tp.setText("0"); else if (gross < 300000) { gross -= 160000; gross *= 0.1; gross += gross * 0.03; tp.setText(Double.toString(gross)); } else if (gross < 500000) { gross -= 300000; gross *= 0.2; gross += 14000; gross += gross * 0.03; tp.setText(Double.toString(gross)); } else { gross -= 500000; gross *= 0.3; gross += 54000; gross += gross * 0.03; tp.setText(Double.toString(gross)); } } // choice=FEMALE else if (cbg.getSelectedCheckbox().getLabel().equals("Female")) { if (gross < 190000) tp.setText("0"); else if (gross < 300000) { gross -= 190000; gross *= 0.1; gross += gross * 0.03; tp.setText(Double.toString(gross)); } else if (gross < 500000) { gross -= 300000; gross *= 0.2; gross += 11000; gross += gross * 0.03; tp.setText(Double.toString(gross)); } else { gross -= 500000; gross *= 0.3; gross += 51000; gross += gross * 0.03; tp.setText(Double.toString(gross)); } } // Choice=Senior citizen else { if (gross < 240000) tp.setText("0"); else if (gross < 300000) { gross -= 240000; gross *= 0.2; gross += gross * 0.03; tp.setText(Double.toString(gross)); } else if (gross < 500000) { gross -= 300000; gross *= 0.2; gross += 6000; gross += gross * 0.03; tp.setText(Double.toString(gross)); } else { gross -= 500000; gross *= 0.3; gross += 46000; gross += gross * 0.03; tp.setText(Double.toString(gross)); } } }