Inilah hasil dari kelas Visual Programing 14 Februari 2011.
<<<<<<<<<<++++++++++>>>>>>>>>>
import java.awt.*;
import javax.swing.*;
public class coba0011 extends JFrame{
public static void main(String [] args){
coba0011 coba = new coba0011();
coba.setVisible(true);
}
coba0011(){
this.setSize(300,200);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setTitle("-------------");
this.setLocationRelativeTo(null);
aturpanel1();
aturpanel2();
aturpanel3();
}
JTextField textfield(){
JTextField text = new JTextField(50);
text.setPreferredSize(new Dimension (30,40));
return text;
}
JLabel label(String name){
JLabel lbl = new JLabel(name);
return lbl;
}
JButton button(String name){
JButton btn = new JButton(name);
btn.setPreferredSize(new Dimension (100,30));
return btn;
}
void aturpanel1(){
JPanel pnl= new JPanel();
this.add(pnl, BorderLayout.NORTH);
JButton btn =null;
JLabel lbl=null;
JTextField text = null;
pnl.setLayout(new FlowLayout(FlowLayout.LEFT));
JToolBar bar= new JToolBar("Tool");
btn=button("A");
bar.add(btn);
btn=button("B");
bar.add(btn);
btn=button("C");
bar.add(btn);
pnl.add(bar);
}
void aturpanel2(){
JPanel pnl= new JPanel();
this.add(pnl, BorderLayout.CENTER);
pnl.setLayout(new GridLayout(3,2,5,5));
JLabel lbl=null;
JTextField text = null;
lbl=label("Frist Name");
pnl.add(lbl);
text=textfield();
pnl.add(text);
lbl=label("Middel Name");
pnl.add(lbl);
text=textfield();
pnl.add(text);
lbl=label("Last Name");
pnl.add(lbl);
text=textfield();
pnl.add(text);
}
void aturpanel3(){
JPanel pnl= new JPanel();
this.add(pnl, BorderLayout.SOUTH);
pnl.setLayout(new FlowLayout(FlowLayout.CENTER));
JButton btn =null;
btn=button("Ok");
pnl.add(btn);
btn=button("Cancel");
pnl.add(btn);
}
}
<<<<<<<<<<++++++++++>>>>>>>>>>
0 komentar:
Posting Komentar