lukmanunindra

Home » Pemograman Visual » Pertemuan 1 visual

Pertemuan 1 visual

contoh Program membuat Frame di java

package pertemuan1;

import javax.swing.JFrame;
public class frame2
{   public static void main(String[]xXx)
{   JFrame frame = new JFrame();
frame.setSize(700,300);
frame.setVisible(true);
}
}

 

Contoh Progra pembuatan text

package pertemuan1;
import javax.swing.*;
class Text
{   public static void main(String[] args)
{   JTextField txt = new JTextField();
JFrame frame = new JFrame();
JLabel lbl = new JLabel(“Nama Anda”);
JLabel lbl2 = new JLabel(“Alamat”);

frame.setSize(500, 200);
frame.add(txt);
frame.add(lbl);
frame.add(lbl2);
lbl.setBounds(10, 10, 150, 25);
lbl2.setBounds(10, 30, 150, 25);

txt.setBounds(80, 10, 150, 25);
frame.setLayout(null);
frame.setVisible(true);

}
}

 

Contoh pembuatan Button

package pertemuan1;

import javax.swing.JFrame;
import javax.swing.JButton;
import java.awt.*;

public class button
{   public static void main(String[]xXx)
{   JFrame frame = new JFrame();
JButton bttn = new JButton(“pencetaku”);
frame.setSize(300,300);
bttn.setBounds(180, 100, 150, 25);
frame.add(bttn);
frame.setLayout(null);
frame.setVisible(true);

}
}

Advertisements
%d bloggers like this: