All pastes #2062711 Raw Edit

elllliiaaaa

public text v1 · immutable
#2062711 ·published 2011-05-17 16:57 UTC
rendered paste body
public class Grafica extends Frame implements WindowListener, MouseListener, ActionListener {

    private final TextArea t1;
    private final Panel p1;
    private final Button b1;
    private final Label l1;

    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);

        l1 = new Label();
        p1.add(l1);

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

        
        
        addComponentListener(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(l1);
        } else {
            t1.getText();
            try {
                FileWriter f = new FileWriter("C:\\prova.txt");
                f.write("" + t1.getText());
                System.out.println(t1.getText());
                f.flush();
                f.close();
            } catch (IOException ex) {
                Logger.getLogger(Grafica.class.getName()).log(Level.SEVERE, null, ex);

            }
        }
    }
}