0

Im trying to get an error message to display, but i'm getting some errors on my code. Below is the method for the message, the if else statement for the frame to display, and the method for the frame itself, as well as the error message. Thank you, and all help is appreciated!

method for the error.

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

action performed statement else

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"); } 

frame method

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); } 

error message

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$ 
2
  • errorMes is missing a return statement (for the case where everything is OK) Commented Apr 28, 2017 at 18:05
  • im able to compile my program now(Thank you!) but I am getting a new error message once I try to launch the Frame.HERE IT IS Exception in thread "main" java.lang.NullPointerException at java.awt.Window.init(Window.java:497) at java.awt.Window.<init>(Window.java:537) at java.awt.Frame.<init>(Frame.java:420) at java.awt.Frame.<init>(Frame.java:385) at javax.swing.JFrame.<init>(JFrame.java:189) at GuiInter.<init>(GuiInter.java:6) at GuiInter.main(GuiInter.java:939) Commented Apr 28, 2017 at 18:19

1 Answer 1

3

The problem is, you don't know how to spell Exception.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.