My program can dynamically create JButtons, Text is added to it and the value they will return to me when I click:
String name = nameField.getText();
String identification = idField.getText();
Person person = new Person(name, identification);
insertarVendedores(name, identification);
JButton personButton = new JButton(new PersonAction(person));
pnlVen.add(personButton);
pnlVen.revalidate();
pnlVen.repaint();
nameField.setText("");
idField.setText("");
CargarTablaVendedores("");
Afterwards, it loads them from a SQLite database:
try{
Connection miConexion = DriverManager.getConnection("jdbc:sqlite:vendedores2Claro.db");
Statement miStatement = miConexion.createStatement();
ResultSet miResultSet = miStatement.executeQuery("SELECT id, name, identification FROM vendedores2Claro");
while(miResultSet.next()){
pnlVen.add(new JButton(new PersonAction(new Person(miResultSet.getString("name"), miResultSet.getString("identification")))));
pnlVen.revalidate();
pnlVen.repaint();
}
}catch(Exception e){
System.out.println(e);
}
But the buttons become indistinguishable because they are all of a color, and I need help to be told how I can do so that at the time of filling out the form for the user to create the JButton select from a box combo the color of that new JButton and that when loaded it also loads with that color. A thousand apologies if I give too many turns in my question, And I thank you for your attention.