How do I get the item selected by the user in this Combobox?
opcaoBusca.setModel(new DefaultComboBoxModel(new String[] {"Op\u00E7\u00E3o da Busca", "N\u00FAmero do Pedido"}));
entBusca = new JFormattedTextField();
entBusca.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent arg0) {
entBusca.setText("");
}
});
entBusca.setEnabled(false);
ListaBox = new JComboBox<String>();
ListaBox.addItem("Selecione");
try {
Class.forName("oracle.jdbc.OracleDriver");
Connection con = DriverManager.getConnection(
"jdbc:oracle:thin:@192.168.1.1:1521:banco1","root","root");
Statement stmt = con.createStatement();
ResultSet RS = null;
RS = stmt.executeQuery("select codplpag from pcplpag ");
while(RS.next()){
ListaBox.addItem(RS.getString("codplpag"));
//String codplpag = RS.getString("codplpag");
//System.out.println("saida de dados" +codplpag);
}
stmt.close();
con.close();
}
catch(SQLException e)
{
JOptionPane.showMessageDialog(this,"Erro Cmdo SQL "+e.getMessage());
}
catch(ClassNotFoundException e){
JOptionPane.showMessageDialog(this,"Driver não encontrado");
}