🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #16782

Re: can't catch IOExceptions!!!!

#16782
From: Marcel Hell
Date: Tue, 19 Jan 1999 00:00
123 lines
4512 bytes
Thanks, Tor!
But now I have the same problem one step higher, when the actionPerformed
method is called!

Here's the code:
public class Frame3 extends JFrame {
  XYLayout xYLayout1 = new XYLayout();
  Label label1 = new Label();
  TextField textField1 = new TextField();
  Label label2 = new Label();
  TextField textField2 = new TextField();
  JButton jButton1 = new JButton();
  jclass.bwt.JCSeparator jCSeparator1 = new jclass.bwt.JCSeparator();
  JButton jButton2 = new JButton();
  JButton jButton3 = new JButton();
  TextField textField3 = new TextField();


  public Frame3() {
   enableEvents(AWTEvent.WINDOW_EVENT_MASK);
    try  {
      jbInit();
    }
    catch (Exception e) {
      e.printStackTrace();
    }
  }
//Component initialization


  private void jbInit()  {
    this.getContentPane().setLayout(xYLayout1);
    this.setSize(new Dimension(400, 300));
    label1.setFont(new Font("Courier", 1, 14));
    label1.setText("Quelldatei:");
    textField1.setText("<Quelldatei>");
    label2.setFont(new Font("Courier", 1, 14));
    label2.setText("Zieldatei:");
    textField2.setText("<Zieldatei>");
    jButton1.setText("jButton1");
    jButton1.setLabel("Back Button");
    jCSeparator1.setShadowThickness(3);
    jCSeparator1.setTraversable(true);
    jButton2.setText("jButton2");
    jButton2.setLabel("Kodieren");
    jButton2.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(ActionEvent e) {
        jButton2_actionPerformed (e);
//   now here                                 ^^ is the unreported
IOException!!!!
//what_is_the_way_to_do_it???????????????????????

      }
    });
    jButton3.setText("jButton3");
    jButton3.setLabel("Dekodieren");
    textField3.setEditable(false);
    jButton1.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(ActionEvent e) {
        jButton1_actionPerformed(e);
      }
    });
    textField1.addMouseListener(new java.awt.event.MouseAdapter() {
      public void mouseClicked(MouseEvent e) {
        textField1_mousePressed(e);
      }

    });
    this.setTitle("Willkommen zum Kodierungsprogramm");
    this.setBackground(new Color(150, 242, 170));
    this.getContentPane().add(label1, new XYConstraints(13, 89, 91, -1));
    this.getContentPane().add(textField1, new XYConstraints(261, 90, 114,
26));
    this.getContentPane().add(label2, new XYConstraints(14, 137, 93, 31));
    this.getContentPane().add(textField2, new XYConstraints(261, 142, 113,
26));
    this.getContentPane().add(jButton1, new XYConstraints(16, 235, 102,
30));
    this.getContentPane().add(jCSeparator1, new XYConstraints(12, 218, 369,
3));
    this.getContentPane().add(jButton2, new XYConstraints(134, 234, 94,
31));
    this.getContentPane().add(jButton3, new XYConstraints(249, 233, 103,
32));
    this.getContentPane().add(textField3, new XYConstraints(49, 201, 240,
16));
  }

  void textField1_mousePressed(MouseEvent e) {
    textField1.setText("");
  }

  void jButton1_actionPerformed(ActionEvent e) {
    Frame1 frame = new Frame1();
    frame.show();
    this.setVisible(false);
    }

  void jButton2_actionPerformed(ActionEvent e)throws IOException {
    String que= textField1.getText();
    String zie= textField2.getText();
    kodiere(que,zie);
    }
 public static void kodiere(String quelldatei, String zieldatei) throws
IOException {

 DataInput quelle = new DataInputStream(new FileInputStream(quelldatei));
 DataOutput ziel = new DataOutputStream(new FileOutputStream(zieldatei));
try {
 while(true){
 byte b = (byte) quelle.readByte(); //Einlesen eines Bytes aus der Quelle

 b = (byte) ((b+3)%256);
 ziel.writeByte(b);} }

catch (EOFException e) //End of source.
{System.out.println("Alles klar! Kodierung beendet."); }
catch (IOException e) {}
}
}


Now: where should I insert the ..throws IOException now??
Technical Details
Message-ID: <782ct6$bt87@forums.borland.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <782105$bbo8@forums.borland.com> <uognv4bw8.fsf@sds.no>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,986058edfa4b9616
X-Google-Attributes: gidf74b3,public
From: "Marcel Hell" <MLP.HELL@student.unimaas.nl>
Subject: Re: can't catch IOExceptions!!!!
Date: 1999/01/19
Message-ID: <782ct6$bt87@forums.borland.com>
X-Deja-AN: 434456902
References: <782105$bbo8@forums.borland.com> <uognv4bw8.fsf@sds.no>
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3
Organization: Another Netscape Collabra Server User
Newsgroups: borland.public.jbuilder.java.language