0

In this piece of code i just simple display the host name and ipaddress from database. Now i want to add check boxes there for any kind of selection that first there comes a check box then there is a hostname and ipadress in front of that checkbox how can i do that kindly help me

 private void HomeActionPerformed(java.awt.event.ActionEvent evt) {                                     
        jTextArea1.setText("Clients ID\t\t\tClients Name\t\t\tClients IPAddress\n");
        int i=0;
        sh1 = new JCheckBox();
        Connection conn=MySqlConnect.ConnectDB();
        String Sql="Select * from clients";
        try
        {
            PreparedStatement pst=conn.prepareStatement(Sql);
            ResultSet rs=pst.executeQuery();
            while(rs.next())
            {
                String str=rs.getString("hostname");
                String str1=rs.getString("ipaddress");
                i=i+1;
                jTextArea1.append(i+"\t\t\t"+str+"\t\t\t"+str1+"\n");
            }
        }
        catch(Exception e)
        {
            JOptionPane.showMessageDialog(null,e);
        }  
        }
zeeshan nisar
  • 553
  • 2
  • 4
  • 18

1 Answers1

1

Maybe you should try loading the values into the JTable. You can add checkboxes into the cells opposite of values. Or maybe you may use textfields with the checkboxes nearby, but it's harder. I am not sure that it is possible to contain checkboxes in the JTextArea