Membuat MultiLayout dengan nama class amri.java
import java.awt.*;
import javax.swing.*;
class GLayout extends JFrame{
JButton tombol0, tombol1, tombol2, tombol3,tombol4, tombol5, tombol6, tombol7,tombol8, tombol9, tombol10, tombol11;
JLabel labelGambar;
JPanel P1,P2,P3;
public GLayout() {
setTitle("MULTI LAYOUT");
tombol0 = new JButton("0");
tombol1 = new JButton("1");
tombol2 = new JButton("2");
tombol3 = new JButton("3");
tombol4 = new JButton("4");
tombol5 = new JButton("5");
tombol6 = new JButton("6");
tombol7 = new JButton("7");
tombol8 = new JButton("8");
tombol9 = new JButton("9");
tombol10 = new JButton("10");
tombol11 = new JButton("11");
P1 = new JPanel();
P2 = new JPanel();
P3 = new JPanel();
setLayout(new GridLayout(1,3));
add(P1);
add(P2);
add(P3);
P1.setLayout(new FlowLayout());
P1.add(tombol0);
P1.add(tombol1);
P1.add(tombol2);
P1.add(tombol3);
P2.setLayout (null);
P2.add(tombol4);
P2.add(tombol5);
P2.add(tombol6);
P2.add(tombol7);
tombol4.setBounds(10,10,150,20);
tombol5.setBounds(10,30,150,20);
tombol6.setBounds(10,50,150,20);
tombol7.setBounds(10,70,150,20);
P3.setLayout(new GridLayout(2,2));
P3.add(tombol8);
P3.add(tombol9);
P3.add(tombol10);
P3.add(tombol11);
setSize(600,200);
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
}
public class amri {
public static void main(String[] args) {
GLayout g= new GLayout();
}
}
TUGAS PERTEMUAN 8
Written by Amri on Minggu, 06 Januari 2013 at 23.09
inilah hasilnya
Langganan:
Posting Komentar (RSS)
0 Responses to "TUGAS PERTEMUAN 8"
Posting Komentar