Untitled

 avatar
unknown
plain_text
24 days ago
3.9 kB
8
Indexable
package gui;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JRadioButton;

public class RadioButtonTest extends JFrame implements ActionListener {

    JButton btn;
    JRadioButton rBtn1, rBtn2, rBtn3, rBtn4, rBtn5, rBtn6, rBtn7, rBtn8, rBtn9, rBtn10;

    public RadioButtonTest() {

        setTitle("BLERJE");
        setSize(300, 300);
        setLayout(null);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        JLabel label = new JLabel("Zgjidh: ");
        label.setBounds(20, 20, 250, 20);

        rBtn1 = new JRadioButton("EMRI");
        rBtn2 = new JRadioButton("MBIEMRI");
        rBtn3 = new JRadioButton("EMAIL");
        rBtn4 = new JRadioButton("PASSWORD");
        rBtn5 = new JRadioButton("EMRI PRODUKTIT");
        rBtn6 = new JRadioButton("SASIA PRODUKTIT");
        rBtn7 = new JRadioButton("CMIMI");
        rBtn8 = new JRadioButton("KARTA KREDITIT");
        rBtn9 = new JRadioButton("KODI I SIGURISE");
        rBtn10 = new JRadioButton("BLI");



        rBtn1.setBounds(40, 60, 200, 30);
        rBtn2.setBounds(40, 100, 200, 30);
        rBtn3.setBounds(40, 140, 200, 30);
        rBtn4.setBounds(40, 180, 200, 30);
        rBtn5.setBounds(40, 220, 200, 30);
        rBtn6.setBounds(40, 260, 200, 30);
        rBtn7.setBounds(40, 300, 200, 30);
        rBtn8.setBounds(40, 340, 200, 30);
        rBtn9.setBounds(40, 380, 200, 30);
        rBtn10.setBounds(40, 420, 200, 30);


        ButtonGroup bg = new ButtonGroup();
        bg.add(rBtn1);
        bg.add(rBtn2);
        bg.add(rBtn3);
        bg.add(rBtn4);
        bg.add(rBtn5);
        bg.add(rBtn6);
        bg.add(rBtn7);
        bg.add(rBtn8);
        bg.add(rBtn9);

        btn = new JButton("BLI");
        btn.setBounds(100, 200, 80, 30);
        btn.addActionListener(this);

        add(label);
        add(rBtn1);
        add(rBtn2);
        add(rBtn3);
        add(rBtn4);
        add(rBtn5);
        add(rBtn6);
        add(rBtn7);
        add(rBtn8);
        add(rBtn9);
        add(rBtn10);
        add(btn);

        setVisible(true);
    }

    
    public void actionPerformed(ActionEvent e) {

        if (rBtn1.isSelected() {
            JOptionPane.showMessageDialog(this,
                    "EMRI JOT ESHTE XX"));

        } else if (rBtn2.isSelected()) {
            JOptionPane.showMessageDialog(this,
                    "MBIEMRI JOT ESHTE XX");

         } else if (rBtn3.isSelected()) {
            JOptionPane.showMessageDialog(this,
                    "EMAILI JOT ESHTE XX");

         } else if (rBtn4.isSelected()) {
            JOptionPane.showMessageDialog(this,
                    "PASSWORDI JOT ESHTE XX");
            
         } else if (rBtn5.isSelected()) {
            JOptionPane.showMessageDialog(this,
                    "EMRI I PRODUKTIT ESHTE XX");

         } else if (rBtn6.isSelected()) {
            JOptionPane.showMessageDialog(this,
                    "SASIA E PRODUKTIT ESHTE XX");

         } else if (rBtn7.isSelected()) {
            JOptionPane.showMessageDialog(this,
                    "CMIMI ESHTE XX");

         } else if (rBtn8.isSelected()) {
            JOptionPane.showMessageDialog(this,
                    "KARTA E KREDITIT ESHTE XX");

         } else if (rBtn9.isSelected()) {
            JOptionPane.showMessageDialog(this,
                    "KODI I SIGURISE ESHTE XX");

         } else if (rBtn10.isSelected()) {
            JOptionPane.showMessageDialog(this,
                    "BLI");

    public static void main(String[] args) {
        new RadioButtonTest();
    }
}
Editor is loading...
Leave a Comment