import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Benvenuto {
JFrame f1= new JFrame("Benvenuto");
JFrame f2=new JFrame();
JTextField t1=new JTextField();
JButton b1=new JButton("vai!");
JLabel l1=new JLabel();
JLabel l2=new JLabel();
public void apriFinestra(){
f1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f1.add(BorderLayout.NORTH,t1);
b1.addActionListener(new Bottone());
f1.add(BorderLayout.SOUTH,b1);
f1.setSize(200,100);
f1.setVisible(true);
}
class Bottone implements ActionListener{
public void actionPerformed(ActionEvent e){
String nome=t1.getText();
l1.setText(nome+" Auguri!");
f2.add(BorderLayout.CENTER,l1);
f2.pack();
f2.setVisible(true);
}
}
public static void main(String Args[]){
Benvenuto b=new Benvenuto();
b.apriFinestra();
}
}
Commenti
Posta un commento