Save this file as Profile.java.
01 | import javax.swing.*; |
02 | import java.awt.*; |
03 | import java.awt.event.*; |
04 |
05 | public class Profile extends JFrame { |
06 | public Profile() { |
07 | JFrame frame = new JFrame(); |
08 | Container c = getContentPane(); |
09 | String name = "Name: Merry Go Round" ; |
10 | String address = "Address: Carnival" ; |
11 | String telno = "Telno: 14344" ; |
12 | String profile = name + "\n" + address + "\n" + telno; |
13 | JTextArea area = new JTextArea(profile); |
14 |
15 | setBounds( 400 , 300 , 200 , 100 ); |
16 | setTitle( "Simple Profile" ); |
17 |
18 | JButton button = new JButton( "Close" ); |
19 |
20 | c.add (area, BorderLayout.NORTH); |
21 | c.add(button, BorderLayout.CENTER); |
22 |
23 | button.addActionListener( new ActionListener() { |
24 | public void actionPerformed(ActionEvent e) {buttonAction();} |
25 | }); |
26 |
27 | show(); |
28 | } |
29 |
30 | void buttonAction() { |
31 | System.exit( 0 ); |
32 | } |
33 |
34 | public static void main(String[]args) { |
35 | Profile show = new Profile(); |
36 | show.setResizable( false ); |
37 |
38 | } |
39 | } |
0 comments:
Post a Comment