-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSelectMenu.java
227 lines (163 loc) · 5.79 KB
/
SelectMenu.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
package oodp;
import java.awt.*;
import java.awt.event.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.applet.*;
import javax.swing.*;
public class SelectMenu extends JPanel implements ActionListener
{
JButton[] sectionbtn = new JButton[10];
JButton[] btn = new JButton[50];
ArrayList<Menu> list = new ArrayList<Menu>();
Menu menu = new Menu();
int item_num=0;
private JFrame frm = new JFrame();
public SelectMenu()
{
this.setSize(400, 300);
int i = 0;
sectionbtn[0]=new JButton("Mix Rice");
sectionbtn[1]=new JButton("Korean Table");
sectionbtn[2]=new JButton("Fry Fry");
sectionbtn[3]=new JButton("Grace Garden");
sectionbtn[4]=new JButton("Hao");
sectionbtn[5]=new JButton("Noodle road");
Menu_Management.initialMenu(list);
Iterator<Menu> iter = list.iterator();
//menuSection별 출력
add(new JLabel("Mix Rice\n"));
while (iter.hasNext()) {
menu = (Menu)iter.next();
if(menu.menuSection.equalsIgnoreCase("Mix Rice"))
{
btn[i]=new JButton(menu.menuList);
add(btn[i]);
i++;
}
}
add(new JLabel("\n\n"));
iter = list.iterator();
add(new JLabel("Korean Table\n"));
while (iter.hasNext()) {
menu = (Menu)iter.next();
if(menu.menuSection.equalsIgnoreCase("Korean Table"))
{
btn[i]=new JButton(menu.menuList);
add(btn[i]);
i++;
}
}
add(new JLabel("\n\n"));
iter = list.iterator();
add(new JLabel("Fry Fry\n"));
while (iter.hasNext()) {
menu = (Menu)iter.next();
if(menu.menuSection.equalsIgnoreCase("Fry Fry"))
{
btn[i]=new JButton(menu.menuList);
add(btn[i]);
i++;
}
}
add(new JLabel("\n\n"));
iter = list.iterator();
add(new JLabel("Grace Garden\n"));
while (iter.hasNext()) {
menu = (Menu)iter.next();
if(menu.menuSection.equalsIgnoreCase("Grace Garden"))
{
btn[i]=new JButton(menu.menuList);
add(btn[i]);
i++;
}
}
add(new JLabel("\n\n"));
iter = list.iterator();
add(new JLabel("Hao\n"));
while (iter.hasNext()) {
menu = (Menu)iter.next();
if(menu.menuSection.equalsIgnoreCase("Hao"))
{
btn[i]=new JButton(menu.menuList);
add(btn[i]);
i++;
}
}
add(new JLabel("\n\n"));
iter = list.iterator();
add(new JLabel("Noodle road\n"));
while (iter.hasNext()) {
menu = (Menu)iter.next();
if(menu.menuSection.equalsIgnoreCase("Noodle road"))
{
btn[i]=new JButton(menu.menuList);
add(btn[i]);
i++;
}
}
//button 누르면 cash, coupon, point 선택 창 띄우기
item_num= i--;
i=0;
while (i<item_num) {
btn[i].addActionListener(this);
i++;
}
}
@Override
public void actionPerformed(ActionEvent e)
{
if(e.getSource().equals(MainBoard.btn2))
{
MainBoard.board.remove(MainBoard.board_panel);
MainBoard.board.repaint();
MainBoard.board.revalidate();
MainBoard.board_panel=this;
MainBoard.board_panel.setBackground(Color.white);
MainBoard.board_panel.setBounds(150,40,650,560);
MainBoard.board.add(MainBoard.board_panel);
}
int i=0, use=0;
Payment pay_with = new Payment();
while (i<item_num)
{
use=0;
if(e.getSource().equals(btn[i]))
{
Object[] options = {"포인트 결제", "현장 결제", "쿠폰 결제"};
int selectedNum = JOptionPane.showOptionDialog(frm, "결제 수단을 선택하여 주세요.", "결제 수단",
JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
Iterator<Menu> iter = list.iterator();
int j=0;
while (j<item_num) {
menu = (Menu)iter.next();
if(menu.menuList.equalsIgnoreCase(btn[i].getText()))
{
if(selectedNum==0)//포인트
{
pay_with.Pay_Point(menu);
use=1;
}
else if(selectedNum==1)//현장
{
pay_with.Pay_Cash(menu);
use=1;
}
else if(selectedNum==2)//쿠폰
{
pay_with.Pay_Coupon(menu);
use=1;
}
break;
}
j++;
}
if(use==1)
{
break;
}
}
i++;
}
}
}