如何从虚拟数字键盘获取小数点?

时间:2012-11-11 23:19:41

标签: java swing jbutton decimal-point numpad

我试图通过点击GUI按钮来显示小数点。我使用下面的方法,它适用于数字但不是小数点。任何建议都会很棒。感谢

private void displayWeightedquantity(ActionEvent event){
    JButton currentButton = null;
    JButton[] numberButtonsarray = {bnDecimal,bnZero,bnOne, bnTwo, bnThree, bnFour, bnFive,bnSix,bnSeven,
                                    bnEight,bnNine};

    currentButton = (JButton)event.getSource();  
    for (int i = 0; i <numberButtonsarray.length; i++){
         if (currentButton == numberButtonsarray[i]){
             lbDisplayitemQty.setText(lbDisplayitemQty.getText() + currentButton.getText());  
             break;
             }
        } 
   }

我的虚拟号码:

enter image description here

1 个答案:

答案 0 :(得分:1)

我怀疑问题是代码中的其他位置。

我设置的测试工作找到了。

您需要提供一个功能示例来显示问题,而不仅仅是代码段。

另外,请确保小数点按钮附加了动作监听器

相关问题