MANAJEMEN LAYOUT
import java.awt.*;
import javax.swing.*;
class FLayout extends JFrame {
JButton tombolSave,tombolEdit, tombolDelete,tombolOpen;
public FLayout() {
setTitle("FLOWLAYOUT");
tombolOpen = new JButton("OPEN");
tombolOpen.setMnemonic('O');
tombolSave = new JButton("SAVE");
tombolSave.setMnemonic('S');
tombolEdit = new JButton("EDIT");
tombolEdit.setMnemonic('E');
tombolDelete = new JButton("DELETE");
tombolDelete.setMnemonic('D');
setLayout(new FlowLayout());
add(tombolOpen);
add(tombolSave);
add(tombolEdit);
add(tombolDelete);
pack();
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
}
public class CobaFlowLayout {
public static void main (String[] args) {
FLayout f = new FLayout();
}
}
A.OUTPUT

B.INPUT
import java.awt.*;
import javax.swing.*;
class GLayout extends JFrame {
JButton tombolSave, tombolEdit, tombolDelete, tombolOpen, tombolCopy, tombolPaste;
public GLayout() {
setTitle("GRIDLAYOUT");
tombolOpen = new JButton("OPEN");
tombolOpen.setMnemonic('O');
tombolSave = new JButton("SAVE");
tombolSave.setMnemonic('S');
tombolEdit = new JButton("EDIT");
tombolEdit.setMnemonic('E');
tombolDelete = new JButton("DELETE");
tombolDelete.setMnemonic('D');
tombolCopy = new JButton("COPY");
tombolCopy.setMnemonic('C');
tombolPaste = new JButton("PASTE");
tombolPaste.setMnemonic('P');
setLayout(new GridLayout (3,2));
add(tombolOpen);
add(tombolSave);
add(tombolEdit);
add(tombolDelete);
add(tombolCopy);
add(tombolPaste);
pack();
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
}
public class CobaGridLayout {
public static void main (String[] args) {
GLayout g = new GLayout();
}
}
B.OUTPUT

C.INPUT
import java.awt.*;
import javax.swing.*;
class BLayout extends JFrame {
JButton tombolSave, tombolEdit, tombolDelete, tombolOpen;
JLabel labelGambar;
public BLayout() {
setTitle("Border Layout");
tombolOpen = new JButton("Open");
tombolOpen.setMnemonic('O');
tombolSave = new JButton("Save");
tombolSave.setMnemonic('S');
tombolEdit = new JButton("Edit");
tombolEdit.setMnemonic('E');
tombolDelete = new JButton("Delete");
tombolDelete.setMnemonic('D');
labelGambar = new JLabel(new
ImageIcon("Image/Satu.jpg"));
setLayout(new BorderLayout());
add(tombolOpen, "North");
add(tombolSave, "West");
add(labelGambar, "Center");
add(tombolEdit, "East");
add(tombolDelete, "South");
setSize(400,300);
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
}
public class cobaBorderLayout{
public static void main (String []args) {
BLayout b = new BLayout();
}
}
C.OUTPUT

D.INPUT
import java.awt.*;
import javax.swing.*;
class NLayout extends JFrame {
JButton tombolSave, tombolEdit, tombolDelete, tombolOpen;
public NLayout() {
setTitle("NONELAYOUT");
tombolOpen = new JButton("OPEN");
tombolOpen.setMnemonic('O');
tombolSave = new JButton("SAVE");
tombolSave.setMnemonic('S');
tombolEdit = new JButton("EDIT");
tombolEdit.setMnemonic('E');
tombolDelete = new JButton("DELETE");
tombolDelete.setMnemonic('D');
setLayout(null);
add(tombolOpen);
add(tombolSave);
add(tombolEdit);
add(tombolDelete);
tombolOpen.setBounds(10,10,150,20);
tombolSave.setBounds(150,15,150,20);
tombolEdit.setBounds(100,30,150,20);
tombolDelete.setBounds(40,50,150,20);
setSize(350,200);
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
}
public class cobaNullLayout {
public static void main (String[] args) {
NLayout n = new NLayout();
}
}
D.OUTPUT

E.INPUT
import java.awt.*;
public class frameAWT {
public static void main(String[] args) {
Frame myFrame = new Frame ("Demo program AWT");
myFrame.setLayout(new BorderLayout());
Label labelPil = new Label("Title Pilihan Buah");
myFrame.add(labelPil,BorderLayout.NORTH);
Panel myPanel = new Panel(new BorderLayout());
Label labelBuah = new Label("Buah = ");
myPanel.add(labelBuah,BorderLayout.WEST);
Choice myChoice = new Choice();
myChoice.add("Mangga");
myChoice.add("Pisang");
myChoice.add("Jeruk");
myChoice.add("Apple");
myChoice.add("Anggur");
myChoice.add("Nangka");
myFrame.add(myPanel,BorderLayout.SOUTH);
myFrame.setSize(300,200);
myPanel.add(myChoice,BorderLayout.EAST);
myFrame.show();
}
}
E.OUTPUT

F.INPUT
import javax.swing.*;
class GUI extends JFrame {
JLabel lNama = new JLabel("Nama Lengkap : ");
final JTextField fNama =
new JTextField(10);
JLabel lJnsKlmn =
new JLabel("Jenis Kelamin : ");
JRadioButton rBPria =
new JRadioButton("Laki-laki");
JRadioButton rBWanita =
new JRadioButton("Perempuan");
JLabel lAgama =
new JLabel("Agama : ");
String [] NamaAgama = {
"Islam", "Kristen", "Katolik",
"Hindu", "Buddha"
};
JComboBox cMBAgama =
new JComboBox(NamaAgama);
JLabel lHobby =
new JLabel("Hobby : ");
JCheckBox cBSepakBola =
new JCheckBox("SepakBola");
JCheckBox cBBasket =
new JCheckBox("Basket");
JButton bTNSave =
new JButton("OK");
public GUI() {
setTitle("Mencoba kombinasi komponen GUI");
setDefaultCloseOperation(3);
setSize(350,200);
ButtonGroup Group = new ButtonGroup();
Group.add(rBPria);
Group.add(rBWanita);
setLayout(null);
add(lNama);
add(fNama);
add(lJnsKlmn);
add(rBPria);
add(rBWanita);
add(lAgama);
add(cMBAgama);
add(lHobby);
add(cBSepakBola);
add(cBBasket);
add(bTNSave);
lNama.setBounds(10,10,120,20);
fNama.setBounds(130,10,150,20);
lJnsKlmn.setBounds(10,35,120,20);
rBPria.setBounds(130,35,100,20);
rBWanita.setBounds(230,35,120,20);
lAgama.setBounds(10,60,150,20);
cMBAgama.setBounds(130,60,120,20);
lHobby.setBounds(10,85,120,20);
cBSepakBola.setBounds(130,85,100,20);
cBBasket.setBounds(230,85,150,20);
bTNSave.setBounds(10,130,120,20);
fNama.setBounds(130,10,150,20);
setVisible(true);
}
}
class ObjekGUI {
public static void main(String []args) {
GUI G = new GUI();
}
}
F.OUTPUT

G.INPUT
import javax.swing.*;
import java.awt.*;class TES extends JFrame {
JButton tombol1, tombol2, tombol3, tombol4, tombol5, tombol6, tombol7, tombol8, tombol9, tombol10, tombol11, tombol12;
JLabel Label1, Label2, Label3;
JPanel panelLabel, panel1, panel2, panel3;
public TES () {
setTitle ("MULTI LAYOUT");
panelLabel = new JPanel (null);
Label1 = new JLabel ("Flow Layout");
Label2 = new JLabel ("None Layout");
Label3 = new JLabel ("None Layout");
panel1 = new JPanel (new FlowLayout());
tombol1 = new JButton ("1");
tombol2 = new JButton ("2");
tombol3 = new JButton ("3");
tombol4 = new JButton ("4");
panel2 = new JPanel (null);
tombol5 = new JButton ("5");
tombol6 = new JButton ("6");
tombol7 = new JButton ("7");
tombol8 = new JButton ("8");
Label3 = new JLabel ("Grid Layout");
panel3 = new JPanel (new GridLayout(2,2));
tombol9 = new JButton ("9");
tombol10 = new JButton ("10");
tombol11 = new JButton ("11");
tombol12 = new JButton ("12");
setLayout (new BorderLayout());
add (Label1, "North");
add (Label2);
add (Label3);
add (panel1,"West");
panel1.add (tombol1);
panel1.add (tombol2);
panel1.add (tombol3);
panel1.add (tombol4);
add (panel2, "Center");
panel2.add (tombol5);
panel2.add (tombol6);
panel2.add (tombol7);
panel2.add (tombol8);
add (panel3, "East");
panel3.add (tombol9);
panel3.add (tombol10);
panel3.add (tombol11);
panel3.add (tombol12);
Label2.setBounds(225,-5,80,25);
Label3.setBounds(345,-5,80,25);
tombol5.setBounds(30,15,80,25);
tombol6.setBounds(30,40,80,25);
tombol7.setBounds(30,65,80,25);
tombol8.setBounds(30,90,80,25);
setSize(450,170);
setVisible(true);
setResizable(false);
setLocation(450,300);
setDefaultCloseOperation(3);
}
}
class Tugas {
public static void main (String[]args) {
TES T = new TES();
}
}
G.OUTPUT
