Monday, 4 February 2013

Membuat Aplikasi java Netbeans (studi kasus menampilkan data dengan komponen swing)

Standard
Pada tutorial java netbeans kali ini akan membahas pembuatan aplikasi menampilkan data dari komponen swing JcheckBox, jRadioButton, Button Group dan jTextArea kelanjutan dari tutorial sebelumnya. Berikut langkah pembuatan aplikasi praktek2 menampilkan data dari komponen swing :
a. Buat project Praktek2 – klik kanan project – pilih New – Klik jFrame Form
b. Masukkan jLabel (4), jTextField, jCheckBox, jRadioButton (2), jButton dan jTextArea. Atur posisi tiap-tiap komponen. Kemudian ubah propertie masing-masing komponen seperti gambar berikut :
image image
c. Pilih dan drag ButtonGroup dari komponen pallete ke dalam jFrame seperti gambar diatas.

d. Ubah properties jRadioButton1 dan jRadioButton2 pada baris buttonGroup menjadi buttonGroup1, seperti gambar berikut :
image
image
e. Klik kanan pada jCheckBox1, pilih Events > Change > stateChanged
ketikan kode seperti gambar berikut :
image
f. Klik kanan jButton1, pilih Events > Mouse > mouseClicked.
Ketikan kode seperti gambar berikut :
image
g. Compile (F11) dan Jalankan program (F6).
image image
Analisa : Apabila jTextField dan jRadioButton kita inputkan maka akan menghasilkan keluaran yang akan ditampung di jTextArea. Contoh disini adalah jTextField : NUR ROCHIM | Jenis Kelamin : Laki-Laki.
image image
Apabila jCheckBox di centang maka akan menghasilkan jenis huruf tebal pada jTextArea, apabila tidak dicentang maka jenis huruf tetap normal seperti gambar disebelah kanan.
Tambahkan juga Button Clear untuk mereset ulang apabila ingin menginputkan lagi.
Pembahasan
* Kode komponen jCheckBox1
image
Analisa : Koding ini memiliki event stateChange yang bermaksut apabila kotak CheckBox dicentang maka akan tampil berubah.
Script diatas maksutnya adalah apabila jCheckBox1 di centang maka teksnya akan berubah menjadi YA, apabila tidak dicentang teksnya tetap TIDAK.
* Kode komponen jButton1
image
Analisa : Koding ini memiliki Event mouseClicked, apabila jButton di klik maka akan melaksanakan kode program selanjutnya.
Font tebal= new Font("Arial".Font.BOLD.J2);
Font biasa= new Font("Arial".Font.PLAIN.J2);
Script diatas untuk mengatur jenis dan ukuran font. Jangan lupa di baris paling awal kode ditambahkan import java.awt.Font agar font dapat berkerja.
if (jRadioButton1.isSelected())     
{ if (jCheckBox1.isSelected())     
{ jTextArea1.setText("Nama : "+jTextField1.getText()+",\nJenis Kelamin:"+jRadioButton1.getText());     
jTextArea1.setFont(tebal); }     
else{     
jTextArea1.setText("Nama : "+jTextField1.getText()+",\nJenis Kelamin:"+jRadioButton1.getText());     
jTextArea1.setFont(biasa);}     
else if(jRadioButton2.isSelected()){     
if (jCheckBox1.isSelected()){     
jTextArea1.setText("Nama : "+jTextField1.getText()+",Jenis Kelamin:"+jRadioButton2.getText());     
jTextArea1.setFont(tebal);}     
else{     
jTextArea1.setText("Nama : "+jTextField1.getText()+",Jenis Kelamin:"+jRadioButton2.getText());     
jTextArea1.setFont(biasa);}}
Maksut script di atas adalah jika jRadioButton1 dan jCheckBox1 di centang maka jTextArea akan menerima input dari jTextField1 yang berupa nama, Jenis kelamin dari jRadioButton dan jCheckBox yang berjenis huruf tebal atau normal. Script “\n” dimaksutkan untuk jRadioButton agar kedua jRadioButton tidak terpilih semuanya dan hanya terpilih salah satu saja.
*** Selamat mencoba ***

39 comments:

  1. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a Java developer learn from Java Training in Chennai. or learn thru Java Online Training in India . Nowadays Java has tons of job opportunities on various vertical industry.

    ReplyDelete
  2. This is quite educational arrange. It has famous breeding about what I rarity to vouch. Colossal proverb.
    This trumpet is a famous tone to nab to troths. Congratulations on a career well achieved. This arrange is synchronous s informative impolites festivity to pity. I appreciated what you ok extremely here 


    Selenium training in bangalore
    Selenium training in Chennai
    Selenium training in Bangalore
    Selenium training in Pune
    Selenium Online training

    ReplyDelete
  3. Hello today decided to climb on the Internet in search of something interetninkogo and found this site fine baccarat online Today I will withdraw my first mo

    ReplyDelete
  4. Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging.
    Selenium Training in Electronic City

    ReplyDelete
  5. Nice article. I liked very much. All the informations given by you are really helpful for my research. keep on posting your views.
    Java Training in Chennai
    Java Training in Coimbatore
    Java Training in Bangalore

    ReplyDelete
  6. This comment has been removed by the author.

    ReplyDelete
  7. This is really an awesome post, thanks for it. Keep adding more information to this.selenium training in bangalore

    ReplyDelete
  8. Really it was an awesome article,very interesting to read.You have provided an nice article,Thanks for sharing.coded ui training in bangalore

    ReplyDelete
  9. Being new to the blogging world I feel like there is still so much to learn. Your tips helped to clarify a few things for me as well as giving.big data testing training in bangalore

    ReplyDelete
  10. Linking is very useful thing.you have really helped lots of people who visit blog and provide them use full information.mobile application testing training in bangalore

    ReplyDelete
  11. Your articles really impressed for me,because of all information so nice.manual testing training in bangalore

    ReplyDelete
  12. Awesome,Thank you so much for sharing such an awesome blog.web designing training in bangalore

    ReplyDelete
  13. Really it was an awesome article,very interesting to read.You have provided an nice article,Thanks for sharing.

    ReplyDelete
  14. Being new to the blogging world I feel like there is still so much to learn. Your tips helped to clarify a few things for me as well as giving.angular 7 training in bangalore

    ReplyDelete
  15. Linking is very useful thing.you have really helped lots of people who visit blog and provide them use full information.sap s4 hana simple finance training in bangalore

    ReplyDelete
  16. I gathered a lot of information through this article.Every example is easy to undestandable and explaining the logic easily.javascript training in bangalore

    ReplyDelete
  17. Very useful and information content has been shared out here, Thanks for sharing it.sap hr training in bangalore

    ReplyDelete
  18. This is really an awesome post, thanks for it. Keep adding more information to this.html training in bangalore

    ReplyDelete
  19. Really i appreciate the effort you made to share the knowledge. The topic here i found was really effective...

    Softgen Infotech is the Best Oracle Training institute located in BTM Layout, Bangalore providing quality training with Realtime Trainers and 100% Job Assistance.

    ReplyDelete
  20. thank you so much for this nice information Article, Digitahanks for sharing your post with us.Real Time Experts training center bangalore

    ReplyDelete
  21. It is amazing and wonderful to visit your site.Thanks for sharing this information,this is useful . student review for Realtime Experts marathahalli bangalore

    ReplyDelete
  22. I have read your blog its very attractive and impressive. I like it your blog.Real Time Experts Training in Bangalore center address bangalore

    ReplyDelete


Copyright © AIMAGU. Jasa Pembuatan Website. All Rights Reserved
Design by Automattic | Blogger Theme by NewBloggerThemes | Official: www.aimagu.com