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$
errorMesis missing areturnstatement (for the case where everything is OK)