Selasa, 12 April 2011

Membuat Form dengan bahasa JAVA


Berikut adalah code Membuat form dalam bahasa JAVA
//nama file : form.java
import javax.swing.*;
import java.awt.event.*;
public class Form
{
public static void main(String[] args)
{
JFrame form1 = new JFrame("Form PertamaKu");
JDesktopPane desk1 = new JDesktopPane();
JLabel lblnpm = new JLabel ("NPM");
JLabel lblnama = new JLabel ("NAMA");
JLabel lblkelas = new JLabel ("KELAS");
JTextField txtnpm = new JTextField ();
JTextField txtnama = new JTextField ();
JTextField txtkelas = new JTextField ();
JButton btnok = new JButton ("OK");
form1.setSize(800,600);
form1.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
lblnpm.setBounds(10,10,100,25);
txtnpm.setBounds(150,10,560,25);
desk1.add(lblnpm);
desk1.add(txtnpm);
form1.add(desk1);
lblnama.setBounds(10,45,100,25);
txtnama.setBounds(150,45,560,25);
desk1.add(lblnama);
desk1.add(txtnama);
form1.add(desk1);
lblkelas.setBounds(10,80,100,25);
txtkelas.setBounds(150,80,560,25);
desk1.add(lblkelas);
desk1.add(txtkelas);
form1.add(desk1);
btnok.setBounds(600,350,100,25);
desk1.add(btnok);
btnok.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
System.out.println("button di tekan");
}
});
form1.show();
}
}

Tidak ada komentar:

Posting Komentar