如何使用jpa列表中的数据填充Jcombobox?需要绝望的帮助
public static MyNames myNames() {
EntityManagerFactory emf = Persistence.createEntityManagerFactory("JavaTrialsPU");
EntityManager em = emf.createEntityManager();
em.getTransaction().begin();
Query q = em.createNamedQuery("MyNames.findAll");
MyNames n = (MyNames) q.getResultList();
return n;
}
public static void myCombo() {
comboBox = new JComboBox(????--how can i make the jcombobox display my myNames() list--?????);
frame.add(comboBox, BorderLayout.PAGE_START);
}
public static void myCombo() {
comboBox = new JComboBox(????--how can i make the jcombobox display my myNames() list--?????);
frame.add(comboBox, BorderLayout.PAGE_START);
}
答案 0 :(得分:0)
你可以使用jcombox方法
comboBox.addItems();