File: outer.java

package info (click to toggle)
jswat2 2.37-1
  • links: PTS
  • area: contrib
  • in suites: etch, etch-m68k
  • size: 7,092 kB
  • ctags: 5,592
  • sloc: java: 43,576; xml: 1,086; sh: 66; makefile: 57
file content (82 lines) | stat: -rw-r--r-- 1,805 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// An inner class test for JSwat.
// $Id: outer.java 1113 2004-01-25 22:25:32Z nfiedler $

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

/**
 * Test for inner class handling.
 *
 * @author  Nathan Fiedler
 */
public class outer implements ActionListener {
    /** inner class instance */
    protected inner inside;

    /**
     * Constructor.
     */
    public outer() {
        inside = new inner();

        JFrame mainWin = new JFrame("inner class tester");
        Container pane = mainWin.getContentPane();

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

        mainWin.addWindowListener(new WindowAdapter() {
		public void windowClosing(WindowEvent e) {
                    System.out.println("exiting tester...");
		    System.exit(0);
		}
	    });
        mainWin.setSize(200, 100);
        mainWin.setVisible(true);
    }

    /**
     * Invoked when an action occurs.
     *
     * @param  e  action event.
     */
    public void actionPerformed(ActionEvent e) {
        inside.pushed();
        outside.amethod(10, 20);
    }

    /**
     * Main method.
     */
    public static void main(String[] args) {
        new outer();
    }

    /**
     * The inner class.
     */
    protected class inner {
        public void pushed() {
            System.out.println("button pushed");
        }
    }; // parser test
}

// Non-public class defined in the same source file to test possible
// bug with regards to the source code single-stepping highlighter.
class outside {

    /**
     * A test method.
     */
    public static int amethod(int i, int j) {
        int k = i * j;
        i++;
        j++;
        k += i + j;
        return k;
    }
}; // parser test