Thursday, November 14, 2013

Java GUI Part 1 - Tampilan1

SamaLoaJava GUI Part 1 - Tampilan1


Hasil Tampilan1 ketika dijalankan
Langsung aja codingnya seperti berikut :

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;

class Tampilan1{
public Tampilan1(){
JFrame frame =  new JFrame();
JLabel label = new JLabel("Pesan : ");
final JTextField txtPesan = new JTextField(30);

JButton btnTampil = new JButton("Tampilkan");
JButton btnKosong = new JButton("Kosongkan");

txtPesan.setText("Ketik Disini");

btnTampil.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent event){
JOptionPane.showMessageDialog(null, txtPesan.getText());
}
});

btnKosong.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent event){
txtPesan.setText("");
}
});

Container contentPane = frame.getContentPane();
contentPane.setLayout(new FlowLayout());

contentPane.add(label);
contentPane.add(txtPesan);
contentPane.add(btnTampil);
contentPane.add(btnKosong);

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}
public static void main(String[] args){
new Tampilan1();
}
}

Categories: , , ,

0 comments:

Post a Comment

http://www.resepkuekeringku.com/2014/11/resep-donat-empuk-ala-dunkin-donut.html http://www.resepkuekeringku.com/2015/03/resep-kue-cubit-coklat-enak-dan-sederhana.html http://www.resepkuekeringku.com/2014/10/resep-donat-kentang-empuk-lembut-dan-enak.html http://www.resepkuekeringku.com/2014/07/resep-es-krim-goreng-coklat-kriuk-mudah-dan-sederhana-dengan-saus-strawberry.html http://www.resepkuekeringku.com/2014/06/resep-kue-es-krim-goreng-enak-dan-mudah.html http://www.resepkuekeringku.com/2014/09/resep-bolu-karamel-panggang-sarang-semut-lembut.html

Copyright © SamaLoa | Powered by Blogger

Design by Anders Noren | Blogger Theme by NewBloggerThemes.com | BTheme.net      Up ↑