JAVA
import java.awt.*;
import javax.swing.*;
class BLayout extends JFrame {
JButton tombolSave, tombolEdit, tombolDelete,tombolOpen;
JLabel labelGambar;
public BLayout() {
setTitle("BOURDER 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(tombolEdit, "Center");
add(tombolDelete, "East");
setSize(400,300);
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
}
public class CobaBorderLayout {
public static void main (String[] args) {
BLayout b=new BLayout();
}
}
import javax.swing.*;
class BLayout extends JFrame {
JButton tombolSave, tombolEdit, tombolDelete,tombolOpen;
JLabel labelGambar;
public BLayout() {
setTitle("BOURDER 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(tombolEdit, "Center");
add(tombolDelete, "East");
setSize(400,300);
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
}
public class CobaBorderLayout {
public static void main (String[] args) {
BLayout b=new BLayout();
}
}
==========================================================================
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();
}
}
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();
}
}
===========================================================================
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();
}
}
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();
}
}
==========================================================================
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();
}
}
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();
}
}
===========================================================================
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= ");
Choice myChoice=new Choice();
myChoice.add("Mangga");
myChoice.add("Pisang");
myChoice.add("Jeruk");
myChoice.add("Apel");
myChoice.add("Anggur");
myChoice.add("Nangka");
myFrame.add(myPanel,BorderLayout.SOUTH);
myFrame.setSize(300,200);
myPanel.add(myChoice,BorderLayout.EAST);
myFrame.show();
}
}
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= ");
Choice myChoice=new Choice();
myChoice.add("Mangga");
myChoice.add("Pisang");
myChoice.add("Jeruk");
myChoice.add("Apel");
myChoice.add("Anggur");
myChoice.add("Nangka");
myFrame.add(myPanel,BorderLayout.SOUTH);
myFrame.setSize(300,200);
myPanel.add(myChoice,BorderLayout.EAST);
myFrame.show();
}
}
===========================================================================
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", "Katolok", "Hindu", "Budha"
};
JComboBox cMBAgama =
new JComboBox(NamaAgama);
JLabel lHobby =
new JLabel ("Hobby : ");
JCheckBox cBSepakbola =
new JCheckBox("Sepakbola");
JCheckBox cBBolaBasket =
new JCheckBox("BolaBasket");
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(cBBolaBasket);
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,100,20);
lAgama.setBounds (10,60,150,20);
cMBAgama.setBounds (130,60,120,20);
lHobby.setBounds (10,10,120,20);
cBSepakbola.setBounds (130,85,150,20);
cBBolaBasket.setBounds (230,85,150,20);
bTNSave.setBounds (100,130,120,20);
FNama.setBounds (130,10,150,20);
setVisible (true);
}
}
class ObjekGUI {
public static void main (String []args){
GUI G = new GUI();
}
}
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", "Katolok", "Hindu", "Budha"
};
JComboBox cMBAgama =
new JComboBox(NamaAgama);
JLabel lHobby =
new JLabel ("Hobby : ");
JCheckBox cBSepakbola =
new JCheckBox("Sepakbola");
JCheckBox cBBolaBasket =
new JCheckBox("BolaBasket");
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(cBBolaBasket);
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,100,20);
lAgama.setBounds (10,60,150,20);
cMBAgama.setBounds (130,60,120,20);
lHobby.setBounds (10,10,120,20);
cBSepakbola.setBounds (130,85,150,20);
cBBolaBasket.setBounds (230,85,150,20);
bTNSave.setBounds (100,130,120,20);
FNama.setBounds (130,10,150,20);
setVisible (true);
}
}
class ObjekGUI {
public static void main (String []args){
GUI G = new GUI();
}
}
=============================================================================
Tugas :
import java.awt.*;
import javax.swing.*;
class layout extends JFrame {
JButton Btna,Btnb, Btnc, Btnd, Btne,Btnf, Btng, Btnh, Btni, Btnj, Btnk, Btnl ;
JLabel lNama,lNama2,lNama3;
JPanel P1,P2,P3;
public layout() {
setTitle("MULTI LAYOUT");
JLabel lNama= new JLabel("Flow Layout" );
JButton Btna=new JButton ("0");
JButton Btnb=new JButton ("1");
JButton Btnc=new JButton ("2");
JButton Btnd=new JButton ("3");
JLabel lNama2= new JLabel("None Layout" );
JButton Btne=new JButton ("4");
JButton Btnf=new JButton ("5");
JButton Btng=new JButton ("6");
JButton Btnh=new JButton ("7");
JLabel lNama3= new JLabel("Grid Layout" );
JButton Btni=new JButton ("8");
JButton Btnj=new JButton ("9");
JButton Btnk=new JButton ("10");
JButton Btnl=new JButton ("11");
P1 = new JPanel();
P2 = new JPanel();
P3 = new JPanel();
setLayout(null);
add(lNama);
add(lNama2);
add(lNama3);
add(P1);
add(P2);
add(P3);
lNama.setBounds(15,10,100,20);
lNama2.setBounds(220,10,100,20);
lNama3.setBounds(320,10,100,20);
P1.setBounds(5,30,200,40);
P2.setBounds(215,30,200,100);
P3.setBounds(320,30,200,150);
P1.setLayout(new FlowLayout());
P1.add(Btna);
P1.add(Btnb);
P1.add(Btnc);
P1.add(Btnd);
P2.setLayout(null);
P2.add(Btne);
P2.add(Btnf);
P2.add(Btng);
P2.add(Btnh);
Btne.setBounds(5,10,70,20);
Btnf.setBounds(5,30,70,20);
Btng.setBounds(5,50,70,20);
Btnh.setBounds(5,70,70,20);
P3.setLayout(new GridLayout(2,1));
P3.add(Btni);
P3.add(Btnj);
P3.add(Btnk);
P3.add(Btnl);
P3.setSize(100,100);
setSize(500,200);
setDefaultCloseOperation(3);
}
}
public class BelsonDamanik{
public static void main(String[] args) {
layout l = new layout();
}
}
import javax.swing.*;
class layout extends JFrame {
JButton Btna,Btnb, Btnc, Btnd, Btne,Btnf, Btng, Btnh, Btni, Btnj, Btnk, Btnl ;
JLabel lNama,lNama2,lNama3;
JPanel P1,P2,P3;
public layout() {
setTitle("MULTI LAYOUT");
JLabel lNama= new JLabel("Flow Layout" );
JButton Btna=new JButton ("0");
JButton Btnb=new JButton ("1");
JButton Btnc=new JButton ("2");
JButton Btnd=new JButton ("3");
JLabel lNama2= new JLabel("None Layout" );
JButton Btne=new JButton ("4");
JButton Btnf=new JButton ("5");
JButton Btng=new JButton ("6");
JButton Btnh=new JButton ("7");
JLabel lNama3= new JLabel("Grid Layout" );
JButton Btni=new JButton ("8");
JButton Btnj=new JButton ("9");
JButton Btnk=new JButton ("10");
JButton Btnl=new JButton ("11");
P1 = new JPanel();
P2 = new JPanel();
P3 = new JPanel();
setLayout(null);
add(lNama);
add(lNama2);
add(lNama3);
add(P1);
add(P2);
add(P3);
lNama.setBounds(15,10,100,20);
lNama2.setBounds(220,10,100,20);
lNama3.setBounds(320,10,100,20);
P1.setBounds(5,30,200,40);
P2.setBounds(215,30,200,100);
P3.setBounds(320,30,200,150);
P1.setLayout(new FlowLayout());
P1.add(Btna);
P1.add(Btnb);
P1.add(Btnc);
P1.add(Btnd);
P2.setLayout(null);
P2.add(Btne);
P2.add(Btnf);
P2.add(Btng);
P2.add(Btnh);
Btne.setBounds(5,10,70,20);
Btnf.setBounds(5,30,70,20);
Btng.setBounds(5,50,70,20);
Btnh.setBounds(5,70,70,20);
P3.setLayout(new GridLayout(2,1));
P3.add(Btni);
P3.add(Btnj);
P3.add(Btnk);
P3.add(Btnl);
P3.setSize(100,100);
setSize(500,200);
setDefaultCloseOperation(3);
}
}
public class BelsonDamanik{
public static void main(String[] args) {
layout l = new layout();
}
}
Tidak ada komentar:
Posting Komentar