Untitled
unknown
plain_text
20 days ago
2.1 kB
5
Indexable
import javax.swing.JTextField;
public class RegjistrimGUI extends JFrame {
JTextField txtEmri, txtMbiemri;
JRadioButton mashkull,femer;
JCheckBox java, python, cpp;
JButton regjistro;
public RegjistrimGUI() {
setTitle("Form Regjistrimi");
setSize(400, 350);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLocationRelativeTo(null);
setLayout(new GridLayout(8, 1));
JPanel p1 = new JPanel();
p1.add(new JLabel("Emri:"));
txtEmri = new JTextField(20);
p1.add(txtEmri);
add(p1);
JPanel p2 = new JPanel();
p2.add(new JLabel("Mbiemri:"));
txtMbiemri = new JTextField(20);
p2.add(txtMbiemri);
add(p2);
JPanel p3 = new JPanel();
p3.add(new JLabel("Gjinia:"));
mashkull = new JRadioButton("M");
femer = new JRadioButton("F");
ButtonGroup grupi = new ButtonGroup();
grupi.add(mashkull);
grupi.add(femer);
p3.add(mashkull);
p3.add(femer);
add(p3);
JPanel p4 = new JPanel();
p4.add(new JLabel("Gjuha e Programimit:"));
java = new JCheckBox("Java");
python = new JCheckBox("Python");
cpp = new JCheckBox("C++");
p4.add(java);
p4.add(python);
p4.add(cpp);
add(p4);
JPanel p5 = new JPanel();
regjistro = new JButton("Regjistrohu");
p5.add(regjistro);
add(p5);
regjistro.addActionListener( new ActionListener() {
public void actionPerformed(ActionEvent e) {
String emri = txtEmri.getText();
String mbiemri = txtMbiemri.getText();
if(emri.isEmpty() || mbiemri.isEmpty()) {
JOptionPane.showMessageDialog(null,"Plotesoni emrin dhe mbiemrin!");
return;
}
if(!mashkull.isSelected() && !femer.isSelected()) {
JOptionPane.showMessageDialog(null,
"Zgjidhni gjinine!");
return;
}
if(!java.isSelected() &&
!python.isSelected() &&
!cpp.isSelected()) {
JOptionPane.showMessageDialog(null,
"Zgjidhni nje gjuhe programimi!");
return;
}
JOptionPane.showMessageDialog(null,
"Regjistrimi u krye me sukses!");
}
});
}
public static void main(String[] args) {
RegjistrimGUI form = new RegjistrimGUI();
form.setVisible(true);
}
Editor is loading...
Leave a Comment