├── .gitattributes
├── .gitignore
├── README.txt
├── doc
├── allclasses-frame.html
├── allclasses-noframe.html
├── com
│ └── mtk
│ │ └── calculator
│ │ ├── CalcLauncher.html
│ │ ├── Calculator.OperatorAction.html
│ │ ├── Calculator.html
│ │ ├── class-use
│ │ ├── CalcLauncher.html
│ │ ├── Calculator.OperatorAction.html
│ │ └── Calculator.html
│ │ ├── package-frame.html
│ │ ├── package-summary.html
│ │ ├── package-tree.html
│ │ └── package-use.html
├── constant-values.html
├── deprecated-list.html
├── help-doc.html
├── index-files
│ ├── index-1.html
│ ├── index-2.html
│ ├── index-3.html
│ ├── index-4.html
│ ├── index-5.html
│ ├── index-6.html
│ └── index-7.html
├── index.html
├── overview-tree.html
├── package-list
├── resources
│ ├── background.gif
│ ├── tab.gif
│ ├── titlebar.gif
│ └── titlebar_end.gif
└── stylesheet.css
├── javadoc.xml
└── src
└── com
└── mtk
└── calculator
├── CalcLauncher.java
└── Calculator.java
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 | *.sln merge=union
7 | *.csproj merge=union
8 | *.vbproj merge=union
9 | *.fsproj merge=union
10 | *.dbproj merge=union
11 |
12 | # Standard to msysgit
13 | *.doc diff=astextplain
14 | *.DOC diff=astextplain
15 | *.docx diff=astextplain
16 | *.DOCX diff=astextplain
17 | *.dot diff=astextplain
18 | *.DOT diff=astextplain
19 | *.pdf diff=astextplain
20 | *.PDF diff=astextplain
21 | *.rtf diff=astextplain
22 | *.RTF diff=astextplain
23 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | #################
2 | ## Eclipse
3 | #################
4 |
5 | *.pydevproject
6 | .project
7 | .metadata
8 | bin/
9 | tmp/
10 | *.tmp
11 | *.bak
12 | *.swp
13 | *~.nib
14 | local.properties
15 | .classpath
16 | .settings/
17 | .loadpath
18 |
19 | # External tool builders
20 | .externalToolBuilders/
21 |
22 | # Locally stored "Eclipse launch configurations"
23 | *.launch
24 |
25 | # CDT-specific
26 | .cproject
27 |
28 | # PDT-specific
29 | .buildpath
30 |
31 |
32 | #################
33 | ## Visual Studio
34 | #################
35 |
36 | ## Ignore Visual Studio temporary files, build results, and
37 | ## files generated by popular Visual Studio add-ons.
38 |
39 | # User-specific files
40 | *.suo
41 | *.user
42 | *.sln.docstates
43 |
44 | # Build results
45 | [Dd]ebug/
46 | [Rr]elease/
47 | *_i.c
48 | *_p.c
49 | *.ilk
50 | *.meta
51 | *.obj
52 | *.pch
53 | *.pdb
54 | *.pgc
55 | *.pgd
56 | *.rsp
57 | *.sbr
58 | *.tlb
59 | *.tli
60 | *.tlh
61 | *.tmp
62 | *.vspscc
63 | .builds
64 | *.dotCover
65 |
66 | ## TODO: If you have NuGet Package Restore enabled, uncomment this
67 | #packages/
68 |
69 | # Visual C++ cache files
70 | ipch/
71 | *.aps
72 | *.ncb
73 | *.opensdf
74 | *.sdf
75 |
76 | # Visual Studio profiler
77 | *.psess
78 | *.vsp
79 |
80 | # ReSharper is a .NET coding add-in
81 | _ReSharper*
82 |
83 | # Installshield output folder
84 | [Ee]xpress
85 |
86 | # DocProject is a documentation generator add-in
87 | DocProject/buildhelp/
88 | DocProject/Help/*.HxT
89 | DocProject/Help/*.HxC
90 | DocProject/Help/*.hhc
91 | DocProject/Help/*.hhk
92 | DocProject/Help/*.hhp
93 | DocProject/Help/Html2
94 | DocProject/Help/html
95 |
96 | # Click-Once directory
97 | publish
98 |
99 | # Others
100 | [Bb]in
101 | [Oo]bj
102 | sql
103 | TestResults
104 | *.Cache
105 | ClientBin
106 | stylecop.*
107 | ~$*
108 | *.dbmdl
109 | Generated_Code #added for RIA/Silverlight projects
110 |
111 | # Backup & report files from converting an old project file to a newer
112 | # Visual Studio version. Backup files are not needed, because we have git ;-)
113 | _UpgradeReport_Files/
114 | Backup*/
115 | UpgradeLog*.XML
116 |
117 |
118 |
119 | ############
120 | ## Windows
121 | ############
122 |
123 | # Windows image file caches
124 | Thumbs.db
125 |
126 | # Folder config file
127 | Desktop.ini
128 |
129 |
130 | #############
131 | ## Python
132 | #############
133 |
134 | *.py[co]
135 |
136 | # Packages
137 | *.egg
138 | *.egg-info
139 | dist
140 | build
141 | eggs
142 | parts
143 | bin
144 | var
145 | sdist
146 | develop-eggs
147 | .installed.cfg
148 |
149 | # Installer logs
150 | pip-log.txt
151 |
152 | # Unit test / coverage reports
153 | .coverage
154 | .tox
155 |
156 | #Translations
157 | *.mo
158 |
159 | #Mr Developer
160 | .mr.developer.cfg
161 |
162 | # Mac crap
163 | .DS_Store
164 |
--------------------------------------------------------------------------------
/README.txt:
--------------------------------------------------------------------------------
1 | README.txt
2 |
3 | An amazing calculator which was made using java by importing swing/awt.
4 |
5 | The main class is ClacLauncher
6 |
--------------------------------------------------------------------------------
/doc/allclasses-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | All Classes
7 |
8 |
9 |
10 |
11 | All Classes
12 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/doc/allclasses-noframe.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | All Classes
7 |
8 |
9 |
10 |
11 | All Classes
12 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/doc/com/mtk/calculator/CalcLauncher.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | CalcLauncher
7 |
8 |
9 |
10 |
11 |
17 |
18 | JavaScript is disabled on your browser.
19 |
20 |
21 |
36 |
37 |
38 | Prev Class
39 | Next Class
40 |
41 |
45 |
48 |
49 |
59 |
60 |
61 |
62 | Summary:
63 | Nested |
64 | Field |
65 | Constr |
66 | Method
67 |
68 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
84 |
85 |
86 | java.lang.Object
87 |
88 |
89 | com.mtk.calculator.CalcLauncher
90 |
91 |
92 |
93 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 | Constructor Summary
118 |
119 | Constructors
120 |
121 | Constructor and Description
122 |
123 |
124 | CalcLauncher ()
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 | Method Summary
135 |
136 | Methods
137 |
138 | Modifier and Type
139 | Method and Description
140 |
141 |
142 | static void
143 | main (java.lang.String[] args)
144 |
145 |
146 |
147 |
148 |
149 |
150 | Methods inherited from class java.lang.Object
151 | clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 | Constructor Detail
167 |
168 |
169 |
170 |
171 |
172 | CalcLauncher
173 | public CalcLauncher()
174 |
175 |
176 |
177 |
178 |
179 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
217 |
218 |
219 | Prev Class
220 | Next Class
221 |
222 |
226 |
229 |
230 |
240 |
241 |
242 |
243 | Summary:
244 | Nested |
245 | Field |
246 | Constr |
247 | Method
248 |
249 |
250 | Detail:
251 | Field |
252 | Constr |
253 | Method
254 |
255 |
256 |
257 |
258 |
259 |
260 |
261 |
262 |
--------------------------------------------------------------------------------
/doc/com/mtk/calculator/Calculator.OperatorAction.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Calculator.OperatorAction
7 |
8 |
9 |
10 |
11 |
17 |
18 | JavaScript is disabled on your browser.
19 |
20 |
21 |
36 |
37 |
41 |
45 |
48 |
49 |
59 |
60 |
75 |
76 |
77 |
78 |
79 |
80 |
84 |
85 |
86 | java.lang.Object
87 |
88 |
89 | com.mtk.calculator.Calculator.OperatorAction
90 |
91 |
92 |
93 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 | Field Summary
123 |
124 | Fields
125 |
126 | Modifier and Type
127 | Field and Description
128 |
129 |
130 | private int
131 | operator
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 | Constructor Summary
142 |
143 | Constructors
144 |
145 | Constructor and Description
146 |
147 |
148 | Calculator.OperatorAction (int operation)
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 | Method Summary
159 |
160 | Methods
161 |
162 | Modifier and Type
163 | Method and Description
164 |
165 |
166 | void
167 | actionPerformed (java.awt.event.ActionEvent event)
168 |
169 |
170 |
171 |
172 |
173 |
174 | Methods inherited from class java.lang.Object
175 | clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 | Field Detail
191 |
192 |
193 |
194 |
195 |
196 | operator
197 | private int operator
198 |
199 |
200 |
201 |
202 |
203 |
220 |
221 |
241 |
242 |
243 |
244 |
245 |
246 |
247 |
262 |
263 |
267 |
271 |
274 |
275 |
285 |
286 |
301 |
302 |
303 |
304 |
305 |
306 |
307 |
--------------------------------------------------------------------------------
/doc/com/mtk/calculator/Calculator.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Calculator
7 |
8 |
9 |
10 |
11 |
17 |
18 | JavaScript is disabled on your browser.
19 |
20 |
21 |
36 |
37 |
41 |
45 |
48 |
49 |
59 |
60 |
75 |
76 |
77 |
78 |
79 |
80 |
84 |
85 |
86 | java.lang.Object
87 |
88 |
89 | com.mtk.calculator.Calculator
90 |
91 |
92 |
93 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 | Nested Class Summary
121 |
122 | Nested Classes
123 |
124 | Modifier and Type
125 | Class and Description
126 |
127 |
128 | private class
129 | Calculator.OperatorAction
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 | Field Summary
140 |
141 | Fields
142 |
143 | Modifier and Type
144 | Field and Description
145 |
146 |
147 | (package private) javax.swing.JPanel
148 | buttonPanel
149 |
150 |
151 | (package private) int
152 | calcOperation
153 |
154 |
155 | (package private) int
156 | currentCalc
157 |
158 |
159 | (package private) javax.swing.JFrame
160 | guiFrame
161 |
162 |
163 | (package private) javax.swing.JTextField
164 | numberCalc
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 | Constructor Summary
175 |
176 | Constructors
177 |
178 | Constructor and Description
179 |
180 |
181 | Calculator ()
182 | Consturct a new Calculator Frame.
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 | Method Summary
194 |
195 | Methods
196 |
197 | Modifier and Type
198 | Method and Description
199 |
200 |
201 | void
202 | actionPerformed (java.awt.event.ActionEvent event)
203 |
204 |
205 | private void
206 | addButton (java.awt.Container parent,
207 | java.lang.String name)
208 |
209 |
210 |
211 |
212 |
213 |
214 | Methods inherited from class java.lang.Object
215 | clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
278 |
279 |
298 |
299 |
330 |
331 |
332 |
333 |
334 |
335 |
336 |
351 |
352 |
356 |
360 |
363 |
364 |
374 |
375 |
390 |
391 |
392 |
393 |
394 |
395 |
396 |
--------------------------------------------------------------------------------
/doc/com/mtk/calculator/class-use/CalcLauncher.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Uses of Class com.mtk.calculator.CalcLauncher
7 |
8 |
9 |
10 |
11 |
17 |
18 | JavaScript is disabled on your browser.
19 |
20 |
21 |
36 |
63 |
64 |
67 | No usage of com.mtk.calculator.CalcLauncher
68 |
69 |
84 |
111 |
112 |
113 |
114 |
--------------------------------------------------------------------------------
/doc/com/mtk/calculator/class-use/Calculator.OperatorAction.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Uses of Class com.mtk.calculator.Calculator.OperatorAction
7 |
8 |
9 |
10 |
11 |
17 |
18 | JavaScript is disabled on your browser.
19 |
20 |
21 |
36 |
63 |
64 |
67 | No usage of com.mtk.calculator.Calculator.OperatorAction
68 |
69 |
84 |
111 |
112 |
113 |
114 |
--------------------------------------------------------------------------------
/doc/com/mtk/calculator/class-use/Calculator.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Uses of Class com.mtk.calculator.Calculator
7 |
8 |
9 |
10 |
11 |
17 |
18 | JavaScript is disabled on your browser.
19 |
20 |
21 |
36 |
63 |
64 |
67 | No usage of com.mtk.calculator.Calculator
68 |
69 |
84 |
111 |
112 |
113 |
114 |
--------------------------------------------------------------------------------
/doc/com/mtk/calculator/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | com.mtk.calculator
7 |
8 |
9 |
10 |
11 |
12 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/doc/com/mtk/calculator/package-summary.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | com.mtk.calculator
7 |
8 |
9 |
10 |
11 |
17 |
18 | JavaScript is disabled on your browser.
19 |
20 |
21 |
36 |
37 |
38 | Prev Package
39 | Next Package
40 |
41 |
45 |
48 |
49 |
59 |
60 |
61 |
62 |
63 |
64 |
67 |
68 |
69 |
70 |
71 | Class Summary
72 |
73 | Class
74 | Description
75 |
76 |
77 |
78 | CalcLauncher
79 |
80 | The main launcher for java calculator.
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
104 |
105 |
106 | Prev Package
107 | Next Package
108 |
109 |
113 |
116 |
117 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
--------------------------------------------------------------------------------
/doc/com/mtk/calculator/package-tree.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | com.mtk.calculator Class Hierarchy
7 |
8 |
9 |
10 |
11 |
17 |
18 | JavaScript is disabled on your browser.
19 |
20 |
21 |
36 |
63 |
64 |
67 |
68 |
Class Hierarchy
69 |
70 | java.lang.Object
71 |
74 |
75 |
76 |
77 |
78 |
93 |
120 |
121 |
122 |
123 |
--------------------------------------------------------------------------------
/doc/com/mtk/calculator/package-use.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Uses of Package com.mtk.calculator
7 |
8 |
9 |
10 |
11 |
17 |
18 | JavaScript is disabled on your browser.
19 |
20 |
21 |
36 |
63 |
64 |
67 | No usage of com.mtk.calculator
68 |
69 |
84 |
111 |
112 |
113 |
114 |
--------------------------------------------------------------------------------
/doc/constant-values.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Constant Field Values
7 |
8 |
9 |
10 |
11 |
17 |
18 | JavaScript is disabled on your browser.
19 |
20 |
21 |
36 |
63 |
64 |
68 |
69 |
84 |
111 |
112 |
113 |
114 |
--------------------------------------------------------------------------------
/doc/deprecated-list.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Deprecated List
7 |
8 |
9 |
10 |
11 |
17 |
18 | JavaScript is disabled on your browser.
19 |
20 |
21 |
36 |
63 |
64 |
68 |
69 |
84 |
111 |
112 |
113 |
114 |
--------------------------------------------------------------------------------
/doc/help-doc.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | API Help
7 |
8 |
9 |
10 |
11 |
17 |
18 | JavaScript is disabled on your browser.
19 |
20 |
21 |
36 |
63 |
64 |
68 |
69 |
70 |
71 | Package
72 | Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain six categories:
73 |
74 | Interfaces (italic)
75 | Classes
76 | Enums
77 | Exceptions
78 | Errors
79 | Annotation Types
80 |
81 |
82 |
83 | Class/Interface
84 | Each class, interface, nested class and nested interface has its own separate page. Each of these pages has three sections consisting of a class/interface description, summary tables, and detailed member descriptions:
85 |
86 | Class inheritance diagram
87 | Direct Subclasses
88 | All Known Subinterfaces
89 | All Known Implementing Classes
90 | Class/interface declaration
91 | Class/interface description
92 |
93 |
94 | Nested Class Summary
95 | Field Summary
96 | Constructor Summary
97 | Method Summary
98 |
99 |
100 | Field Detail
101 | Constructor Detail
102 | Method Detail
103 |
104 | Each summary entry contains the first sentence from the detailed description for that item. The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer.
105 |
106 |
107 | Annotation Type
108 | Each annotation type has its own separate page with the following sections:
109 |
110 | Annotation Type declaration
111 | Annotation Type description
112 | Required Element Summary
113 | Optional Element Summary
114 | Element Detail
115 |
116 |
117 |
118 | Enum
119 | Each enum has its own separate page with the following sections:
120 |
121 | Enum declaration
122 | Enum description
123 | Enum Constant Summary
124 | Enum Constant Detail
125 |
126 |
127 |
128 | Use
129 | Each documented package, class and interface has its own Use page. This page describes what packages, classes, methods, constructors and fields use any part of the given class or package. Given a class or interface A, its Use page includes subclasses of A, fields declared as A, methods that return A, and methods and constructors with parameters of type A. You can access this page by first going to the package, class or interface, then clicking on the "Use" link in the navigation bar.
130 |
131 |
132 | Tree (Class Hierarchy)
133 | There is a Class Hierarchy page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. The classes are organized by inheritance structure starting with java.lang.Object
. The interfaces do not inherit from java.lang.Object
.
134 |
135 | When viewing the Overview page, clicking on "Tree" displays the hierarchy for all packages.
136 | When viewing a particular package, class or interface page, clicking "Tree" displays the hierarchy for only that package.
137 |
138 |
139 |
140 | Deprecated API
141 | The Deprecated API page lists all of the API that have been deprecated. A deprecated API is not recommended for use, generally due to improvements, and a replacement API is usually given. Deprecated APIs may be removed in future implementations.
142 |
143 |
144 | Index
145 | The Index contains an alphabetic list of all classes, interfaces, constructors, methods, and fields.
146 |
147 |
148 | Prev/Next
149 | These links take you to the next or previous class, interface, package, or related page.
150 |
151 |
152 | Frames/No Frames
153 | These links show and hide the HTML frames. All pages are available with or without frames.
154 |
155 |
156 | All Classes
157 | The All Classes link shows all classes and interfaces except non-static nested types.
158 |
159 |
160 | Serialized Form
161 | Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See also" section of the class description.
162 |
163 |
164 | Constant Field Values
165 | The <a href="constant-values.html">Constant Field Values</a> page lists the static final fields and their values.
166 |
167 |
168 |
This help file applies to API documentation generated using the standard doclet.
169 |
170 |
185 |
186 |
187 | Prev
188 | Next
189 |
190 |
194 |
197 |
198 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
--------------------------------------------------------------------------------
/doc/index-files/index-1.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | C-Index
7 |
8 |
9 |
10 |
11 |
17 |
18 | JavaScript is disabled on your browser.
19 |
20 |
21 |
36 |
63 |
64 | C M
65 |
66 |
67 |
C
68 |
69 | CalcLauncher - Class in com.mtk.calculator
70 |
71 | The main launcher for java calculator.
72 |
73 | CalcLauncher() - Constructor for class com.mtk.calculator.CalcLauncher
74 |
75 | com.mtk.calculator - package com.mtk.calculator
76 |
77 |
78 |
C M
79 |
80 |
95 |
122 |
123 |
124 |
125 |
--------------------------------------------------------------------------------
/doc/index-files/index-2.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | M-Index
7 |
8 |
9 |
10 |
11 |
17 |
18 | JavaScript is disabled on your browser.
19 |
20 |
21 |
36 |
63 |
64 | C M
65 |
66 |
67 |
M
68 |
69 | main(String[]) - Static method in class com.mtk.calculator.CalcLauncher
70 |
71 |
72 |
C M
73 |
74 |
89 |
116 |
117 |
118 |
119 |
--------------------------------------------------------------------------------
/doc/index-files/index-3.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | C-Index
7 |
8 |
9 |
10 |
11 |
17 |
18 | JavaScript is disabled on your browser.
19 |
20 |
21 |
36 |
63 |
64 | A B C G N O
65 |
66 |
67 |
C
68 |
69 | calcOperation - Variable in class com.mtk.calculator.Calculator
70 |
71 | Calculator - Class in com.mtk.calculator
72 |
73 | Calculator() - Constructor for class com.mtk.calculator.Calculator
74 |
75 | Consturct a new Calculator Frame.
76 |
77 | Calculator.OperatorAction - Class in com.mtk.calculator
78 |
79 | Calculator.OperatorAction(int) - Constructor for class com.mtk.calculator.Calculator.OperatorAction
80 |
81 | com.mtk.calculator - package com.mtk.calculator
82 |
83 | currentCalc - Variable in class com.mtk.calculator.Calculator
84 |
85 |
86 |
A B C G N O
87 |
88 |
103 |
130 |
131 |
132 |
133 |
--------------------------------------------------------------------------------
/doc/index-files/index-4.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | G-Index
7 |
8 |
9 |
10 |
11 |
17 |
18 | JavaScript is disabled on your browser.
19 |
20 |
21 |
36 |
63 |
64 | A B C G N O
65 |
66 |
67 |
G
68 |
69 | guiFrame - Variable in class com.mtk.calculator.Calculator
70 |
71 |
72 |
A B C G N O
73 |
74 |
89 |
116 |
117 |
118 |
119 |
--------------------------------------------------------------------------------
/doc/index-files/index-5.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | N-Index
7 |
8 |
9 |
10 |
11 |
17 |
18 | JavaScript is disabled on your browser.
19 |
20 |
21 |
36 |
63 |
64 | A B C G N O
65 |
66 |
67 |
N
68 |
69 | numberCalc - Variable in class com.mtk.calculator.Calculator
70 |
71 |
72 |
A B C G N O
73 |
74 |
89 |
116 |
117 |
118 |
119 |
--------------------------------------------------------------------------------
/doc/index-files/index-6.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | O-Index
7 |
8 |
9 |
10 |
11 |
17 |
18 | JavaScript is disabled on your browser.
19 |
20 |
21 |
36 |
63 |
64 | A B C G N O
65 |
66 |
67 |
O
68 |
69 | operator - Variable in class com.mtk.calculator.Calculator.OperatorAction
70 |
71 |
72 |
A B C G N O
73 |
74 |
89 |
116 |
117 |
118 |
119 |
--------------------------------------------------------------------------------
/doc/index-files/index-7.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | O-Index
7 |
8 |
9 |
10 |
11 |
17 |
18 | JavaScript is disabled on your browser.
19 |
20 |
21 |
36 |
63 |
64 | A B C G M N O
65 |
66 |
67 |
O
68 |
69 | operator - Variable in class com.mtk.calculator.Calculator.OperatorAction
70 |
71 |
72 |
A B C G M N O
73 |
74 |
89 |
116 |
117 |
118 |
119 |
--------------------------------------------------------------------------------
/doc/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Generated Documentation (Untitled)
7 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | JavaScript is disabled on your browser.
25 |
26 | Frame Alert
27 | This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. Link to Non-frame version .
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/doc/overview-tree.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Class Hierarchy
7 |
8 |
9 |
10 |
11 |
17 |
18 | JavaScript is disabled on your browser.
19 |
20 |
21 |
36 |
63 |
64 |
71 |
72 |
Class Hierarchy
73 |
74 | java.lang.Object
75 |
78 |
79 |
80 |
81 |
82 |
97 |
98 |
99 | Prev
100 | Next
101 |
102 |
106 |
109 |
110 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
--------------------------------------------------------------------------------
/doc/package-list:
--------------------------------------------------------------------------------
1 | com.mtk.calculator
2 |
--------------------------------------------------------------------------------
/doc/resources/background.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdtareque/Calculator/07f62fd66e8fccd633ab53c07cc3c029ae47fa05/doc/resources/background.gif
--------------------------------------------------------------------------------
/doc/resources/tab.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdtareque/Calculator/07f62fd66e8fccd633ab53c07cc3c029ae47fa05/doc/resources/tab.gif
--------------------------------------------------------------------------------
/doc/resources/titlebar.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdtareque/Calculator/07f62fd66e8fccd633ab53c07cc3c029ae47fa05/doc/resources/titlebar.gif
--------------------------------------------------------------------------------
/doc/resources/titlebar_end.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdtareque/Calculator/07f62fd66e8fccd633ab53c07cc3c029ae47fa05/doc/resources/titlebar_end.gif
--------------------------------------------------------------------------------
/doc/stylesheet.css:
--------------------------------------------------------------------------------
1 | /* Javadoc style sheet */
2 | /*
3 | Overall document style
4 | */
5 | body {
6 | background-color:#ffffff;
7 | color:#353833;
8 | font-family:Arial, Helvetica, sans-serif;
9 | font-size:76%;
10 | margin:0;
11 | }
12 | a:link, a:visited {
13 | text-decoration:none;
14 | color:#4c6b87;
15 | }
16 | a:hover, a:focus {
17 | text-decoration:none;
18 | color:#bb7a2a;
19 | }
20 | a:active {
21 | text-decoration:none;
22 | color:#4c6b87;
23 | }
24 | a[name] {
25 | color:#353833;
26 | }
27 | a[name]:hover {
28 | text-decoration:none;
29 | color:#353833;
30 | }
31 | pre {
32 | font-size:1.3em;
33 | }
34 | h1 {
35 | font-size:1.8em;
36 | }
37 | h2 {
38 | font-size:1.5em;
39 | }
40 | h3 {
41 | font-size:1.4em;
42 | }
43 | h4 {
44 | font-size:1.3em;
45 | }
46 | h5 {
47 | font-size:1.2em;
48 | }
49 | h6 {
50 | font-size:1.1em;
51 | }
52 | ul {
53 | list-style-type:disc;
54 | }
55 | code, tt {
56 | font-size:1.2em;
57 | }
58 | dt code {
59 | font-size:1.2em;
60 | }
61 | table tr td dt code {
62 | font-size:1.2em;
63 | vertical-align:top;
64 | }
65 | sup {
66 | font-size:.6em;
67 | }
68 | /*
69 | Document title and Copyright styles
70 | */
71 | .clear {
72 | clear:both;
73 | height:0px;
74 | overflow:hidden;
75 | }
76 | .aboutLanguage {
77 | float:right;
78 | padding:0px 21px;
79 | font-size:.8em;
80 | z-index:200;
81 | margin-top:-7px;
82 | }
83 | .legalCopy {
84 | margin-left:.5em;
85 | }
86 | .bar a, .bar a:link, .bar a:visited, .bar a:active {
87 | color:#FFFFFF;
88 | text-decoration:none;
89 | }
90 | .bar a:hover, .bar a:focus {
91 | color:#bb7a2a;
92 | }
93 | .tab {
94 | background-color:#0066FF;
95 | background-image:url(resources/titlebar.gif);
96 | background-position:left top;
97 | background-repeat:no-repeat;
98 | color:#ffffff;
99 | padding:8px;
100 | width:5em;
101 | font-weight:bold;
102 | }
103 | /*
104 | Navigation bar styles
105 | */
106 | .bar {
107 | background-image:url(resources/background.gif);
108 | background-repeat:repeat-x;
109 | color:#FFFFFF;
110 | padding:.8em .5em .4em .8em;
111 | height:auto;/*height:1.8em;*/
112 | font-size:1em;
113 | margin:0;
114 | }
115 | .topNav {
116 | background-image:url(resources/background.gif);
117 | background-repeat:repeat-x;
118 | color:#FFFFFF;
119 | float:left;
120 | padding:0;
121 | width:100%;
122 | clear:right;
123 | height:2.8em;
124 | padding-top:10px;
125 | overflow:hidden;
126 | }
127 | .bottomNav {
128 | margin-top:10px;
129 | background-image:url(resources/background.gif);
130 | background-repeat:repeat-x;
131 | color:#FFFFFF;
132 | float:left;
133 | padding:0;
134 | width:100%;
135 | clear:right;
136 | height:2.8em;
137 | padding-top:10px;
138 | overflow:hidden;
139 | }
140 | .subNav {
141 | background-color:#dee3e9;
142 | border-bottom:1px solid #9eadc0;
143 | float:left;
144 | width:100%;
145 | overflow:hidden;
146 | }
147 | .subNav div {
148 | clear:left;
149 | float:left;
150 | padding:0 0 5px 6px;
151 | }
152 | ul.navList, ul.subNavList {
153 | float:left;
154 | margin:0 25px 0 0;
155 | padding:0;
156 | }
157 | ul.navList li{
158 | list-style:none;
159 | float:left;
160 | padding:3px 6px;
161 | }
162 | ul.subNavList li{
163 | list-style:none;
164 | float:left;
165 | font-size:90%;
166 | }
167 | .topNav a:link, .topNav a:active, .topNav a:visited, .bottomNav a:link, .bottomNav a:active, .bottomNav a:visited {
168 | color:#FFFFFF;
169 | text-decoration:none;
170 | }
171 | .topNav a:hover, .bottomNav a:hover {
172 | text-decoration:none;
173 | color:#bb7a2a;
174 | }
175 | .navBarCell1Rev {
176 | background-image:url(resources/tab.gif);
177 | background-color:#a88834;
178 | color:#FFFFFF;
179 | margin: auto 5px;
180 | border:1px solid #c9aa44;
181 | }
182 | /*
183 | Page header and footer styles
184 | */
185 | .header, .footer {
186 | clear:both;
187 | margin:0 20px;
188 | padding:5px 0 0 0;
189 | }
190 | .indexHeader {
191 | margin:10px;
192 | position:relative;
193 | }
194 | .indexHeader h1 {
195 | font-size:1.3em;
196 | }
197 | .title {
198 | color:#2c4557;
199 | margin:10px 0;
200 | }
201 | .subTitle {
202 | margin:5px 0 0 0;
203 | }
204 | .header ul {
205 | margin:0 0 25px 0;
206 | padding:0;
207 | }
208 | .footer ul {
209 | margin:20px 0 5px 0;
210 | }
211 | .header ul li, .footer ul li {
212 | list-style:none;
213 | font-size:1.2em;
214 | }
215 | /*
216 | Heading styles
217 | */
218 | div.details ul.blockList ul.blockList ul.blockList li.blockList h4, div.details ul.blockList ul.blockList ul.blockListLast li.blockList h4 {
219 | background-color:#dee3e9;
220 | border-top:1px solid #9eadc0;
221 | border-bottom:1px solid #9eadc0;
222 | margin:0 0 6px -8px;
223 | padding:2px 5px;
224 | }
225 | ul.blockList ul.blockList ul.blockList li.blockList h3 {
226 | background-color:#dee3e9;
227 | border-top:1px solid #9eadc0;
228 | border-bottom:1px solid #9eadc0;
229 | margin:0 0 6px -8px;
230 | padding:2px 5px;
231 | }
232 | ul.blockList ul.blockList li.blockList h3 {
233 | padding:0;
234 | margin:15px 0;
235 | }
236 | ul.blockList li.blockList h2 {
237 | padding:0px 0 20px 0;
238 | }
239 | /*
240 | Page layout container styles
241 | */
242 | .contentContainer, .sourceContainer, .classUseContainer, .serializedFormContainer, .constantValuesContainer {
243 | clear:both;
244 | padding:10px 20px;
245 | position:relative;
246 | }
247 | .indexContainer {
248 | margin:10px;
249 | position:relative;
250 | font-size:1.0em;
251 | }
252 | .indexContainer h2 {
253 | font-size:1.1em;
254 | padding:0 0 3px 0;
255 | }
256 | .indexContainer ul {
257 | margin:0;
258 | padding:0;
259 | }
260 | .indexContainer ul li {
261 | list-style:none;
262 | }
263 | .contentContainer .description dl dt, .contentContainer .details dl dt, .serializedFormContainer dl dt {
264 | font-size:1.1em;
265 | font-weight:bold;
266 | margin:10px 0 0 0;
267 | color:#4E4E4E;
268 | }
269 | .contentContainer .description dl dd, .contentContainer .details dl dd, .serializedFormContainer dl dd {
270 | margin:10px 0 10px 20px;
271 | }
272 | .serializedFormContainer dl.nameValue dt {
273 | margin-left:1px;
274 | font-size:1.1em;
275 | display:inline;
276 | font-weight:bold;
277 | }
278 | .serializedFormContainer dl.nameValue dd {
279 | margin:0 0 0 1px;
280 | font-size:1.1em;
281 | display:inline;
282 | }
283 | /*
284 | List styles
285 | */
286 | ul.horizontal li {
287 | display:inline;
288 | font-size:0.9em;
289 | }
290 | ul.inheritance {
291 | margin:0;
292 | padding:0;
293 | }
294 | ul.inheritance li {
295 | display:inline;
296 | list-style:none;
297 | }
298 | ul.inheritance li ul.inheritance {
299 | margin-left:15px;
300 | padding-left:15px;
301 | padding-top:1px;
302 | }
303 | ul.blockList, ul.blockListLast {
304 | margin:10px 0 10px 0;
305 | padding:0;
306 | }
307 | ul.blockList li.blockList, ul.blockListLast li.blockList {
308 | list-style:none;
309 | margin-bottom:25px;
310 | }
311 | ul.blockList ul.blockList li.blockList, ul.blockList ul.blockListLast li.blockList {
312 | padding:0px 20px 5px 10px;
313 | border:1px solid #9eadc0;
314 | background-color:#f9f9f9;
315 | }
316 | ul.blockList ul.blockList ul.blockList li.blockList, ul.blockList ul.blockList ul.blockListLast li.blockList {
317 | padding:0 0 5px 8px;
318 | background-color:#ffffff;
319 | border:1px solid #9eadc0;
320 | border-top:none;
321 | }
322 | ul.blockList ul.blockList ul.blockList ul.blockList li.blockList {
323 | margin-left:0;
324 | padding-left:0;
325 | padding-bottom:15px;
326 | border:none;
327 | border-bottom:1px solid #9eadc0;
328 | }
329 | ul.blockList ul.blockList ul.blockList ul.blockList li.blockListLast {
330 | list-style:none;
331 | border-bottom:none;
332 | padding-bottom:0;
333 | }
334 | table tr td dl, table tr td dl dt, table tr td dl dd {
335 | margin-top:0;
336 | margin-bottom:1px;
337 | }
338 | /*
339 | Table styles
340 | */
341 | .contentContainer table, .classUseContainer table, .constantValuesContainer table {
342 | border-bottom:1px solid #9eadc0;
343 | width:100%;
344 | }
345 | .contentContainer ul li table, .classUseContainer ul li table, .constantValuesContainer ul li table {
346 | width:100%;
347 | }
348 | .contentContainer .description table, .contentContainer .details table {
349 | border-bottom:none;
350 | }
351 | .contentContainer ul li table th.colOne, .contentContainer ul li table th.colFirst, .contentContainer ul li table th.colLast, .classUseContainer ul li table th, .constantValuesContainer ul li table th, .contentContainer ul li table td.colOne, .contentContainer ul li table td.colFirst, .contentContainer ul li table td.colLast, .classUseContainer ul li table td, .constantValuesContainer ul li table td{
352 | vertical-align:top;
353 | padding-right:20px;
354 | }
355 | .contentContainer ul li table th.colLast, .classUseContainer ul li table th.colLast,.constantValuesContainer ul li table th.colLast,
356 | .contentContainer ul li table td.colLast, .classUseContainer ul li table td.colLast,.constantValuesContainer ul li table td.colLast,
357 | .contentContainer ul li table th.colOne, .classUseContainer ul li table th.colOne,
358 | .contentContainer ul li table td.colOne, .classUseContainer ul li table td.colOne {
359 | padding-right:3px;
360 | }
361 | .overviewSummary caption, .packageSummary caption, .contentContainer ul.blockList li.blockList caption, .summary caption, .classUseContainer caption, .constantValuesContainer caption {
362 | position:relative;
363 | text-align:left;
364 | background-repeat:no-repeat;
365 | color:#FFFFFF;
366 | font-weight:bold;
367 | clear:none;
368 | overflow:hidden;
369 | padding:0px;
370 | margin:0px;
371 | }
372 | caption a:link, caption a:hover, caption a:active, caption a:visited {
373 | color:#FFFFFF;
374 | }
375 | .overviewSummary caption span, .packageSummary caption span, .contentContainer ul.blockList li.blockList caption span, .summary caption span, .classUseContainer caption span, .constantValuesContainer caption span {
376 | white-space:nowrap;
377 | padding-top:8px;
378 | padding-left:8px;
379 | display:block;
380 | float:left;
381 | background-image:url(resources/titlebar.gif);
382 | height:18px;
383 | }
384 | .overviewSummary .tabEnd, .packageSummary .tabEnd, .contentContainer ul.blockList li.blockList .tabEnd, .summary .tabEnd, .classUseContainer .tabEnd, .constantValuesContainer .tabEnd {
385 | width:10px;
386 | background-image:url(resources/titlebar_end.gif);
387 | background-repeat:no-repeat;
388 | background-position:top right;
389 | position:relative;
390 | float:left;
391 | }
392 | ul.blockList ul.blockList li.blockList table {
393 | margin:0 0 12px 0px;
394 | width:100%;
395 | }
396 | .tableSubHeadingColor {
397 | background-color: #EEEEFF;
398 | }
399 | .altColor {
400 | background-color:#eeeeef;
401 | }
402 | .rowColor {
403 | background-color:#ffffff;
404 | }
405 | .overviewSummary td, .packageSummary td, .contentContainer ul.blockList li.blockList td, .summary td, .classUseContainer td, .constantValuesContainer td {
406 | text-align:left;
407 | padding:3px 3px 3px 7px;
408 | }
409 | th.colFirst, th.colLast, th.colOne, .constantValuesContainer th {
410 | background:#dee3e9;
411 | border-top:1px solid #9eadc0;
412 | border-bottom:1px solid #9eadc0;
413 | text-align:left;
414 | padding:3px 3px 3px 7px;
415 | }
416 | td.colOne a:link, td.colOne a:active, td.colOne a:visited, td.colOne a:hover, td.colFirst a:link, td.colFirst a:active, td.colFirst a:visited, td.colFirst a:hover, td.colLast a:link, td.colLast a:active, td.colLast a:visited, td.colLast a:hover, .constantValuesContainer td a:link, .constantValuesContainer td a:active, .constantValuesContainer td a:visited, .constantValuesContainer td a:hover {
417 | font-weight:bold;
418 | }
419 | td.colFirst, th.colFirst {
420 | border-left:1px solid #9eadc0;
421 | white-space:nowrap;
422 | }
423 | td.colLast, th.colLast {
424 | border-right:1px solid #9eadc0;
425 | }
426 | td.colOne, th.colOne {
427 | border-right:1px solid #9eadc0;
428 | border-left:1px solid #9eadc0;
429 | }
430 | table.overviewSummary {
431 | padding:0px;
432 | margin-left:0px;
433 | }
434 | table.overviewSummary td.colFirst, table.overviewSummary th.colFirst,
435 | table.overviewSummary td.colOne, table.overviewSummary th.colOne {
436 | width:25%;
437 | vertical-align:middle;
438 | }
439 | table.packageSummary td.colFirst, table.overviewSummary th.colFirst {
440 | width:25%;
441 | vertical-align:middle;
442 | }
443 | /*
444 | Content styles
445 | */
446 | .description pre {
447 | margin-top:0;
448 | }
449 | .deprecatedContent {
450 | margin:0;
451 | padding:10px 0;
452 | }
453 | .docSummary {
454 | padding:0;
455 | }
456 | /*
457 | Formatting effect styles
458 | */
459 | .sourceLineNo {
460 | color:green;
461 | padding:0 30px 0 0;
462 | }
463 | h1.hidden {
464 | visibility:hidden;
465 | overflow:hidden;
466 | font-size:.9em;
467 | }
468 | .block {
469 | display:block;
470 | margin:3px 0 0 0;
471 | }
472 | .strong {
473 | font-weight:bold;
474 | }
475 |
--------------------------------------------------------------------------------
/javadoc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/src/com/mtk/calculator/CalcLauncher.java:
--------------------------------------------------------------------------------
1 | package com.mtk.calculator;
2 | import java.awt.EventQueue;
3 |
4 |
5 | /**
6 | * The main launcher for java calculator. Creates the {@code Calculator} object.
7 | * @author mtk
8 | * @version 1.0 Nov 25, 2012
9 | * @see Calculator
10 | */
11 | public class CalcLauncher {
12 | /**
13 | * @param args
14 | * Currently no arguments required to be passed to this program.
15 | */
16 | public static void main(String[] args) {
17 |
18 | // Use the event dispatch thread for Swing components
19 | EventQueue.invokeLater(new Runnable() {
20 | /* (non-Javadoc)
21 | * @see java.lang.Runnable#run()
22 | */
23 | @Override
24 | public void run() {
25 | new Calculator();
26 | }
27 | });
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/com/mtk/calculator/Calculator.java:
--------------------------------------------------------------------------------
1 | package com.mtk.calculator;
2 |
3 | import java.awt.GridLayout;
4 | import java.awt.BorderLayout;
5 | import java.awt.event.ActionListener;
6 | import java.awt.event.ActionEvent;
7 | import javax.swing.JFrame;
8 | import javax.swing.JPanel;
9 | import javax.swing.JTextField;
10 | import javax.swing.JButton;
11 | import java.awt.Container;
12 |
13 | /**
14 | * Create the UI and also performs the event handling and operations of calculations.
15 | * @author mtk
16 | * @version 1.0 Nov 25, 2012
17 | */
18 | public class Calculator implements ActionListener {
19 |
20 | JFrame guiFrame;
21 | JPanel buttonPanel;
22 | JTextField numberCalc;
23 | int calcOperation = 0;
24 | int currentCalc;
25 |
26 | /**
27 | * Consturct a new Calculator Frame. Sets a default
28 | * EXIT_ON_CLOSE
option. Positions the JFrame
in
29 | * the middle of the screen Also fills the UI with required components.
30 | */
31 | public Calculator() {
32 | guiFrame = new JFrame();
33 |
34 | guiFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
35 | guiFrame.setTitle("Simple Calculator");
36 | guiFrame.setSize(300, 300);
37 |
38 | guiFrame.setLocationRelativeTo(null);
39 |
40 | numberCalc = new JTextField();
41 | numberCalc.setHorizontalAlignment(JTextField.RIGHT);
42 | numberCalc.setEditable(false);
43 |
44 | guiFrame.add(numberCalc, BorderLayout.NORTH);
45 |
46 | buttonPanel = new JPanel();
47 |
48 | buttonPanel.setLayout(new GridLayout(5, 3));
49 | guiFrame.add(buttonPanel, BorderLayout.CENTER);
50 |
51 | // Add the number buttons
52 | for (int i = 1; i < 10; i++) {
53 | addButton(buttonPanel, String.valueOf(i));
54 | }
55 | addButton(buttonPanel, " ");
56 | addButton(buttonPanel, "0");
57 | addButton(buttonPanel, " ");
58 |
59 | JButton addButton = new JButton("+");
60 | addButton.setActionCommand("+");
61 |
62 | OperatorAction subAction = new OperatorAction(1);
63 | addButton.addActionListener(subAction);
64 |
65 | JButton subButton = new JButton("-");
66 | subButton.setActionCommand("-");
67 |
68 | OperatorAction addAction = new OperatorAction(2);
69 | subButton.addActionListener(addAction);
70 |
71 | JButton equalsButton = new JButton("=");
72 | equalsButton.setActionCommand("=");
73 | equalsButton.addActionListener(new ActionListener() {
74 | /* (non-Javadoc)
75 | * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
76 | */
77 | @Override
78 | public void actionPerformed(ActionEvent event) {
79 | if (!numberCalc.getText().isEmpty()) {
80 | int number = Integer.parseInt(numberCalc.getText());
81 | if (calcOperation == 1) {
82 | int calculate = currentCalc + number;
83 | numberCalc.setText(Integer.toString(calculate));
84 | } else if (calcOperation == 2) {
85 | int calculate = currentCalc - number;
86 | numberCalc.setText(Integer.toString(calculate));
87 | }
88 | }
89 | }
90 | });
91 |
92 | buttonPanel.add(addButton);
93 | buttonPanel.add(subButton);
94 | buttonPanel.add(equalsButton);
95 | guiFrame.setVisible(true);
96 | }
97 |
98 | /**
99 | * @param parent
100 | * the main container of the component to be added
101 | * @param name
102 | * name of the JButton
that is to be added
103 | */
104 | private void addButton(Container parent, String name) {
105 | JButton but = new JButton(name);
106 | but.setActionCommand(name);
107 | but.addActionListener(this);
108 | parent.add(but);
109 | }
110 |
111 | /* (non-Javadoc)
112 | * As all the buttons are doing the same thing it's easier to make the class
113 | * implement the ActionListener
interface and control the
114 | * button clicks from one place
115 | *
116 | * @see
117 | * java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
118 | */
119 | @Override
120 | public void actionPerformed(ActionEvent event) {
121 | String action = event.getActionCommand();
122 | numberCalc.setText(action);
123 | }
124 |
125 | /**
126 | * @author mtk
127 | *
128 | */
129 | private class OperatorAction implements ActionListener {
130 | private int operator;
131 |
132 | /**
133 | * @param operation
134 | */
135 | public OperatorAction(int operation) {
136 | operator = operation;
137 | }
138 |
139 | /* (non-Javadoc)
140 | * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
141 | */
142 | public void actionPerformed(ActionEvent event) {
143 | currentCalc = Integer.parseInt(numberCalc.getText());
144 | calcOperation = operator;
145 | }
146 | }
147 | }
--------------------------------------------------------------------------------