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 ***

48 comments:

  1. This comment has been removed by the author.

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

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

    ReplyDelete
  4. 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
  5. 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
  6. Very useful and information content has been shared out here, Thanks for sharing it.sap hr training in bangalore

    ReplyDelete
  7. 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
  8. Office 365 has number of technical prerequisites that you need to be aware of before you migrate. The main one that catches people out is that Windows XP and Office 2003 are not supported. office 365

    ReplyDelete
  9. When I originally commented I seem to have clicked the -Notify me when new comments are added- checkbox and from now on each time a comment is added I recieve 4 emails with the exact same comment. theme Perhaps there is an easy method you are able to remove me from that service? Thanks a lot!

    ReplyDelete
  10. Thanks for the informative article About Java. This is one of the best resources I have found in quite some time. Nicely written and great info. I really cannot thank you enough for sharing.
    Java training in chennai | Java training in annanagar | Java training in omr | Java training in porur | Java training in tambaram | Java training in velachery

    ReplyDelete
  11. Wow What A Nice And Great Article, Thank You So Much for Giving Us Such a Nice & Helpful Information about Java, keep sending us such informative articles I visit your website on a regular basis.Please refer below if you are looking for best Training Center.
    Java training in chennai | Java training in annanagar | Java training in omr | Java training in porur | Java training in tambaram | Java training in velachery

    ReplyDelete
  12. I have been reading for the past two days about your blogs and topics, still on fetching! Wondering about your words on each line was massively effective. Techno-based information has been fetched in each of your topics. Sure it will enhance and fill the queries of the public needs. thank u so much for sharing this post
    Ai & Artificial Intelligence Course in Chennai
    PHP Training in Chennai
    Ethical Hacking Course in Chennai Blue Prism Training in Chennai
    UiPath Training in Chennai

    ReplyDelete
  13. Great post, you have pointed out some fantastic points , I likewise think this s a very wonderful website. magento data entry

    ReplyDelete
  14. Wounderful blog thanks for sharing us it is very useful article blog.
    https://www.acte.in/reviews-complaints-testimonials
    https://www.acte.in/velachery-reviews
    https://www.acte.in/tambaram-reviews
    https://www.acte.in/anna-nagar-reviews
    https://www.acte.in/porur-reviews
    https://www.acte.in/omr-reviews
    https://www.acte.in/blog/acte-student-reviews

    ReplyDelete
  15. Nice information, valuable and excellent design, as share good stuff with good ideas and concepts, lots of great information and inspiration, both of which I need, thanks to offer such a helpful information here.
    python training in bangalore

    python training in hyderabad

    python online training

    python training

    python flask training

    python flask online training

    python training in coimbatore
    python training in chennai

    python course in chennai

    python online training in chennai

    ReplyDelete
  16. Mountain Duck Keygen is a nifty OS X app that can make managing cloud storage accounts and FTP, SFTP, or WebDAV servers a lot easier, as it.Mountain Duck Encryption

    ReplyDelete
  17. Great, post is so informative and helpfull to everyone , keep posting and checkout my blog java course in pune

    ReplyDelete


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