我想打印我在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();
}
答案 0 :(得分:1)
combocourse.getSelectedItem();