如何使用来自JPA的数据填充JCombobox

如何使用来自JPA的数据填充JCombobox,jpa,jcombobox,Jpa,Jcombobox,如何使用jpa列表中的数据填充Jcombobox?急需帮助 公共静态MyNames MyNames(){ EntityManagerFactory emf=Persistence.createEntityManagerFactory(“JavaTrialsPU”); EntityManager em=emf.createEntityManager(); em.getTransaction().begin(); Query q=em.createNamedQuery(“MyNames.findA

如何使用jpa列表中的数据填充Jcombobox?急需帮助


公共静态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(); 返回n; }


您可以使用jcombox方法

comboBox.addItems();

你试过什么?尝试用对象填充JComboBox。然后尝试使用JPA从数据库加载对象。然后将两者结合起来。您可以创建组合框模型,请尝试以下链接
comboBox.addItems();