Sabtu, 13 Juni 2020

Contoh program GUI menggunakan JavaScript

Berikut contoh program GUI menggunakan JavaScript

import javax.swing.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

class GUII extends JFrame{

JButton nama = new JButton("Nama");
JButton kelas = new JButton("Kelas");
JButton absen = new JButton("No Absen");
JButton sekolah = new JButton("Sekolah");
JButton alamat = new JButton("Alamat");
JLabel pilihan = new JLabel("Pilih Salah Satu Informasi Tentang Saya");


public GUII(){

super("Biodata Ahmad Rhandy");

this.setSize(400,200);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setLocationRelativeTo(null);
this.getContentPane().setLayout(null);
this.add(nama);
this.add(kelas);
this.add(absen);
this.add(sekolah);
this.add(alamat);
this.add(pilihan);

nama.setBounds(10,10,100,25);
kelas.setBounds(10,40,100,25);
absen.setBounds(10,70,100,25);
sekolah.setBounds(10,100,100,25);
alamat.setBounds(10,130,100,25);
pilihan.setBounds(130,10,250,25);

nama.addActionListener(new ActionListener( ) {
public void actionPerformed(ActionEvent e){

pilihan.setText("Ahmad Rhandy S");
}
}
);

kelas.addActionListener(new ActionListener( ) {
public void actionPerformed(ActionEvent e){
pilihan.setText("X-TKJ 2");
}
}
);

absen.addActionListener(new ActionListener( ) {
public void actionPerformed(ActionEvent e){
pilihan.setText("06");
}
}
);

sekolah.addActionListener(new ActionListener( ) {
public void actionPerformed(ActionEvent e){
pilihan.setText("SMK Negeri 3 Buduran");
}
}
);

alamat.addActionListener(new ActionListener( ) {
public void actionPerformed(ActionEvent e){
pilihan.setText("Graha Asri Sukodono Blok AO-27");
}
}
);

show();
}

public static void main(String[] args){
new GUII();
}
}

Tidak ada komentar:

Posting Komentar

Cara menggabungkan 2 foto menjadi 1 menggunakan Photoshop

Cara menggabungkan 2 foto menjadi 1 menggunakan Photoshop                 Kali ini saya akan membagikan tutorial menggabungkan 2 fot...