Results 1 to 6 of 6
Thread: please check me this excption
- 05-18-2010, 07:40 PM #1
Member
- Join Date
- Mar 2010
- Posts
- 49
- Rep Power
- 0
please check me this excption
//after i catch the exception it doesnt print on the console ???why ??
Java Code:import javax.swing.*; import java.awt.*; import java.util.*; import java.awt.event.*; public class FileReader extends JFrame{ String s1; String s2; double x1; double x2; double result; String resultStr; JTextField field1; JTextField field2 ; JTextField resultField; public FileReader(){ Container c = getContentPane(); JPanel p1 = new JPanel(); JPanel p2 = new JPanel(); c.setLayout(new GridLayout(2,1,5,5)); p1.setLayout(new FlowLayout()); JLabel l1 = new JLabel("number 1"); field1 = new JTextField(8); field2 = new JTextField(8); JLabel l2 = new JLabel("number 2"); JLabel l3 = new JLabel ("Result"); resultField = new JTextField(8); p1.add(l1); p1.add(field1); p1.add(l2); p1.add(field2); p1.add(l3); p1.add(resultField); JButton divide = new JButton(" Divide "); divide.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ try{ s1 = field1.getText(); x1 = Double.parseDouble(s1); s2 = field2.getText(); x2 = Double.parseDouble(s2); result = x1 / x2; resultStr = Double.toString(result); resultField.setText(resultStr);} catch (Exception ex) { System.out.println(""); //why it does not print on the console ??? ?????? } } }); p2.add(divide); c.add(p1); c.add(p2); setSize(400,400); setVisible(true); } }
- 05-18-2010, 07:45 PM #2
Senior Member
- Join Date
- Feb 2010
- Location
- Ljubljana, Slovenia
- Posts
- 470
- Rep Power
- 4
You're trying to print an empty String. Surprise surprise, nothing shows up.
Ever seen a dog chase its tail? Now that's an infinite loop.
- 05-18-2010, 07:56 PM #3
Member
- Join Date
- Mar 2010
- Posts
- 49
- Rep Power
- 0
lol i am sorry i forgot to edit it,,
even if it wasnt an empty string it will pirnt nothing
- 05-18-2010, 07:59 PM #4
Senior Member
- Join Date
- Feb 2010
- Location
- Ljubljana, Slovenia
- Posts
- 470
- Rep Power
- 4
If a System.out.println() inside a catch block doesn't print, then no exception was caught.
Ever seen a dog chase its tail? Now that's an infinite loop.
- 05-18-2010, 08:25 PM #5
Member
- Join Date
- Mar 2010
- Posts
- 49
- Rep Power
- 0
why no exception was caught ?? i inserted zero, and there must be an exception
- 05-18-2010, 08:37 PM #6
Senior Member
- Join Date
- Feb 2009
- Posts
- 303
- Rep Power
- 5
Similar Threads
-
how to check authorisation
By somesh A in forum NetworkingReplies: 2Last Post: 05-07-2010, 04:44 AM -
Don't know what to check for
By Chasingxsuns in forum New To JavaReplies: 8Last Post: 08-26-2009, 05:59 AM -
pls check it
By aRTx in forum New To JavaReplies: 0Last Post: 03-24-2009, 02:35 PM -
how to check java
By funkygarzon in forum New To JavaReplies: 10Last Post: 03-08-2009, 08:39 AM -
Check box tag
By elizaabru in forum JavaServer Pages (JSP) and JSTLReplies: 0Last Post: 08-26-2008, 02:37 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks