Penambahan dengan swing
Halaman 1 dari 1
Penambahan dengan swing
Code dibawah ini adalah GUI dasar untuk java
sampai baris ke 44 yakni tanda );
GoodLuck......
- Code:
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
public class oke extends JFrame
{
public JTextArea a,b,c;
int aa,bb,cc;
public JLabel satu,dua,tiga ;
String Hasil;
public oke()
{
setTitle("Simle Event");
satu = new JLabel ("Pertama :");
satu.setBounds (10,20,80,25);
a = new JTextArea();
a.setBounds(100, 20, 80, 25);
dua = new JLabel ("Kedua :");
dua.setBounds (10,50,80,25);
b = new JTextArea();
b.setBounds(100, 50, 80, 25);
tiga = new JLabel ("Tiga :");
tiga.setBounds (10,80,80,25);
c = new JTextArea();
c.setBounds(100, 80, 80, 25);
JButton ppfu = new JButton("Ok");
ppfu.setBounds(100, 110, 80, 25);
ppfu.addActionListener
(
new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
aa = Integer.parseInt(a.getText());
bb = Integer.parseInt(b.getText());
cc = aa+bb;
Hasil = Integer.toString(cc);
c.setText(Hasil);
}
}
);
JPanel paimo = new JPanel();
paimo.setLayout(null);
paimo.add(satu);
paimo.add(ppfu);
paimo.add(dua);
paimo.add(tiga);
paimo.add(a);
paimo.add(b);
paimo.add(c);
add(paimo);
setSize(300, 200);
setLocationRelativeTo(null);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setVisible(true);
}
public static void main(String[] args)
{
new oke();
}
}
sampai baris ke 44 yakni tanda );
GoodLuck......
cpp- Pejuang
- Jumlah posting : 35
Registration date : 15.03.09
Halaman 1 dari 1
Permissions in this forum:
Anda tidak dapat menjawab topik
|
|