0
    jComboBox1.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jComboBox1ActionPerformed(evt);

          if (jComboBox1.getSelectedItem().equals(" ")) 
            {
                rlsum = addElement(sumthing );
            }
         if (jComboBox1.getSelectedItem().equals("S")) 
            {
                rlsum = addElement(sumthing/64 );
            } 
         if (jComboBox1.getSelectedItem().equals("Z")) 
            {
                rlsum = addElement(sumthing/220 );
            } 
       }

        private Object addElement(double i) {
            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }
    });

我想知道如何在不每次都抛出的情况下读取变量 sumthing...

4

1 回答 1

1

你的问题在于下面的代码。您在操作UnsupportedException期间正在投掷addElement

private Object addElement(double i) {
            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

首先使用与您的应用程序需求相关的逻辑来实现您的 addElement。

替换addElement()为以下代码,以免抛出异常

 private Object addElement(double i) {

            //put your business logic, add relevant exception handling for your requirement
            }
于 2013-05-25T05:09:45.487 回答