Navigator
Java UIManager
Demo Project
Desktop GUI
- JTextField/JLabel
- JProgressBar/JSlider
- JCheckBox
- JDialog/JColorChooser
- JComboBox/JList
- JRadioButton
- JSpinner
- JTextArea
- JTable
J2ME (Java Mobile)
JME (JMonkey)
Tutorial & Doc
Java Monkey Engine (EN)
JavaFX (En)

Netbeans IDE
![]()
Swing GUI with NetBeans IDE
JCheckBox


นำ Component ต่างๆ มาวางดังภาพแล้วทำการแก้ไข
คลิกขวาที่ปุ่ม เลือก Events --> Action --> actionPerformed เพื่อทำการเขียนโค้ด
int Bath = 0;
if (jCheckBox1.isSelected() == true) { Bath += 50; } if (jCheckBox2.isSelected() == true) { Bath += 30; } if (jCheckBox3.isSelected() == true) { Bath += 20; } jLabel1.setText("ราคารวม : " + Bath + " ฿"); |
กดปุ่ม Shift+F6 เพื่อรันโปรแกรม
ผลที่ได้
อธิบาย
โปรแกรมจะทำการบวกค่าเพิ่มตามจำนวนที่กำหนดไว้
เช่น if (jCheckBox1.isSelected() == true) {
Bath += 50;
}
เมื่อมีการ check ค่าที่ช่องแรกให้บวกค่าเพิ่มไปอีก 50 แล้วเก็บค่าไว้ในตัวแปร Bath เพื่อนำไปแสดงผลยัง JLabel






