File: overload.java

package info (click to toggle)
jswat 1.7-2
  • links: PTS
  • area: contrib
  • in suites: etch, etch-m68k
  • size: 5,656 kB
  • ctags: 3,210
  • sloc: java: 24,683; xml: 130; makefile: 59; sh: 21
file content (56 lines) | stat: -rw-r--r-- 1,487 bytes parent folder | download
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// A sample class to test the debugger.
// $Author: nfiedler $ $Date: 2002-10-13 00:03:33 -0700 (Sun, 13 Oct 2002) $ $Rev: 604 $

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;

public class overload implements ActionListener {
    private JFrame mainWin;
    private JButton button1;
    private JButton button2;

    public overload() {
        mainWin = new JFrame("b tester");
        Container pane = mainWin.getContentPane();
        pane.setLayout(new BorderLayout());

        button1 = new JButton("Push me");
        pane.add(button1, "North");
        button1.addActionListener(this);

        button2 = new JButton("No, push me instead");
        pane.add(button2, "South");
        button2.addActionListener(this);

        mainWin.addWindowListener(new WindowAdapter() {
		public void windowClosing(WindowEvent e) {
		    System.exit(0);
		}
	    });
        mainWin.setSize(300, 100);
        mainWin.show();
    }

    public void actionPerformed(ActionEvent e) {
        Object button = e.getSource();
        if (button == button1) {
            overloadedMethod();
        } else {
            overloadedMethod("Second button was pushed");
        }
    }

    public void overloadedMethod() {
        System.out.println("First button was pushed.");
    }

    public void overloadedMethod(String msg) {
        System.out.println(msg);
    }

    public static void main(String[] args) {
        new overload();
    }
}