public void itemStateChanged(ItemEvent ie) { if (ie.getSource() == c1) { String s = c1.getLabel(); g = s; } else { String s = c2.getLabel(); g = s; } }
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); } } }
public patientAdd(String s) { super(s); image = new JLabel() { public void paint(Graphics g) { ImageIcon ic = new ImageIcon(str); Image img = ic.getImage(); g.drawImage(img, 0, 0, 150, 150, this); } }; image.setBounds(670, 270, 300, 300); bu = new JButton("UPLOAD"); bu.setBounds(700, 230, 100, 20); bu.addActionListener(this); // q.add(bu); ldt = new JLabel("Date"); lpid = new JLabel("Patient ID"); lpnm = new JLabel("Patient Name"); lgen = new JLabel("Gender"); lbg = new JLabel("Blood Group"); lage = new JLabel("Age"); lwt = new JLabel("Weight Kg"); ladd = new JLabel("Address"); lcno = new JLabel("Cont. no."); ldnm = new JLabel("Doctor Name Dr."); lsym = new JLabel("Symptoms"); ldig = new JLabel("Diagnosis"); lfee = new JLabel("Fee Rs."); cbg = new CheckboxGroup(); cm = new Checkbox("Male", cbg, false); cm.addItemListener(this); cf = new Checkbox("Female", cbg, false); cf.setState(true); cf.addItemListener(this); tdt = new JTextField(15); tpid = new JTextField(6); tpid.addFocusListener(this); tpfnm = new JTextField("first"); tpmnm = new JTextField("middle"); tplnm = new JTextField("last"); tage = new JTextField(4); tage.addFocusListener(this); tbg = new JTextField(6); twt = new JTextField(5); tadd = new TextArea(patient.addr); tcno = new JTextField(20); tdnm = new JTextField(20); tsym = new TextArea(); tdig = new JTextField(20); tfee = new JTextField(6); tfee.addFocusListener(this); ba = new JButton("ADD"); ba.addActionListener(this); bm = new JButton("CANCEL"); bm.addActionListener(this); bd = new JButton("DELETE"); bd.addActionListener(this); bl = new JButton("DISPLAY"); bl.addActionListener(this); bs = new JButton("SEARCH"); bs.addActionListener(this); JPanel p = new JPanel(); p.add(ba); p.add(bm); // p.add(bd); // p.add(bl); // p.add(bs); add(p, BorderLayout.SOUTH); q = new JPanel(); q.setLayout(null); ldt.setBounds(1015, 20, 60, 20); q.add(ldt); tdt.setBounds(1060, 20, 170, 20); q.add(tdt); lpid.setBounds(70, 60, 80, 20); q.add(lpid); tpid.setBounds(200, 60, 60, 20); q.add(tpid); lpnm.setBounds(70, 100, 80, 20); q.add(lpnm); tpfnm.setBounds(200, 100, 100, 20); q.add(tpfnm); tpmnm.setBounds(320, 100, 100, 20); q.add(tpmnm); tplnm.setBounds(440, 100, 100, 20); q.add(tplnm); lgen.setBounds(70, 140, 60, 20); q.add(lgen); lbg.setBounds(370, 140, 80, 20); q.add(lbg); tbg.setBounds(470, 140, 60, 20); q.add(tbg); cm.setBounds(200, 140, 60, 20); cf.setBounds(280, 140, 60, 20); lage.setBounds(70, 180, 40, 20); q.add(lage); tage.setBounds(200, 180, 50, 20); q.add(tage); lwt.setBounds(370, 180, 200, 20); q.add(lwt); twt.setBounds(470, 180, 60, 20); q.add(twt); ladd.setBounds(70, 220, 60, 20); q.add(ladd); tadd.setBounds(200, 220, 350, 50); q.add(tadd); lcno.setBounds(70, 310, 60, 20); q.add(lcno); tcno.setBounds(200, 310, 120, 20); q.add(tcno); ldnm.setBounds(70, 350, 200, 20); q.add(ldnm); tdnm.setBounds(200, 350, 150, 20); q.add(tdnm); lsym.setBounds(70, 390, 100, 20); q.add(lsym); tsym.setBounds(200, 390, 300, 70); q.add(tsym); ldig.setBounds(70, 480, 60, 20); q.add(ldig); tdig.setBounds(200, 480, 100, 20); q.add(tdig); lfee.setBounds(70, 520, 200, 20); q.add(lfee); tfee.setBounds(200, 520, 40, 20); q.add(tfee); q.add(cm); q.add(cf); q.add(image); q.add(bu); add(q, BorderLayout.CENTER); addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { try { patient.con.close(); System.exit(0); } catch (Exception e8) { } } }); System.out.println(tadd.getText()); setSize(1330, 740); setVisible(true); }
void launch() { f.setSize(800, 800); p.setLayout(null); l1.setBounds(600, 10, 150, 36); l2.setBounds(100, 30, 400, 70); l13.setBounds(2, 90, 1200, 20); l14.setBounds(80, 150, 250, 30); t1.setBounds(330, 150, 150, 30); b1.setBounds(500, 150, 100, 30); l15.setBounds(2, 200, 1200, 20); b6.setBounds(600, 50, 100, 30); l3.setBounds(100, 250, 100, 30); t2.setBounds(300, 250, 150, 30); l4.setBounds(100, 300, 150, 30); t3.setBounds(300, 300, 150, 30); l5.setBounds(100, 350, 150, 30); t4.setBounds(300, 350, 150, 30); l6.setBounds(100, 400, 100, 30); t5.setBounds(300, 400, 150, 30); l7.setBounds(100, 450, 100, 30); c1.setBounds(300, 450, 60, 30); c2.setBounds(400, 450, 60, 30); l8.setBounds(100, 500, 100, 30); t6.setBounds(300, 500, 150, 30); l9.setBounds(100, 550, 100, 30); t7.setBounds(300, 550, 150, 30); l10.setBounds(100, 600, 120, 30); t8.setBounds(300, 600, 150, 30); l11.setBounds(100, 650, 100, 30); t9.setBounds(300, 650, 150, 30); l12.setBounds(100, 700, 150, 30); t10.setBounds(300, 700, 150, 30); b2.setBounds(500, 400, 100, 30); b3.setBounds(500, 500, 100, 30); b4.setBounds(500, 600, 100, 30); b5.setBounds(650, 150, 100, 30); b1.addActionListener(this); b2.addActionListener(this); b3.addActionListener(this); b4.addActionListener(this); b5.addActionListener(this); b6.addActionListener(this); c1.addItemListener(this); c2.addItemListener(this); p.add(l1); p.add(l2); p.add(l13); p.add(l14); p.add(t1); p.add(b1); p.add(l15); p.add(b5); p.add(b6); f.add(p); f.setVisible(true); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }