如何获得打印选择的组合项目?

时间:2014-05-12 11:51:09

标签: java combobox selecteditem

我想打印我在combobox中选择的值。我的代码打印到所有组合框项目。我该怎么做?

      public void coursename(){
     Session session = HibernateUtil.getSessionFactory().getCurrentSession();
     session.beginTransaction();
     Query query= session.createQuery("select a.courseName  from Semester e inner join e.course as a"); 
   for (Iterator it = query.iterate(); it.hasNext();) {
       Object  row = (Object) it.next();
      combocourse.addItem(row);
     System.out.println(row);

     }        
       session.close();
   }

1 个答案:

答案 0 :(得分:1)

combocourse.getSelectedItem();