=====================================================================================
script aplikasi handphone dengan java ini sangat sederhana dan cocok di buat untuk tuga praktek anak IT,,
di sini saya akan berbagi script aplikasi handphone yang sederhana,,
tinggal di copy paste aja,,trz dijalan kan,,,
moga berhasil....
--------------------------------------------------------------------------------------------------
import java.awt.event.*;
import javax.swing.*;
import java.awt.*;
class myPhone extends JFrame implements ActionListener
{
private JTextField input;
private JButton bt0,bt1,bt2,bt3,bt4,bt5,bt6,bt7,bt8,bt9,bt01,bt02;
private JButton yes,no;
public myPhone()
{
super ("Handphone");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLocation(100,100);
setSize(190,190);
setTitle("my phone");
setBackground(Color.pink);
setForeground(Color.black);
JPanel p1 = new JPanel();
p1.setLayout(new FlowLayout());
p1.add(input = new JTextField(15));
input.setEditable(false);
JPanel p2 = new JPanel();
p2.setLayout (new BorderLayout());
p2.add(yes = new JButton("YES"),BorderLayout.WEST);
p2.add(no = new JButton("NO"), BorderLayout.EAST);
JPanel p3 = new JPanel();
p3.setLayout (new GridLayout(4,3));
p3.add(bt1 = new JButton("1"));
p3.add(bt2 = new JButton("2"));
p3.add(bt3 = new JButton("3"));
p3.add(bt4 = new JButton("4"));
p3.add(bt5 = new JButton("5"));
p3.add(bt6 = new JButton("6"));
p3.add(bt7 = new JButton("7"));
p3.add(bt8 = new JButton("8"));
p3.add(bt9 = new JButton("9"));
p3.add(bt01 = new JButton("*"));
p3.add(bt0 = new JButton("0"));
p3.add(bt02 = new JButton("#"));
JPanel p4 = new JPanel();
p4.setLayout (new BorderLayout());
p4.add(p1, BorderLayout.NORTH);
p4.add(p2, BorderLayout.CENTER);
p4.add(p3, BorderLayout.SOUTH);
getContentPane().setLayout(new BorderLayout());
getContentPane().add(p4, BorderLayout.CENTER);
show();
bt1.addActionListener(this);
bt2.addActionListener(this);
bt3.addActionListener(this);
bt4.addActionListener(this);
bt5.addActionListener(this);
bt6.addActionListener(this);
bt7.addActionListener(this);
bt8.addActionListener(this);
bt9.addActionListener(this);
bt0.addActionListener(this);
bt01.addActionListener(this);
bt02.addActionListener(this);
yes.addActionListener(this);
no.addActionListener(this);
}
public void actionPerformed (ActionEvent e)
{
Object objek = e.getSource();
if(objek==bt1) input.setText(input.getText() +"1");else
if(objek==bt2) input.setText(input.getText() +"2");else
if(objek==bt3) input.setText(input.getText() +"3");else
if(objek==bt4) input.setText(input.getText() +"4");else
if(objek==bt5) input.setText(input.getText() +"5");else
if(objek==bt6) input.setText(input.getText() +"6");else
if(objek==bt7) input.setText(input.getText() +"7");else
if(objek==bt8) input.setText(input.getText() +"8");else
if(objek==bt9) input.setText(input.getText() +"9");else
if(objek==bt0) input.setText(input.getText() +"0");else
if(objek==bt01) input.setText(input.getText() +"*");else
if(objek==bt02) input.setText(input.getText() +"#");else
if(objek==yes) input.setText(String.valueOf("calling..."));else
if(objek==no) input.setText(String.valueOf(""));
}
}
public class Phone
{
public static void main (String[] args)
{
new myPhone();
}
}
--------------------------------------------------------------------------------------------------
Langganan:
Posting Komentar (Atom)
keren wak...
BalasHapusGak ngrti :-(
BalasHapus