Witam, jest taki kodzik:
super("Test JTextField");
setSize(500,100);
setVisible(true);
setResizable(false);
addWindowListener(this);
FlowLayout experimentLayout = new FlowLayout();
Container kontener = getContentPane();
kontener.setBackground(new java.awt.Color (170, 250, 0));
kontener.setLayout(experimentLayout);
jl1 = new JLabel("Podaj liczbę:");
//jl1.setBounds(180,50,260,20);
kontener.add(jl1);
pole = new JTextField();
//pole.setBounds(260,50,50,20);
pole.setToolTipText("Podaj liczbę");
pole.setColumns(10);
kontener.add(pole);
ButtonGroup cbg = new ButtonGroup();
JRadioButton a = new JRadioButton("Rzym->Arab", true);
//a.addActionListener(this);
JRadioButton b = new JRadioButton("Arab->Rzym", false);
//b.addActionListener(this);
cbg.add(a);
cbg.add(b);
kontener.add(a);
kontener.add(b);
jb1 = new JButton("Przelicz");
//jb1.setBounds(320,50,100,20);
jb1.addActionListener(this);
jb1.setToolTipText("Kliknij aby dokonac konwersji temperatury");
kontener.add(jb1);
repaint();
I mój problem polega na tym jak po dostać się do tego, ktory z JRadioButton był zaznaczony. Tzn. po kliknięciu "przelicz" chciałbym wiedizeć, który jest zaznaczony. Jak to odebrać?