Minggu, 13 Februari 2011
Program untuk Summary Visual Programing 0001
ini gan program yang mengandung semua yang ada di posting sebelumnya <<<summary visual programing 0001>>>.
soalnya tugas ini barengan...
kalau ada yang mau copy di buat beda-beda yah biar ngga ketahuan gitu.. hehehehee...
brikut programnya...
<<<<<<<<<<++++++++++>>>>>>>>>>
import java.awt.*;
import javax.swing.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class coba0010 implements ActionListener{
JFrame frame = new JFrame();
JToolBar bar = new JToolBar();
JPanel pnl_bar = new JPanel();
JPanel pnl_isi = new JPanel();
JTextField text = new JTextField("Masukan Nama Anda",20);
final String BOLD = "bold";
final String NORMAL = "normal";
final String ITALIC = "italic";
final String BOLD_ITALIC = "a";
coba0010(){
set_pnl_bar();
set_pnl_isi();
set_frame();
set_pnl();
}
public void set_pnl(){
frame.add(pnl_bar, BorderLayout.NORTH);
frame.add(pnl_isi, BorderLayout.CENTER);
pnl_bar.setLayout(new FlowLayout(FlowLayout.LEFT));
pnl_isi.setLayout(new FlowLayout(FlowLayout.LEFT));
}
public void set_frame(){
frame.setTitle("coba0010");
frame.setSize(250,130);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
public void set_pnl_isi(){
text.setFont(new Font("Kristen ITC",Font.PLAIN,14));
pnl_isi.add(text);
}
public JButton buatButton(String nama, String action, String tip){
JButton btn = new JButton(nama);
btn.setActionCommand(action);
btn.setToolTipText(tip);
btn.addActionListener(this);
return btn;
}
public void set_pnl_bar(){
JButton btn = null;
btn = buatButton("Bold",BOLD,"Membuat Tulisan Tebal");
bar.add(btn);
btn = buatButton("Italic",ITALIC,"Membuat Tulisan Miring");
bar.add(btn);
btn = buatButton("Bold & Italic",BOLD_ITALIC,"Membuat Tulisan Tebal dan Miring");
bar.add(btn);
btn = buatButton("Normal",NORMAL,"Membuat Tulisan Normal");
bar.add(btn);
pnl_bar.add(bar);
}
public void actionPerformed(ActionEvent e){
String cek = e.getActionCommand();
if(BOLD.equals(cek)){
text.setFont(new Font("Kristen ITC",Font.BOLD,14));
}else
if(ITALIC.equals(cek)){
text.setFont(new Font("Kristen ITC",Font.ITALIC,14));
}else
if(BOLD_ITALIC.equals(cek)){
text.setFont(new Font("Kristen ITC",Font.BOLD+Font.ITALIC,14));
}else
if(NORMAL.equals(cek)){
text.setFont(new Font("Kristen ITC",Font.PLAIN,14));
}
}
public static void main(String [] args){
coba0010 coba = new coba0010();
}
}
<<<<<<<<<<++++++++++>>>>>>>>>>
Langganan:
Posting Komentar (Atom)
0 komentar:
Posting Komentar