试图为我的程序生成错误消息

时间:2017-04-28 18:00:56

标签: java swing

我试图收到要显示的错误消息,但我的代码上出现了一些错误。下面是消息的方法,要显示的框架的if else语句,框架本身的方法以及错误消息。谢谢,所有的帮助表示赞赏!

错误的方法。

public boolean errorMes(String s)
                            {

                                try
                                {
                                    Integer.parseInt(s);
                                }
                                catch(NumberFormatExeception e)
                                {
                                    return false;
                                }
                                catch(NullPointerExeception e)
                                {
                                    return false;
                                }
                            }

行动执行声明                                         其他

if(buttonCommand.equals("Calculate M1"))
        {
            GuiCalc CalcIeM1 = new GuiCalc();

            m2IeStr = m2InElas.getText();
            //m2IeNo = Double.parseDouble(m2IeStr);
            v1iIeStr = v1iInElas.getText();
            //v1iIeNo = Double.parseDouble(v1iIeStr);
            v2iIeStr = v2iInElas.getText();
            //v2iIeNo = Double.parseDouble(v2iIeStr);
            vfIeStr = vfInElas.getText();
            //vfIeNo = Double.parseDouble(vfIeStr);

            m2 = errorMes(m2IeStr);
            v1i = errorMes(v1iIeStr);
            v2i = errorMes(v2iIeStr);
            vf = errorMes(vfIeStr);

            if (m2 == true && v1i == true && v2i == true && vf == true)
            {

            m1IeNo = CalcIeM1.CalcInelasM1(m2IeNo, v1iIeNo, v2iIeNo, vfIeNo);
            m1IeStr = Double.toString(m1IeNo);

            JTable inelasTableM1 = new JTable(inelasData,inelasTitles);
            JScrollPane inelasScrollPanelM1 = new JScrollPane(inelasTableM1);
            inelasTableM1.setFillsViewportHeight(true);
            inelasTableM1.setBackground(Color.RED);
            inelasticFrame.add(inelasScrollPanelM1, BorderLayout.SOUTH);
            }

            else{
                m1InElas.setText("");
                m2InElas.setText("");
                v1iInElas.setText("");
                v2iInElas.setText("");
                vfInElas.setText("");

            setError();
            }

            inelasticFrame.validate();
            inelasticFrame.repaint();
            System.out.println("M1 pressed");
        }

帧方法

public void setError()
    {
        errorFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        errorFrame.setBounds(200,200,200,200);
        errorFrame.setLayout(new BorderLayout());
        errorFrame.getContentPane().setBackground(elasColor);

        errorHomeButton.addActionListener(this);

        errorHomeButton.setToolTipText("Go Home");

        picturePanelError.add(errorIcon);

        textPanelErrorTitle.add(errorTitle);
        textPanelErrorMessage.add(errorMessage);
        buttonPanelError.add(errorHomeButton);

        errorFrame.add(textPanelErrorTitle, BorderLayout.NORTH);
        errorFrame.add(textPanelErrorMessage, BorderLayout.CENTER);
        errorFrame.add(buttonPanelError, BorderLayout.SOUTH);
        errorFrame.add(picturePanelError, BorderLayout.EAST);

        errorFrame.setVisible(true);
    }

错误消息

GuiInter.java:300: error: cannot find symbol
        helpSelectButton.setToolTipText("Click for help");
        ^
  symbol:   variable helpSelectButton
  location: class GuiInter
GuiInter.java:909: error: cannot find symbol
                                catch(NumberFormatExeception e)
                                      ^
  symbol:   class NumberFormatExeception
  location: class GuiInter
GuiInter.java:913: error: cannot find symbol
                                catch(NullPointerExeception e)
                                      ^
  symbol:   class NullPointerExeception
  location: class GuiInter
3 errors
Pauls-MacBook-Pro:Chapter 15 paulnelson$ 

1 个答案:

答案 0 :(得分:3)

问题是,你不知道如何拼写Exception