-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBananasFoster.java
729 lines (616 loc) · 25.3 KB
/
BananasFoster.java
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
import java.awt.*; // access to Container
import java.awt.event.*; // access to WindowAdapter, WindowEvent
import javax.swing.*; // access to JFrame and Jcomponents
import javax.swing.event.*; // access to JSlider events
import javax.swing.Timer;
import java.util.*;
/**
* Write a description of class BananasFoster here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class BananasFoster extends Food implements ActionListener, MouseListener
{
JLabel griddle; // pancake griddle image
ArrayList<ImageIcon> griddleimgs; // list of images for the pancake griddle
JLabel batter1; // first pancake batter image
JLabel batter2; // second pancake batter image
JLabel batter3;// third pancake batter image
JLabel batter4;// fourth pancake batter image
JLabel batter5;// fifth pancake batter image
JLabel batter6;// sixth pancake batter image
JLabel[] batters; // List of batter JLabels
JLabel pan; // pan image
JLabel butter; // butter image
JLabel sugar; // sugar image
JLabel banana; // banana image
ArrayList<JLabel> paningredients; // holds ingredients for pan step
ArrayList<ImageIcon> panimgs; // holds images for the pan
int batterCount; // holds the number of batters dropped onto the pan
JButton nextButton; // button for the next step
JButton returnButton; // button to return to the restaurant
private JLabel pancake1; // img for first stacked pancake
private JLabel pancake2; // img for second stacked pancake
private JLabel pancake3; // img for third stacked pancake
private JLabel plate; // / img for plate
private int x1; // xcoordinate for pancake1
private int y1; //y coordinate for pancake1
private int x2; // xcoordinate for pancake2
private int y2; //y coordinate for pancake2
private int x3; // xcoordinate for pancake3
private int y3; //y coordinate for pancake3
private boolean left; // true if the pancake is moving left
private Timer timer; // times the game
JLabel pancakePlate; // image of pancake plate
JLabel syrup; // image of the syrup
JLabel chocolateChips; // image of the bananas
JLabel whippedCream; // image of whipped cream
ArrayList<JLabel> plateingredients; // JLabels of plate ingredients
ArrayList<ImageIcon> plateimgs; // images of plates
boolean switch2; //Stores if switch2 method has been executed
boolean switch3; //Stores if switch3 method has been executed
boolean switch4; //Stores if switch4 method has been executed
Point previousPoint; //Stores previous coordinates
JLabel focusLabel; // Jlabel being moved
boolean butterTouch; // stores if butter touches pan
boolean sugarTouch; // stores if sugar touches pan
boolean bananaTouch; // sotres if bananas touches pan
boolean syrupTouch; // stores if syrup touches pancakes
boolean whippedCreamTouch; // stores if whipped cream touches pancakes
boolean chocolateChipsTouch; // stores if banana sugar touches pancakes
public BananasFoster(KitchenPanel kit)
// extends food and calls super (kit)
{
super(kit);
foodName = "assets/Banana Pancake Speech Bubble.png";
switch2 = false;
switch3 = false;
switch4 = false;
ImageIcon griddleIMG = new ImageIcon(getClass().getResource("assets/griddle1.png"));
ImageIcon nextIMG = new ImageIcon(getClass().getResource("assets/next.png"));
ImageIcon returnIMG = new ImageIcon(getClass().getResource("assets/done.png"));
griddle = new JLabel();
griddle.setIcon(griddleIMG);
griddle.setBounds(0,0, 1000, 750);
griddle.addMouseListener(this);
griddleimgs = new ArrayList<ImageIcon>();
griddleimgs.add(new ImageIcon(getClass().getResource("assets/griddle2.png")));
griddleimgs.add(new ImageIcon(getClass().getResource("assets/griddle3.png")));
griddleimgs.add(new ImageIcon(getClass().getResource("assets/griddle4.png")));
griddleimgs.add(new ImageIcon(getClass().getResource("assets/griddle5.png")));
griddleimgs.add(new ImageIcon(getClass().getResource("assets/griddle6.png")));
batter1 = new JLabel();
batter2 = new JLabel();
batter3 = new JLabel();
batter4 = new JLabel();
batter5 = new JLabel();
batter6 = new JLabel();
JLabel[] batters = new JLabel[6];
batters[0] = batter1;
batters[1] = batter2;
batters[2] = batter3;
batters[3] = batter4;
batters[4] = batter5;
batters[5] = batter6;
batterCount = 0;
ImageIcon panIMG = new ImageIcon(getClass().getResource("assets/pan1.png"));
pan = new JLabel();
pan.setIcon(panIMG);
pan.setBounds(400, 100,470,470);
panimgs = new ArrayList<ImageIcon>();
panimgs.add(new ImageIcon(getClass().getResource("assets/pan2.png")));
panimgs.add(new ImageIcon(getClass().getResource("assets/pan3.png")));
panimgs.add(new ImageIcon(getClass().getResource("assets/pan4.png")));
ImageIcon butterIMG = new ImageIcon(getClass().getResource("assets/butterbowl.png"));
ImageIcon sugarIMG = new ImageIcon(getClass().getResource("assets/sugarbowl.png"));
ImageIcon bananaIMG = new ImageIcon(getClass().getResource("assets/bananaslices.png"));
butter = new JLabel();
butter.setIcon(butterIMG);
butter.setBounds(100, 100, 200, 71);
sugar = new JLabel();
sugar.setIcon(sugarIMG);
sugar.setBounds(100, 200, 200, 200);
banana = new JLabel();
banana.setIcon(bananaIMG);
banana.setBounds(100, 425, 220, 188);
paningredients = new ArrayList<JLabel>();
paningredients.add(butter);
paningredients.add(sugar);
paningredients.add(banana);
ImageIcon pancake1IMG = new ImageIcon(getClass().getResource("assets/pancakes.png"));
pancake1 = new JLabel();
pancake1.setIcon(pancake1IMG);
x1= 200;
y1 = 0;
pancake1.setBounds(x1,y1, 500, 500);
ImageIcon pancake2IMG = new ImageIcon(getClass().getResource("assets/pancakes.png"));
pancake2 = new JLabel();
pancake2.setIcon(pancake2IMG);
x2 = 50;
y2 = 0;
pancake2.setBounds(x2,y2, 500, 500);
ImageIcon pancake3IMG = new ImageIcon(getClass().getResource("assets/pancakes.png"));
pancake3 = new JLabel();
pancake3.setIcon(pancake3IMG);
x3 = 50;
y3 = 0;
pancake3.setBounds(x1,y1, 500, 500);
left = false;
ImageIcon plateIMG2 = new ImageIcon(getClass().getResource("assets/plate.png"));
plate = new JLabel();
plate.setIcon(plateIMG2);
plate.setBounds(70,100, 900,900);
ImageIcon plateIMG = new ImageIcon(getClass().getResource("assets/pancake1.png"));
pancakePlate = new JLabel();
pancakePlate.setIcon(plateIMG);
pancakePlate.setBounds(0,0,1000,750);
plateimgs = new ArrayList<ImageIcon>();
plateimgs.add(new ImageIcon(getClass().getResource("assets/pancake2.png")));
plateimgs.add(new ImageIcon(getClass().getResource("assets/pancake3.png")));
plateimgs.add(new ImageIcon(getClass().getResource("assets/pancake4.png")));
ImageIcon syrupIMG = new ImageIcon(getClass().getResource("assets/syrup.png"));
ImageIcon whippedcreamIMG = new ImageIcon(getClass().getResource("assets/whippedcream.png"));
ImageIcon chocIMG = new ImageIcon(getClass().getResource("assets/chocolatechips.png"));
syrup = new JLabel();
syrup.setIcon(syrupIMG);
syrup.setBounds(100, 20, 124, 161);
whippedCream = new JLabel();
whippedCream.setIcon(whippedcreamIMG);
whippedCream.setBounds(400, 20, 107, 219);
chocolateChips = new JLabel();
chocolateChips.setIcon(chocIMG);
chocolateChips.setBounds(700, 20, 233, 72);
plateingredients = new ArrayList<JLabel>();
plateingredients.add(syrup);
plateingredients.add(whippedCream);
plateingredients.add(chocolateChips);
syrupTouch = false;
whippedCreamTouch = false;
chocolateChipsTouch = false;
nextButton = new JButton();
nextButton.setFocusable(false);
nextButton.setBounds(650,425,350,350);
nextButton.addActionListener(this);
nextButton.setIcon(nextIMG);
nextButton.setBackground(new Color(0xFFFFFF));
nextButton.setContentAreaFilled(false);
nextButton.setBorder(null);
nextButton.setVisible(false);
returnButton = new JButton();
returnButton.setFocusable(false);
returnButton.setBounds(600,450,350,350);
returnButton.addActionListener(foodKitchen); //FIX THIS
returnButton.setIcon(returnIMG);
returnButton.setBackground(new Color(0xFFFFFF));
returnButton.setContentAreaFilled(false);
returnButton.setBorder(null);
ClickListener clickListener = new ClickListener();
DragListener dragListener = new DragListener();
foodKitchen.addMouseListener(clickListener);
foodKitchen.addMouseMotionListener(dragListener);
}
public BananasFoster()
//extends food and calls super()
{
super();
foodName = "assets/Banana Pancake Speech Bubble.png";
}
public void addComponents()
// adds components to the panel
{
foodKitchen.add(griddle);
foodKitchen.add(nextButton);
}
public void removeComponents()
// removes components from panel
{
foodKitchen.remove(pancakePlate);
}
public void switchTo2()
// switches to the next step
{
foodKitchen.add(butter);
foodKitchen.add(sugar);
foodKitchen.add(banana);
foodKitchen.add(pan);
nextButton.setVisible(false);
/**
*
this.add(smoothiecup);
this.add(bp);
oscillate();
toppingAction myTA = new toppingAction(bp, this, timer);
InputMap bpInput = bp.getInputMap(WHEN_IN_FOCUSED_WINDOW);
ActionMap bpAction = bp.getActionMap();
bpInput.put(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0, true), "drop");
bpAction.put("drop", myTA);
nextButton.setVisible(false);
*/
}
public JButton getNextButton()
//returns nextButton object
{
return nextButton;
}
public JLabel getPancake1()
// returns pancake1
{
return pancake1;
}
public JLabel getPancake2()
// returns pancake2
{
return pancake2;
}
public JLabel getPancake3()
// returns pancake3
{
return pancake3;
}
public void switchTo3()
// switches to the next step
{
foodKitchen.add(plate);
foodKitchen.add(pancake1);
oscillate(pancake1);
pancakeAction myTA = new pancakeAction(pancake1, this, timer);
InputMap pancake1Input = pancake1.getInputMap(pancake1.WHEN_IN_FOCUSED_WINDOW);
ActionMap pancake1Action = pancake1.getActionMap();
pancake1Input.put(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0, true), "drop");
pancake1Action.put("drop", myTA);
}
public void switchTo4()
//switches to the next step
{
foodKitchen.add(syrup);
foodKitchen.add(whippedCream);
foodKitchen.add(chocolateChips);
foodKitchen.add(pancakePlate);
}
public void mouseClicked(MouseEvent e)
// updates panel accordingly
{
JLabel currBatter = null;
int XBound1 = 0;
int YBound1 = 0;
int XBound2 = 0;
int YBound2 = 0;
if(batterCount < 6){
if(batterCount ==0){
currBatter = batter1;
XBound1 = 500;
XBound2 = 1000;
YBound1 = 500;
YBound2 = 700;
}else if(batterCount == 1){
currBatter = batter2;
XBound1 = 500;
XBound2 = 1000;
YBound1 = 500;
YBound2 = 700;
}else if(batterCount ==2){
currBatter = batter3;
XBound1 = 500;
XBound2 = 1000;
YBound1 = 500;
YBound2 = 700;
}else if(batterCount == 3){
currBatter = batter4;
XBound1 = 500;
XBound2 = 1000;
YBound1 = 500;
YBound2 = 700;
}else if (batterCount == 4){
currBatter = batter5;
XBound1 = 500;
XBound2 = 1000;
YBound1 = 500;
YBound2 = 700;
}else if (batterCount == 5){
currBatter = batter6;
XBound1 = 500;
XBound2 = 1000;
YBound1 = 500;
YBound2 = 700;
}
currBatter.setIcon(new ImageIcon(getClass().getResource("assets/battercircleogc.png")));
foodKitchen.add(currBatter);
foodKitchen.moveToFront(currBatter);
int currentX = (int)MouseInfo.getPointerInfo().getLocation().getX()-110;
int currentY = (int)MouseInfo.getPointerInfo().getLocation().getY()-120;
foodKitchen.getCoordLabel().setText(currentX + " " +currentY + " " +XBound1+" " +XBound2+" " +YBound1+" " +YBound2);
currBatter.setBounds(currentX, currentY, 208, 208);
if(currentX > XBound1 && currentX < XBound2 && currentY > YBound1 && currentY < YBound2){
foodKitchen.updateScore(-1);
}
if(griddleimgs.size() > 0){
griddle.setIcon(griddleimgs.remove(0));
}
foodKitchen.getFrame().repaint();
batterCount++;
}
if (batterCount == 6){
foodKitchen.updateScore(13);
nextButton.setVisible(true);
foodKitchen.moveToFront(nextButton);
foodKitchen.getFrame().repaint();
}
}
public void mousePressed(MouseEvent e){
}
public void mouseReleased(MouseEvent e){
}
public void mouseEntered(MouseEvent e){
}
public void mouseExited(MouseEvent e){
}
public void actionPerformed(ActionEvent event)
// checks for button press, updates game, accordingly
{
if(event.getSource() == nextButton){
foodKitchen.removeAll();
foodKitchen.add(foodKitchen.getScoreLabel());
if(switch2 == true && switch3 == true){
switchTo4();
switch4 = true;
}
if(switch2 == true && switch3 == false){
System.out.println("switching");
switchTo3();
switch3 = true;
}
if(switch2 == false){
switchTo2();
switch2 = true;
}
foodKitchen.getFrame().repaint();
}
}
private class ClickListener extends MouseAdapter
{
public void mousePressed(MouseEvent e)
{
previousPoint = e.getPoint(); // updating the previous point to new place that is clicked
if(switch2 == true && switch3 == false){
for(JLabel img: paningredients){
boolean withinBounds = previousPoint.getX() > img.getX() && previousPoint.getX()<(img.getX()+img.getWidth()) && previousPoint.getY() > img.getY() && previousPoint.getY() <(img.getY()+img.getHeight());
if(withinBounds){
focusLabel = img;
}
}
}else if(switch2 == true && switch3 == true && switch4 == true){
for(JLabel img: plateingredients){
boolean withinBounds = previousPoint.getX() > img.getX() && previousPoint.getX()<(img.getX()+img.getWidth()) && previousPoint.getY() > img.getY() && previousPoint.getY() <(img.getY()+img.getHeight());
if(withinBounds){
focusLabel = img;
}
}
}
}
}
public void intersects ()
//checks for collision
{
if(switch2 == true && switch3 == false){
if(focusLabel.getX() > 500 && focusLabel.getX()<850 && focusLabel.getY()>150 && focusLabel.getY()<900){
if(focusLabel == butter && butterTouch == false && sugarTouch == false){
foodKitchen.remove(butter);
pan.setIcon(panimgs.remove(0));
butterTouch = true;
focusLabel = null;
}else if(focusLabel == sugar && butterTouch == true && sugarTouch == false){
foodKitchen.remove(sugar);
pan.setIcon(panimgs.remove(0));
sugarTouch = true;
focusLabel = null;
}else if (focusLabel == banana && butterTouch == true && sugarTouch == true){
foodKitchen.add(nextButton,0);
nextButton.setVisible(true);
foodKitchen.moveToFront(nextButton);
foodKitchen.remove(banana);
pan.setIcon(panimgs.remove(0));
focusLabel = null;
}else if (focusLabel == sugar && (butterTouch == false && sugarTouch == false) ) {
focusLabel.setBounds(100, 250, 200, 200);
focusLabel = null;
foodKitchen.updateScore(-1);
}else if(focusLabel == banana && (butterTouch == false && sugarTouch == false || butterTouch == true && sugarTouch == false)){
focusLabel.setBounds(100, 500, 200, 200);
focusLabel = null;
foodKitchen.updateScore(-1);
}
foodKitchen.getFrame().repaint();
}
}else if(switch2==true && switch3 == true){
if(focusLabel.getX() > 250 && focusLabel.getX()<770 && focusLabel.getY()>400 && focusLabel.getY()<680){
if(focusLabel == syrup && syrupTouch == false && whippedCreamTouch == false && chocolateChipsTouch == false){
foodKitchen.remove(syrup);
pancakePlate.setIcon(plateimgs.remove(0));
syrupTouch = true;
}else if(focusLabel == whippedCream && syrupTouch == true && whippedCreamTouch == false && chocolateChipsTouch == false){
foodKitchen.remove(whippedCream);
pancakePlate.setIcon(plateimgs.remove(0));
whippedCreamTouch = true;
}else if (focusLabel == chocolateChips && syrupTouch == true && whippedCreamTouch == true && chocolateChipsTouch == false){
foodKitchen.remove(chocolateChips);
pancakePlate.setIcon(plateimgs.remove(0));
chocolateChipsTouch = true;
foodKitchen.remove(banana);
foodKitchen.add(returnButton);
returnButton.setVisible(true);
foodKitchen.moveToFront(returnButton);
}
foodKitchen.getFrame().repaint();
}
}
}
public void pancakeTwo()
// adds, executes components associated with pancake2
{
foodKitchen.add(pancake2);
oscillate(pancake2);
pancakeAction myTA2 = new pancakeAction(pancake2, this, timer);
InputMap panInput = pancake2.getInputMap(pancake2.WHEN_IN_FOCUSED_WINDOW);
ActionMap panAction = pancake2.getActionMap();
panInput.put(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0, true), "drop");
panAction.put("drop", myTA2);
}
public void pancakeThree()
//adds, executes components associated with pancake3
{
foodKitchen.add(pancake3);
oscillate(pancake3);
System.out.println("oscillating");
pancakeAction myTA3 = new pancakeAction(pancake3, this, timer);
InputMap pancakesInput = pancake3.getInputMap(pancake3.WHEN_IN_FOCUSED_WINDOW);
ActionMap pancakesAction = pancake3.getActionMap();
pancakesInput.put(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0, true), "drop");
pancakesAction.put("drop", myTA3);
}
public int getPanX(JLabel pancake)
//get value of pancake’s x coordinate
{
if (pancake == pancake1){
return x1;
}else if(pancake == pancake2){
return x2;
}else if(pancake == pancake3){
return x3;
}
return 0;
}
public int getPanY(JLabel pancake)
// get value of pancake’s y coordinate
{
if (pancake == pancake1){
return y1;
}else if(pancake == pancake2){
return y2;
}else if(pancake == pancake3){
return y3;
}
return 0;
}
public void incrementPanX(JLabel pancake, int value)
// Changes value of pancake’s x coordinate by increment
{
if (pancake == pancake1){
x1+=value;
}else if(pancake == pancake2){
x2+=value;
}else if(pancake == pancake3){
x3+=value;
}
}
public void incrementPanY(JLabel pancake, int value)
// Changes value of pancake’s y coordinate by increment
{
if (pancake == pancake1){
y1+=value;
}else if(pancake == pancake2){
y2+=value;
}else if(pancake == pancake3){
y3+=value;
}
}
public int getRequiredY(JLabel pancake){
if (pancake == pancake1){
return 285;
}else if(pancake == pancake2){
return 255;
}else if(pancake == pancake3){
return 225;
}
return 0;
}
public void oscillate(JLabel pancake)
// moves the pancake back and forth oscillate movement
{
BananasFoster panel = this;
timer = new Timer(10, new ActionListener(){
public void actionPerformed(ActionEvent e){
pancake.setLocation(panel.getPanX(pancake), 0);
if(left == false){
panel.incrementPanX(pancake, 5);
}else{
panel.incrementPanX(pancake, -5);
}
if(panel.getPanX(pancake) == 500 || panel.getPanX(pancake) == 0){
left = !left;
}
pancake.getParent().repaint();
}
});
timer.setRepeats(true);
timer.start();
}
public void movePancakeDown(JLabel pancake)
// moves the pancake down onto the plate when space bar is pressed
{
BananasFoster panel2 = this;
JButton thisNext = panel2.getNextButton();
timer = new Timer(10, new ActionListener(){
public void actionPerformed(ActionEvent e){
pancake.setLocation(panel2.getPanX(pancake),panel2.getPanY(pancake));
panel2.incrementPanY(pancake, 5);
foodKitchen.moveToBack(plate);
if(panel2.getPanX(pancake) > 350 && panel2.getPanX(pancake) <625){
if(panel2.getPanY(pancake) >= 150)
{
timer.setRepeats(false);
foodKitchen.moveToFront(pancake);
timer.stop();
if (pancake == pancake1){
pancakeTwo();
}else if(pancake == pancake2){
System.out.println("2");
pancakeThree();
}else if (pancake == pancake3){
foodKitchen.add(thisNext,0);
thisNext.setVisible(true);
foodKitchen.moveToFront(thisNext);
System.out.println("3");
}
}
}else if(panel2.getPanY(pancake) >= panel2.getRequiredY(pancake)){
timer.setRepeats(false);
foodKitchen.moveToFront(pancake);
timer.stop();
if (pancake == pancake1){
pancakeTwo();
}else if(pancake == pancake2){
pancakeThree();
}else if (pancake == pancake3){
foodKitchen.add(thisNext,0);
thisNext.setVisible(true);
foodKitchen.moveToFront(thisNext);
System.out.println("3");
}
}
pancake.getParent().repaint();
}
});
timer.setRepeats(true);
timer.start();
}
public JButton getRestaurantButton()
// returns restaurant button
{
return returnButton;
}
private class DragListener extends MouseMotionAdapter
{
public void mouseDragged(MouseEvent e)
//Updates location of focusLabel based on mouse drag action
{
Point currentPoint = e.getPoint(); // gets the point where the mouse is currently
if(focusLabel != null){
focusLabel.setLocation((int)(currentPoint.getX()-50),(int)(currentPoint.getY())-50);
previousPoint = currentPoint;
intersects();
foodKitchen.getFrame().repaint();
}
}
}
}