//metodo q cria e adiciona botoes e seu número em um painel q correspondem as unidades (quartos) de um hotel,
//dúvida está no metodo actionPerformed !!!
//qual o metodo q me retorna o texto do botão selecionado
public void mostraChartPDV() throws SQLException {
jPmovGeral.setLayout(new GridLayout (7,7));
Icon iconDisponivel = new ImageIcon("/Documents and Settings/User/Desktop/desktop/icones/portaaberta2.jpg");
Icon iconOcupado = new ImageIcon("/Documents and Settings/User/Desktop/desktop/icones/ocupada.gif");
ResultSet rs = null;
this.con = pacote_util.Conexao.getConexao();
try{
PreparedStatement pstm = this.con.prepareStatement(“SELECT NumeroUnidade FROM unidade”);
rs = pstm.executeQuery();
String numero = “”;
while(rs.next()){
numero = rs.getString(“NumeroUnidade”);
NumeroUnidades[i] = numero;
botoes[i] = new JButton(NumeroUnidades[i]);
botoes[i].setBackground(White);
botoes[i].addActionListener(new ActionListener () {
public void actionPerformed (ActionEvent e)
{
//String numUnid = texto do botão selecionado pelo usuario
//jTunidade.setText(numUnid);
//visMovUnid(numUnid);
//visCliente(numUnid);
}
});
jPmovGeral.add(botoes[i]);
i++;
}
}catch(Exception e){
e.printStackTrace();
}
}
private void visMovUnid(String value) {
JTextField [] tf = camposMovUnid();
ResultSet res;
try {
PreparedStatement pstm = this.con.prepareStatement("SELECT CodCI, TARIFA_UNIDADE_NomeTarifa, DataCI, DataPrevSaidaCI FROM check_in WHERE UNIDADE_NumeroUnidade ="+ value);
res=pstm.executeQuery();
res.next(); {
//pega os result e os coloca em cada um dos campos
for (int i=0; i<tf.length; i++)
tf[i].setText(res.getString(i+1));
}
}
catch(SQLException ex) {
ex.printStackTrace();
}
}
private JTextField[] camposMovUnid() {
JTextField [] tf = {jTcodCI, jTtarifa, jTentrada, jTsaida};
return tf;
}