throw exception

Reply

Join Date: Oct 2008
Posts: 4
Reputation: Tbusuk is an unknown quantity at this point 
Solved Threads: 0
Tbusuk Tbusuk is offline Offline
Newbie Poster

throw exception

 
0
  #1
Oct 21st, 2008
  1. import java.awt.*;
  2. import java.applet.*;
  3. import java.util.Scanner;
  4. import java.io.*;
  5.  
  6. public class SuperSaver extends Applet
  7. {
  8. TextField inputField;
  9. Button saveButton;
  10. Button clearButton;
  11. Label titleLabel;
  12.  
  13. public void init()
  14. {
  15. setLayout(null);
  16.  
  17. titleLabel = new Label("Super saver");
  18. titleLabel.reshape(260,20,80,30);
  19. add(titleLabel);
  20.  
  21. inputField = new TextField();
  22. inputField.reshape(100,60,400,100);
  23. add(inputField);
  24.  
  25. saveButton = new Button("SAVE");
  26. saveButton.reshape(100,175,70,30);
  27. add(saveButton);
  28.  
  29. clearButton = new Button("CLEAR");
  30. clearButton.reshape(430,175,70,30);
  31. add(clearButton);
  32.  
  33. resize(600,300);
  34.  
  35. }
  36. public boolean handleEvent(Event event)
  37. {
  38. if (event.target == saveButton && event.id == Event.ACTION_EVENT)
  39. {
  40. PrintStream outwrite = new PrintStream(new FileOutputStream("Saver.txt"));
  41.  
  42. String xxx = inputField.getText();
  43. outwrite.println(xxx);
  44. return true;
  45. }
  46. return super.handleEvent(event);
  47. }
  48. }
where must i put the throw Exception,if i haven't had the file saver.txt????
Last edited by ~s.o.s~; Oct 21st, 2008 at 10:39 am. Reason: Added code tags, learn to use them.
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 7,617
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 466
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

Re: throw exception

 
0
  #2
Oct 21st, 2008
> where must i put the throw Exception,if i haven't had the file saver.txt????

If you don't have ``saver.txt'', it will automatically be created given that sufficient privileges are available.
I don't accept change; I don't deserve to live.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,160
Reputation: dickersonka will become famous soon enough dickersonka will become famous soon enough 
Solved Threads: 137
dickersonka dickersonka is offline Offline
Veteran Poster

Re: throw exception

 
0
  #3
Oct 21st, 2008
Not sure if this what you are asking, but you'll need this at the top of the method signature

  1. public boolean handleEvent(Event event) throws IOException {
  2.  
  3. }
Custom Application & Software Development
www.houseshark.net
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC