public void focusLost(FocusEvent e) {
      Object objFocus = e.getSource();
      boolean bSaveCmd = false;
      if (objFocus instanceof DataField) {
        DataField compFocus = (DataField) objFocus;
        Component comp = e.getOppositeComponent();
        if (comp instanceof JButton) {
          String strTxt = ((JButton) comp).getText();
          if (strTxt != null && strTxt.equals(WGlobal.SAVEUSER)) bSaveCmd = true;
        }

        // if the focus is not in the panel then write the file.
        /*if ((comp == null || !m_pnlDisplay.equals(comp.getParent()))
                && !bSaveCmd)
        {
            String strPrevValue = compFocus.getValue();
            String strTxt = compFocus.getText();
            if (!strPrevValue.equals(strTxt))
            {
                // save the data by writing it to the file
                AppIF appIf = Util.getAppIF();
                if (appIf instanceof VAdminIF)
                    ((VAdminIF)appIf).getUserToolBar().doSave();
                compFocus.setValue(strTxt);
            }
        }*/
      }
    }
Beispiel #2
0
 @Override
 public void focusGained(FocusEvent e) {
   // TODO Auto-generated method stub
   Object obj = e.getSource();
   if (obj.equals(jtf)) {
     jtf.setText("");
   } else if (obj.equals(hi)) {
     hi.setText("");
   } else if (obj.equals(pi)) {
     pi.setText("");
   } else if (obj.equals(localport)) {
     localport.setText("");
   } else if (obj.equals(lpw)) {
     lpw.setText("");
   } else if (obj.equals(lid)) {
     lid.setText("");
   }
 }
  public void focusLost(FocusEvent e) {
    int id = 0;
    boolean res = false;
    JTextField t = (JTextField) e.getSource();
    if (t == tpid) {
      try {
        id = Integer.parseInt(tpid.getText());
        res = patient.psearch(id);
      } catch (Exception e1) {
      }

      if (res) {
        int no, ag = 0, fee = 0;
        String pfn = "",
            bg = "",
            pmn = "",
            dt1 = "",
            pln = "",
            add = "",
            sym = "",
            dn = "",
            dig = "",
            cn = "",
            gender = "",
            wgt = "";
        try {
          dt1 = patient.rs.getString(1);
          no = patient.rs.getInt(2);
          pfn = patient.rs.getString(3);
          pmn = patient.rs.getString(4);
          pln = patient.rs.getString(5);
          gender = patient.rs.getString(6);
          ag = patient.rs.getInt(7);
          wgt = patient.rs.getString(8);
          add = patient.rs.getString(9);
          cn = patient.rs.getString(10);
          dn = patient.rs.getString(11);
          sym = patient.rs.getString(12);
          dig = patient.rs.getString(13);
          fee = patient.rs.getInt(14);
          bg = patient.rs.getString(15);
          dir = patient.rs.getString(17);

          s = dir;
          repaint();
          j13 = new JLabel("OLD IMAGE");
          j13.setBounds(840, 5, 300, 300);
          JLabel j12 =
              new JLabel("OLD PHOTO") {
                public void paint(Graphics g) {
                  ImageIcon ic = new ImageIcon(s);
                  Image img = ic.getImage();
                  g.drawImage(img, 0, 0, 150, 150, this);
                }
              };

          //	q.flushAll()

          /*ImageIcon ic=new ImageIcon(dir);
          JLabel j12=new JLabel("",ic,JLabel.CENTER);*/
          j12.setBounds(670, 70, 300, 300);
          //	image.setBounds(700,300,100,100);

          q.add(j12);
          q.add(j13);
          repaint();
          System.out.println("8743t32874" + dir);
        } catch (Exception e2) {
        }
        if (gender.equals("Male")) cm.setState(true);
        else cf.setState(true);
        tdt.setText(dt1);
        tpfnm.setText(pfn);
        tpmnm.setText(pmn);
        tplnm.setText(pln);
        tage.setText("" + ag);
        tfee.setText("" + fee);
        tadd.setText(add);
        tdig.setText(dig);
        tdnm.setText(dn);
        tsym.setText(sym);
        tcno.setText(cn);
        twt.setText(wgt);
        tbg.setText(bg);

        // cm.setState(set1State());
        // cf.setSelectedCheckbox(gender);
        ba.setEnabled(false);
        bm.setEnabled(true);
        bd.setEnabled(true);
      } else {
        if (id == 0) {
          bl.setEnabled(true);
          ba.setEnabled(false);
        } else ba.setEnabled(true);
        bm.setEnabled(false);
        bd.setEnabled(false);
      }
    }
  }