All pastes #2062662 Raw Edit

elllliiaaaa

public text v1 · immutable
#2062662 ·published 2011-05-17 16:27 UTC
rendered paste body
import java.awt.Button;
import java.awt.Color;
import java.awt.Frame;
import java.awt.Panel;
import java.awt.TextArea;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author User
 */
public class Grafica extends Frame implements WindowListener, MouseListener, ActionListener {

    private final TextArea t1;
    private final Panel p1;
    private final Button b1;
    private final TextArea t2;

    public Grafica() {
        super("Blocco note");



        setLayout(null);
        setLocation(0, 0);
        setResizable(false);
        setSize(800, 600);

        p1 = new Panel();
        p1.setSize(500, 200);
        p1.setLocation(50, 30);
        p1.setBackground(Color.red);


        t1 = new TextArea();
        t1.setSize(50, 50);
        t1.setLocation(80, 40);
        p1.add(t1);

        t2 = new TextArea();
        p1.add(t2);

        b1 = new Button("Salva");
        b1.setSize(50, 20);
        b1.setLocation(380 / 2, 180 + 30);
        p1.add(b1);


        add(p1);
        addWindowListener(this);
        setBackground(Color.CYAN);
        setVisible(true);
    }

    public void windowOpened(WindowEvent e) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void windowClosing(WindowEvent e) {
        dispose();
    }

    public void windowClosed(WindowEvent e) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void windowIconified(WindowEvent e) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void windowDeiconified(WindowEvent e) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void windowActivated(WindowEvent e) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void windowDeactivated(WindowEvent e) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void mouseClicked(MouseEvent e) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void mousePressed(MouseEvent e) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void mouseReleased(MouseEvent e) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void mouseEntered(MouseEvent e) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void mouseExited(MouseEvent e) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void actionPerformed(ActionEvent e) {
        if (e.getSource() != b1) {
            p1.remove(t2);
        } else {
            t1.getText();
            try {
                FileWriter f = new FileWriter("C:\\prova.txt");
                f.write("" + t1.getText());
                f.flush();
                f.close();
            } catch (IOException ex) {
                Logger.getLogger(Grafica.class.getName()).log(Level.SEVERE, null, ex);

            }
        }
    }
}