Galerinha me ajuda criei dois botões que são JRadioButton chkDataDiaria e o JRadioButton chkDataMensal , o botão mensal é preciso que o usuário digite num campo JTextField txtAnoMes, o Ano e o Mes como vocês podem ver, e o botão chkDataDiaria irá abilitar um outro botão criado com o nome PESQUISA , a questão é a seguinte eu preciso fazer algum evento que quando o usuário clicar no botão chkDataDiaria o campo txtAnoMes fique desabilitado mais eu não sei como fazer isso.
ALGUÉM ME SOCORRE PLEASE!!!
olá… seguinte, use o ActionListener nos radios, e quando eles forem selecionados vc faz as abilitações e afins…
- ou - isso
static JTextField t = null;
public static void main(String[] args) {
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel panel = new JPanel();
frame.setContentPane(panel);
JRadioButton r = new JRadioButton();
r.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JRadioButton r = (JRadioButton) e.getSource();
t.setEditable(!r.isSelected());
t.setEnabled(!r.isSelected());
}
});
panel.add(r);
t = new JTextField();
t.setPreferredSize(new Dimension(120, 22));
panel.add(t);
frame.pack();
frame.show();
}