lukmanunindra

Home » Pemograman Visual » Pertemuan ke 4 visual

Pertemuan ke 4 visual

Penggunaan  Flow Diagram

package pertemuan4;
import javax.swing.*;
import java.awt.*;
class flow{
public static void main (String [] args){
JFrame f=new JFrame(“Flow Layout”);
FlowLayout fl=new FlowLayout(FlowLayout.CENTER);

JButton b1=new JButton(“Posisi  1”);
JButton b2=new JButton(“Posisi  2”);
JButton b3=new JButton(“Posisi  3”);
JButton b4=new JButton(“Posisi  4”);
JButton b5=new JButton(“Posisi  5”);
JButton b6=new JButton(“Posisi  6”);

f.getContentPane().setLayout(fl);
f.getContentPane().add(b1);
f.getContentPane().add(b2);
f.getContentPane().add(b3);
f.getContentPane().add(b4);
f.getContentPane().add(b5);
f.getContentPane().add(b6);
f.setSize(500,80);
f.setVisible(true);
}
}

Penggunaan Border

package pertemuan4;
import javax.swing.*;
import java.awt.*;
class border{
public static void main (String [] args){
JFrame f=new JFrame(“Border Layout”);
BorderLayout bl=new BorderLayout();
f.getContentPane().setLayout(bl);

JButton b1=new JButton(“NORTH”);
JButton b2=new JButton(“SOUTH”);
JButton b3=new JButton(“EAST”);
JButton b4=new JButton(“WEST”);
JButton b5=new JButton(“CENTER”);

f.getContentPane().add(b1,BorderLayout.NORTH);
f.getContentPane().add(b2,BorderLayout.SOUTH);
f.getContentPane().add(b3,BorderLayout.EAST);
f.getContentPane().add(b4,BorderLayout.WEST);
f.getContentPane().add(b5,BorderLayout.CENTER);

f.pack();
f.setVisible(true);

}
}

%d bloggers like this: