Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9cdeac1

Browse filesBrowse files
committed
ch15 feedback from Kevin
1 parent 2a634e3 commit 9cdeac1
Copy full SHA for 9cdeac1

File tree

Expand file treeCollapse file tree

4 files changed

+9
-6
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

4 files changed

+9
-6
lines changed
Open diff view settings
Collapse file

‎appc/Drawing.java‎

Copy file name to clipboardExpand all lines: appc/Drawing.java
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ public class Drawing extends Canvas {
66

77
public static void main(String[] args) {
88
JFrame frame = new JFrame("My Drawing");
9+
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
910
Canvas drawing = new Drawing();
1011
drawing.setSize(400, 400);
1112
frame.add(drawing);
Collapse file

‎appc/Mickey.java‎

Copy file name to clipboardExpand all lines: appc/Mickey.java
+6-5Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ public class Mickey extends Canvas {
88

99
public static void main(String[] args) {
1010
JFrame frame = new JFrame("Mickey Mouse");
11+
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
1112
Canvas canvas = new Mickey();
1213
canvas.setSize(400, 400);
1314
canvas.setBackground(Color.white);
@@ -28,14 +29,14 @@ public void boxOval(Graphics g, Rectangle bb) {
2829
public void mickey(Graphics g, Rectangle bb) {
2930
boxOval(g, bb);
3031

31-
int dx = bb.width / 2;
32-
int dy = bb.height / 2;
33-
Rectangle half = new Rectangle(bb.x, bb.y, dx, dy);
32+
int hx = bb.width / 2;
33+
int hy = bb.height / 2;
34+
Rectangle half = new Rectangle(bb.x, bb.y, hx, hy);
3435

35-
half.translate(-dx / 2, -dy / 2);
36+
half.translate(-hx / 2, -hy / 2);
3637
boxOval(g, half);
3738

38-
half.translate(dx * 2, 0);
39+
half.translate(hx * 2, 0);
3940
boxOval(g, half);
4041
}
4142

Collapse file

‎appc/Moire.java‎

Copy file name to clipboardExpand all lines: appc/Moire.java
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ public class Moire extends Canvas {
77

88
public static void main(String[] args) {
99
JFrame frame = new JFrame("Moire Pattern");
10+
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
1011
Canvas canvas = new Moire();
1112
canvas.setSize(400, 400);
1213
canvas.setBackground(Color.white);
Collapse file

‎ch15/Cell.java‎

Copy file name to clipboardExpand all lines: ch15/Cell.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public Cell(int x, int y, int size) {
3333
* @param g graphics context
3434
*/
3535
public void draw(Graphics g) {
36-
g.setColor(COLORS[this.state]);
36+
g.setColor(COLORS[state]);
3737
g.fillRect(x + 1, y + 1, size - 1, size - 1);
3838
g.setColor(Color.LIGHT_GRAY);
3939
g.drawRect(x, y, size, size);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.