1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
| package afli;
import javax.swing.*;
import java.awt.*;
import com.borland.jbcl.layout.*;
import java.awt.event.*;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.FileNotFoundException;
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2009</p>
* <p>Company: FAC De Science De Monastir
* @author AFLI HAITHEM
* @version 1.0
*/
public class Frame1 extends JFrame {
XYLayout xYLayout1 = new XYLayout();
JButton jButton1 = new JButton();
JButton jButton2 = new JButton();
JTextArea jTextArea1 = new JTextArea();
public Frame1() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
Frame1 frame1 = new Frame1();
frame1.setSize(700,700);
frame1.setVisible(true);
}
private void jbInit() throws Exception {
jButton1.setText("Raffrichir");
jButton1.addActionListener(new Frame1_jButton1_actionAdapter(this));
this.getContentPane().setLayout(xYLayout1);
jButton2.setText("Quitter");
jButton2.addActionListener(new Frame1_jButton2_actionAdapter(this));
xYLayout1.setWidth(606);
xYLayout1.setHeight(610);
this.getContentPane().add(jTextArea1, new XYConstraints(6, 6, 593, 550));
this.getContentPane().add(jButton2, new XYConstraints(457, 563, 141, 43));
this.getContentPane().add(jButton1, new XYConstraints(8, 563, 149, 40));
}
void jButton1_actionPerformed(ActionEvent e) {
File f=new File("text.txt");
char buff[]=new char[Integer.parseInt(""+f.length())];
try {
FileReader f1 = new FileReader(f);
try {
f1.read(buff);
String tmp=String.valueOf(buff);
this.jTextArea1.setText(tmp);
this.repaint();
}
catch (IOException ex1) {
}
}
catch (FileNotFoundException ex) {
}
}
void jButton2_actionPerformed(ActionEvent e) {
if(e.getSource()==jButton2)
System.exit(0);
}
}
class Frame1_jButton1_actionAdapter implements java.awt.event.ActionListener {
Frame1 adaptee;
Frame1_jButton1_actionAdapter(Frame1 adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton1_actionPerformed(e);
}
}
class Frame1_jButton2_actionAdapter implements java.awt.event.ActionListener {
Frame1 adaptee;
Frame1_jButton2_actionAdapter(Frame1 adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton2_actionPerformed(e);
}
} |
Partager