Пример #1
0
  public EmpMain() {
    String[] col = {"사번", "이름", "직위", "입사일", "부서번호"};
    String[][] row = new String[0][5];
    model =
        new DefaultTableModel(row, col) {
          public boolean isCellEditable(int r, int c) {
            return false;
          }
        };
    table = new JTable(model);
    JScrollPane js = new JScrollPane(table);
    la = new JLabel("사원목록");
    la.setFont(new Font("나눔스퀘어", Font.BOLD, 30));
    table.setFont(new Font("나눔스퀘어", Font.PLAIN, 12));
    JPanel p = new JPanel();
    p.add(la);

    la1 = new JLabel("Search");
    tf = new JTextField(10);
    box = new JComboBox();
    box.addItem("이름");
    box.addItem("입사일");
    box.addItem("부서");
    b1 = new JButton("찾기");
    b2 = new JButton("목록");
    JPanel p1 = new JPanel();
    p1.add(la1);
    p1.add(box);
    p1.add(tf);
    p1.add(b1);
    p1.add(b2);
    add("South", p1);
    add("Center", js);
    add("North", p);
    setSize(640, 480);
    setVisible(true);
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    getData();
    table.addMouseListener(this);
    b1.addActionListener(this);
    b2.addActionListener(this);
  }
Пример #2
0
 @Override
 public void mouseClicked(MouseEvent e) {
   // TODO Auto-generated method stub
   if (e.getSource() == table) {
     if (e.getClickCount() == 2) {
       int row = table.getSelectedRow();
       String sabun = model.getValueAt(row, 0).toString();
       EmpDAO dao = new EmpDAO();
       EmpDTO d = dao.empDetailData(Integer.parseInt(sabun));
       String msg =
           "사번:"
               + d.getEmpno()
               + "\n"
               + "이름:"
               + d.getEname()
               + "\n"
               + "직위:"
               + d.getJob()
               + "\n"
               + "사수번호:"
               + d.getMgr()
               + "\n"
               + "입사일:"
               + d.getHiredate().toString()
               + "\n"
               + "급여:"
               + d.getSal()
               + "\n"
               + "성과급:"
               + d.getComm()
               + "\n"
               + "부서번호:"
               + d.getDeptno();
       JOptionPane.showMessageDialog(this, msg);
     }
   }
 }