How to retrieve data from MYSQL to combobox in JUNG visualization

有些话、适合烂在心里 提交于 2019-12-12 03:19:50

问题


I am trying to create a JCombobox and retrieving data from the MYSQL database in JUNG visualization platform. I need to know whether i can use the same method to create a JCombo box in JUNG as we created in JAVA swing? I used the following code to create and import the data from the database. But nothing gets displayed. According to the item which is selected from Jcombo box, I've to edit the jung network. Can anyone help me this?

private void mouseComboBoxActionPerformed(java.awt.event.ActionEvent evt) { 
        JComboBox jcb1 = (JComboBox) evt.getSource();
        try {
            String query = "SELECT * FROM interr";
            PreparedStatement pest = connection.prepareStatement(query);
            ResultSet rs = pest.executeQuery();

            while (rs.next()) {
            String geneID = rs.getString("Mole1");

            if (geneID.equals("")) {
                jcb1.addItem("");
                jcb1.setVisible(false);
            } else {
                jcb1.addItem(rs.getString("Mole1"));
                jcb1.setVisible(true);
            }

        }
    }

    catch (Exception e) {
        e.printStackTrace();
    }
        String selectedItem = (String)jcb1.getSelectedItem();
    if(selectedItem.equals("BRCA1")){
       -----
    } else {
        ----
    }
    vv.repaint();
}

来源:https://stackoverflow.com/questions/34194900/how-to-retrieve-data-from-mysql-to-combobox-in-jung-visualization

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!