import javax.swing.*;
import java.awt.*;
public class Latihan3 extends JFrame{
//Deklarasi array
String[] arrAgm = {"Islam","Kristen","Khatolik","Hindu","Budha"
};
//Deklarasi objek / variabel
JTextField txtNIM = new JTextField("Untuk tempat nim");
JLabel lblnim = new JLabel("NIM :");
JLabel lblnama = new JLabel("Nama :");
JTextField txtNama = new JTextField("Untuk tempat nama");
JLabel lblJK = new JLabel("Jenis Kelamin :");
JRadioButton rbpria = new JRadioButton("Pria");
JRadioButton rbwanita = new JRadioButton("Wanita");
JLabel lblagama = new JLabel("Agama :");
JComboBox cmbAgama = new JComboBox(arrAgm);
JButton cmdOK = new JButton("Tombol");
JPanel pnlJK = new JPanel();
ButtonGroup bgJK = new ButtonGroup();
public Latihan3(){
super("Latihan");
setSize(600,400);
setResizable(false);
setLocationRelativeTo(null);
getContentPane().setBackground(Color.cyan);
//mengisi pnlJK dengan radiobutton
pnlJK.add(rbpria);
pnlJK.add(rbwanita);
bgJK.add(rbpria);
bgJK.add(rbwanita);
//menambahkan objek ke container JFrame
getContentPane().add(lblnim);
getContentPane().add(txtNIM);
getContentPane().add(cmdOK);
getContentPane().add(lblnama);
getContentPane().add(txtNama);
getContentPane().add(lblJK);
getContentPane().add(pnlJK);
getContentPane().add(lblagama);
getContentPane().add(cmbAgama);
getContentPane().add(cmdOK);
getContentPane().setLayout(new GridLayout(5,2));
setVisible(true);
}
public static void main(String[]haha){
new Latihan3();
}
}
import java.awt.*;
public class Latihan3 extends JFrame{
//Deklarasi array
String[] arrAgm = {"Islam","Kristen","Khatolik","Hindu","Budha"
};
//Deklarasi objek / variabel
JTextField txtNIM = new JTextField("Untuk tempat nim");
JLabel lblnim = new JLabel("NIM :");
JLabel lblnama = new JLabel("Nama :");
JTextField txtNama = new JTextField("Untuk tempat nama");
JLabel lblJK = new JLabel("Jenis Kelamin :");
JRadioButton rbpria = new JRadioButton("Pria");
JRadioButton rbwanita = new JRadioButton("Wanita");
JLabel lblagama = new JLabel("Agama :");
JComboBox cmbAgama = new JComboBox(arrAgm);
JButton cmdOK = new JButton("Tombol");
JPanel pnlJK = new JPanel();
ButtonGroup bgJK = new ButtonGroup();
public Latihan3(){
super("Latihan");
setSize(600,400);
setResizable(false);
setLocationRelativeTo(null);
getContentPane().setBackground(Color.cyan);
//mengisi pnlJK dengan radiobutton
pnlJK.add(rbpria);
pnlJK.add(rbwanita);
bgJK.add(rbpria);
bgJK.add(rbwanita);
//menambahkan objek ke container JFrame
getContentPane().add(lblnim);
getContentPane().add(txtNIM);
getContentPane().add(cmdOK);
getContentPane().add(lblnama);
getContentPane().add(txtNama);
getContentPane().add(lblJK);
getContentPane().add(pnlJK);
getContentPane().add(lblagama);
getContentPane().add(cmbAgama);
getContentPane().add(cmdOK);
getContentPane().setLayout(new GridLayout(5,2));
setVisible(true);
}
public static void main(String[]haha){
new Latihan3();
}
}
0 comments:
Post a Comment