2015-04-29 51 views

回答

3

您可以使用ActionListener,這和當行動被觸發,你可以檢查它的選擇或不

final JCheckBox checkBox = new JCheckBox("My checkbox"); 
checkBox.addActionListener(new ActionListener() 
{ 
    @Override 
    public void actionPerformed(ActionEvent e) 
    { 
     // check if checkBox is selected or not 
     if(checkBox.isSelected()){ 
      // here you can fire an event in which your checkbox is mark as selected 
      // and you can display the value you want to display 
     } else{ 
      // checkBox is not selected so you can fire an event in which your checkbox is not selected 
     } 
    } 
} 
+1

謝謝你的例子:)! –

+0

@YongGonEvanPark歡迎:) – Luffy