Untitled
unknown
plain_text
2 months ago
1.3 kB
7
Indexable
package leksion1;
import javax.swing.ButtonGroup;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JRadioButton;
public class RadioButtonTest extends JFrame implements ActionListener {
JFrame frame;
JButton btn;
JRadioButton rBtn1, rBtn2, rBtn3;
RadioButtonTest()
{
frame = new JFrame();
JLabel label = new JLabel("1-Selekto " + "pergjigjen e sakte:", JLabel.CENTER);
label.setBounds(20,0,200,80);
rBtn1 = new JRadioButton("A) Python");
rBtn2 = new JRadioButton("B) C++");
rBtn3 = new JRadioButton("C) Java");
rBtn1.setBounds(40,60,200,50);
rBtn2.setBounds(40,100,200,50);
rBtn3.setBounds(40,140,200,50);
ButtonGroup bg = new ButtonGroup();
bg.add(rBtn1);
bg.add(rBtn2);
bg.add(rBtn3);
btn = new JButton("Check");
btn.setBounds(100,200,80,30);
btn.addActionListener(this);
frame.add(label);
frame.add(rBtn1);
frame.add(rBtn2);
frame.add(rBtn3);
frame.add(btn);
frame.setSize(300,300);
frame.setLayout(null);
frame.setVisible(true);
}
public void actionPerformed(ActionEvent e) {
if(rBtn1.isSelected() || rBtn2.isSelected()) {
JOptionPane.showMessageDialog(this, "Pergjigje e gabuar");
}
}
public static void main(String[] args)
}
Editor is loading...
Leave a Comment