diff --git a/NameGUI.class b/NameGUI.class index a8cee26..96b2d45 100644 Binary files a/NameGUI.class and b/NameGUI.class differ diff --git a/NameGUI.java b/NameGUI.java index 21fe929..6a2d8a9 100644 --- a/NameGUI.java +++ b/NameGUI.java @@ -21,6 +21,7 @@ class NameGUI extends JFrame implements ActionListener{ JButton btnSample = new JButton("Sample Button"); JButton btnQuit = new JButton("Quit"); JButton btnSwap = new JButton("Swap"); + JButton btnChiang = new JButton("Show My Name"); //create sample textboxes txtWord1 = new JTextField(15); @@ -36,12 +37,14 @@ class NameGUI extends JFrame implements ActionListener{ btnQuit.addActionListener(this); btnSwap.setActionCommand("swap"); btnSwap.addActionListener(this); + btnChiang.setActionCommand("name"); + btnChiang.addActionListener(this); //Add components to proper panels panelTop.add(btnSample); panelTop.add(btnQuit); - //panelMiddle.add(btnYourButton); + panelMiddle.add(btnChiang); panelBottom.add(lblSwap); panelBottom.add(btnSwap); @@ -122,6 +125,9 @@ public void actionPerformed(ActionEvent evt) { case "help" : JOptionPane.showMessageDialog(this,"There is no help for you.","Sorry",JOptionPane.WARNING_MESSAGE); break; + case "name": + JOptionPane.showMessageDialog(this,"Chun-Wei Chiang","My name",JOptionPane.PLAIN_MESSAGE); + break; } } @@ -130,4 +136,4 @@ public static void main(String [] args){ new NameGUI(); } -} \ No newline at end of file +}