Menampilkan Pilihan Dengan Java Netbeans

Yesterday there was someone in Facebook Java Group asked how to get selected value from RadioButton in Java Swing. Actually this problem is very easy to be solved, but since in the past i didn’t learn Swing in depth and never use RadioButton except in web based projects which are on different side so i took a search on google and read some books 😀

Belajar menggunakan netbeans untuk. Membuat GUI dengan Java Swing 1 Daftar Materi Java. Next part2 netbeans sangat memudahkan seorang programmer dalam mendesain user interface yang menggunakan SWING dan kita akan belajar menggunakannya. Silahkan disimak dulu. Saya menggunakan netbeans 7.0. Buka netbean.hehe #yaiyalah!!

We need to locate RadioButton inside ButtonGroup so that RadioButton works as group not individually because RadioButton’s behavior is can be selected just one in one group. Moreover we have to set the action command for RadioButton, this is like the value of it. So here’s my solution

Suppose you design the Frame using Netbeans GUI Builder

When jButton is clicked, jLabel1 will show whether “male” or “female” depends on your choice.

2
4
6
8
10
publicMainFrame(){
jRadioButton2.setActionCommand('Female');
buttonGroup=newButtonGroup();
buttonGroup.add(jRadioButton2);

As i mentioned above, we set the action command and place RadioButton inside ButtonGroup. To get the value of your choice simply using buttonGroup object.

THe whole front area becomes a huge sound stage.The pinnacle of sound came when I managed to hook up a Cambridge Soundworks 5.1 megaworks with THX Certification and 500 watts of pure RMS power. I was using a system (low budget at $55) with a 25 watt RMS subwoofer and the highs and lows, clarity and deep bass from the system has blown my friends away when played as it matches and even surpassed systems that would cost ten times more. Creative sound blaster thx trustudio pro drivers. They simply could not comprehend that music can sound so good with strong separation of channels and enhanced through stereo surround from 5 speakers.

Menampilkan pilihan dengan java netbeans tutorial