如何使用JPA中的数据填充JCombobox

时间:2012-11-21 20:41:50

标签: jpa jcombobox

如何使用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); }

1 个答案:

答案 0 :(得分:0)

你可以使用jcombox方法

comboBox.addItems();