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
| import java.awt.*;
import javax.swing.*;
public class test extends JFrame{
public test{
JTextField c = new JTextField();
JButton un = new JButton();
un.setText("un");
un.addActionListener(new java.awt.event.ActionListener(){public void actionPerformed(java.awt.event.ActionEvent evt){
c.setText("1");
}
});
getContentPane().add(c);
getContentPane().setLayout(new BoxLayout(getContentPane(),BoxLayout.Y_AXIS));
getContentPane().add(un,FlowLayout.CENTER);
pack();
}
public static void main(String[] args) {
test t = new test();
t.setVisible(true);
t.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
} |