1 | package main;
|
---|
2 |
|
---|
3 | import java.awt.*;
|
---|
4 | import java.awt.event.*;
|
---|
5 | import java.awt.image.*;
|
---|
6 | import java.io.*;
|
---|
7 | import java.text.*;
|
---|
8 | import java.util.*;
|
---|
9 |
|
---|
10 | import java.sql.*;
|
---|
11 |
|
---|
12 | import gamegui.*;
|
---|
13 | import gamegui.Window;
|
---|
14 | import gamegui.Label;
|
---|
15 | import gamegui.Button;
|
---|
16 | import utils.*;
|
---|
17 |
|
---|
18 | public class WineDBClient implements KeyListener, MouseListener {
|
---|
19 | public enum GameState {
|
---|
20 | Main,
|
---|
21 | ChangeBottle,
|
---|
22 | ChangeIcon
|
---|
23 | }
|
---|
24 |
|
---|
25 | public enum AuxState {
|
---|
26 | None,
|
---|
27 | MsgBox
|
---|
28 | }
|
---|
29 |
|
---|
30 | private static final boolean RUNNING_FROM_JAR = false;
|
---|
31 | private static final int RES_X = 1280;
|
---|
32 | private static final int RES_Y = 800;
|
---|
33 |
|
---|
34 | GameState gameState;
|
---|
35 | AuxState auxState;
|
---|
36 | Point playerLoc;
|
---|
37 |
|
---|
38 | boolean started = false;
|
---|
39 | boolean done, showFps, bounds, passable, minimizedGui;
|
---|
40 | int frameCount, lastFrameCount, refreshRate;
|
---|
41 | long lastFpsUpdate;
|
---|
42 |
|
---|
43 | Graphics g;
|
---|
44 |
|
---|
45 | // GUI elements
|
---|
46 | Frame frmMain;
|
---|
47 |
|
---|
48 | Window wndMain, wndEdit, wndDiagnostics;
|
---|
49 |
|
---|
50 | boolean showCharacter, showInventory, showQuests;
|
---|
51 |
|
---|
52 | ScrollList lstSavedGames;
|
---|
53 |
|
---|
54 | Window wndMessage;
|
---|
55 |
|
---|
56 | DynamicImage yellowCursor, cursor;
|
---|
57 | BufferedImage frame, brightFrame, iconEditor, addButton, cancelButton, removeButton, saveButton, nullImage;
|
---|
58 | BufferedImage[][] bottle_icons;
|
---|
59 |
|
---|
60 | Textbox selectedText;
|
---|
61 |
|
---|
62 | Font font11, font12, font14, font24, fontTT, fontCustom11, fontCustom12, fontCustom14, fontCustom16, fontCustom18,
|
---|
63 | fontCustom24, fontCustom30, guiFont12, guiFont14;
|
---|
64 |
|
---|
65 | FontMetrics m;
|
---|
66 |
|
---|
67 | Map<Integer, WineBottle> wineMap = new HashMap<Integer, WineBottle>();
|
---|
68 | Map<Integer, Cell> locationMap = new HashMap<Integer, Cell>();
|
---|
69 | LinkedList<WineBottle> selectedWines = new LinkedList<WineBottle>();
|
---|
70 | Map<String, BufferedImage[]> imageMap = new HashMap<String, BufferedImage[]>();
|
---|
71 | ArrayList<String> imageNames;
|
---|
72 |
|
---|
73 | int curSize;
|
---|
74 | Cell curCell;
|
---|
75 | String curImageName;
|
---|
76 |
|
---|
77 | static Connection conn;
|
---|
78 |
|
---|
79 | public WineDBClient(GraphicsDevice device) {
|
---|
80 | try {
|
---|
81 | GraphicsConfiguration gc = device.getDefaultConfiguration();
|
---|
82 | frmMain = new Frame(gc);
|
---|
83 | frmMain.setUndecorated(true);
|
---|
84 | frmMain.setIgnoreRepaint(true);
|
---|
85 | device.setFullScreenWindow(frmMain);
|
---|
86 |
|
---|
87 | if (device.isDisplayChangeSupported())
|
---|
88 | Utils.chooseBestDisplayMode(device, RES_X, RES_Y);
|
---|
89 |
|
---|
90 | frmMain.addMouseListener(this);
|
---|
91 | frmMain.addKeyListener(this);
|
---|
92 | frmMain.createBufferStrategy(2);
|
---|
93 | BufferStrategy bufferStrategy = frmMain.getBufferStrategy();
|
---|
94 | g = bufferStrategy.getDrawGraphics();
|
---|
95 | refreshRate = device.getDisplayMode().getRefreshRate();
|
---|
96 |
|
---|
97 | Utils.init(gc, RUNNING_FROM_JAR);
|
---|
98 | gameState = GameState.Main;
|
---|
99 | auxState = AuxState.None;
|
---|
100 | done = false;
|
---|
101 | showFps = false;
|
---|
102 | frameCount = 0;
|
---|
103 | lastFrameCount = 0;
|
---|
104 | lastFpsUpdate = System.nanoTime();
|
---|
105 | playerLoc = new Point(400, 300);
|
---|
106 | selectedText = null;
|
---|
107 |
|
---|
108 | showCharacter = showInventory = showQuests = false;
|
---|
109 |
|
---|
110 | bounds = false;
|
---|
111 | passable = false;
|
---|
112 | minimizedGui = false;
|
---|
113 |
|
---|
114 | Toolkit tk = Toolkit.getDefaultToolkit();
|
---|
115 | frmMain.setCursor(tk.createCustomCursor(tk.createImage(""),new Point(),null));
|
---|
116 |
|
---|
117 | loadGUI(bufferStrategy);
|
---|
118 | loadImages();
|
---|
119 | loadWineList();
|
---|
120 |
|
---|
121 | started = true;
|
---|
122 |
|
---|
123 | while (!done) {
|
---|
124 | g = bufferStrategy.getDrawGraphics();
|
---|
125 | handleGameEvents();
|
---|
126 | render(g);
|
---|
127 | detectMouseOver(g);
|
---|
128 | if(frmMain.getMousePosition() != null)
|
---|
129 | cursor.draw(g, frmMain.getMousePosition().x-5, frmMain.getMousePosition().y-2);
|
---|
130 | g.dispose();
|
---|
131 | bufferStrategy.show();
|
---|
132 |
|
---|
133 | frameCount++;
|
---|
134 | if(System.nanoTime()-1000000000 >= lastFpsUpdate) {
|
---|
135 | lastFpsUpdate = System.nanoTime();
|
---|
136 | lastFrameCount = frameCount;
|
---|
137 | frameCount = 0;
|
---|
138 | }
|
---|
139 | }
|
---|
140 | } catch (Exception e) {
|
---|
141 | e.printStackTrace();
|
---|
142 | } finally {
|
---|
143 | device.setFullScreenWindow(null);
|
---|
144 | }
|
---|
145 | }
|
---|
146 |
|
---|
147 | private static BufferedImage chopBottle(BufferedImage image) {
|
---|
148 | BufferedImage dimg = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_ARGB);
|
---|
149 |
|
---|
150 | Graphics2D g = dimg.createGraphics();
|
---|
151 | g.setComposite(AlphaComposite.Src);
|
---|
152 | g.drawImage(image, 0, 0, 24, 19, 0, 0, 24, 19, null);
|
---|
153 | g.dispose();
|
---|
154 | return dimg;
|
---|
155 | }
|
---|
156 |
|
---|
157 | private void loadGUI(BufferStrategy bufferStrategy) {
|
---|
158 | font11 = new Font("Arial", Font.PLAIN, 11);
|
---|
159 | font12 = new Font("Arial", Font.PLAIN, 12);
|
---|
160 | font14 = new Font("Arial", Font.PLAIN, 14);
|
---|
161 | font24 = new Font("Arial", Font.PLAIN, 24);
|
---|
162 | fontTT = new Font("Courier New", Font.PLAIN, 11);
|
---|
163 | guiFont12 = new Font("Garamond", Font.BOLD, 12);
|
---|
164 | guiFont14 = new Font("Garamond", Font.BOLD, 14);
|
---|
165 | m = g.getFontMetrics(guiFont12);
|
---|
166 |
|
---|
167 | try {
|
---|
168 | Font fontCustom = Utils.loadFont("images/gui/ERASLGHT.TTF");
|
---|
169 | fontCustom11 = fontCustom.deriveFont(Font.PLAIN, 11);
|
---|
170 | fontCustom12 = fontCustom.deriveFont(Font.PLAIN, 12);
|
---|
171 | fontCustom14 = fontCustom.deriveFont(Font.PLAIN, 14);
|
---|
172 | fontCustom16 = fontCustom.deriveFont(Font.PLAIN, 16);
|
---|
173 | fontCustom18 = fontCustom.deriveFont(Font.PLAIN, 18);
|
---|
174 | fontCustom24 = fontCustom.deriveFont(Font.PLAIN, 24);
|
---|
175 | fontCustom30 = fontCustom.deriveFont(Font.PLAIN, 30);
|
---|
176 | }catch(Exception e) {
|
---|
177 | e.printStackTrace();
|
---|
178 | }
|
---|
179 |
|
---|
180 | yellowCursor = new DynamicImage("gui/cursor.png");
|
---|
181 |
|
---|
182 | cursor = yellowCursor;
|
---|
183 |
|
---|
184 | Cell.bg = Utils.loadImg("140x160.png");
|
---|
185 | Cell.wideBg = Utils.loadImg("220x160.png");
|
---|
186 |
|
---|
187 | bottle_icons = new BufferedImage[4][2];
|
---|
188 |
|
---|
189 | iconEditor = Utils.loadImg("IconPopup.png");
|
---|
190 |
|
---|
191 | bottle_icons[0][0] = Utils.loadImg("size icons/375unchecked.png");
|
---|
192 | bottle_icons[0][1] = Utils.loadImg("size icons/375checked.png");
|
---|
193 | bottle_icons[1][0] = Utils.loadImg("size icons/750unchecked.png");
|
---|
194 | bottle_icons[1][1] = Utils.loadImg("size icons/750checked.png");
|
---|
195 | bottle_icons[2][0] = Utils.loadImg("size icons/1500unchecked.png");
|
---|
196 | bottle_icons[2][1] = Utils.loadImg("size icons/1500checked.png");
|
---|
197 | bottle_icons[3][0] = Utils.loadImg("size icons/3000unchecked.png");
|
---|
198 | bottle_icons[3][1] = Utils.loadImg("size icons/3000checked.png");
|
---|
199 |
|
---|
200 | addButton = Utils.loadImg("buttons/AddButton.png");
|
---|
201 | cancelButton = Utils.loadImg("buttons/CancelButton.png");
|
---|
202 | removeButton = Utils.loadImg("buttons/RemoveButton.png");
|
---|
203 | saveButton = Utils.loadImg("buttons/SaveButton.png");
|
---|
204 |
|
---|
205 | nullImage = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
|
---|
206 |
|
---|
207 | wndMain = new Window("main", 0, 0, RES_X, RES_Y, true);
|
---|
208 | wndMain.background = new DynamicImage("Wine GUI 1.png");
|
---|
209 |
|
---|
210 | Textbox search = new Textbox("search", 1085, 242, 169, 30, "", fontCustom18, false);
|
---|
211 | search.setBorder(false);
|
---|
212 |
|
---|
213 | Button close = new Button("close", RES_X-96, 0, 96, 96, Utils.loadImg("CloseButton.png"));
|
---|
214 |
|
---|
215 | wndMain.add(search);
|
---|
216 | wndMain.add(close);
|
---|
217 |
|
---|
218 | wndEdit = new Window("edit", (RES_X-510)/2, 150, 510, 560, true);
|
---|
219 | wndEdit.background = new DynamicImage("Wine Editor Background.png");
|
---|
220 |
|
---|
221 | wndEdit.add(new Textbox("name", 102, 62, 120, 21, "", fontCustom16, false));
|
---|
222 | wndEdit.add(new Textbox("vineyard", 333, 62, 120, 21, "", fontCustom16, false));
|
---|
223 | wndEdit.add(new Textbox("country", 115, 130, 120, 21, "", fontCustom16, false));
|
---|
224 | wndEdit.add(new Textbox("region", 319, 130, 120, 21, "", fontCustom16, false));
|
---|
225 | wndEdit.add(new Textbox("variety", 105, 205, 120, 21, "", fontCustom16, false));
|
---|
226 | wndEdit.add(new Textbox("vintage", 316, 205, 50, 21, "", fontCustom16, false));
|
---|
227 | wndEdit.add(new Textbox("price", 110, 270, 50, 21, "", fontCustom16, false));
|
---|
228 |
|
---|
229 | wndEdit.add(new Label("date added", 369, 268, 50, 21, "", fontCustom16, Color.white));
|
---|
230 |
|
---|
231 | wndEdit.add(new Button("size1", 113, 392-46, 31, 46, bottle_icons[0][0]));
|
---|
232 | wndEdit.add(new Button("size2", 164, 392-60, 41, 60, bottle_icons[1][0]));
|
---|
233 | wndEdit.add(new Button("size3", 220, 392-74, 51, 74, bottle_icons[2][0]));
|
---|
234 | wndEdit.add(new Button("size4", 283, 392-91, 63, 91, bottle_icons[3][0]));
|
---|
235 |
|
---|
236 | wndEdit.add(new Button("icon", 91, 433, 25, 24, null));
|
---|
237 | wndEdit.add(new Button("change_icon", 125, 438, 68, 19, Utils.loadImg("buttons/ChangeIcon.png")));
|
---|
238 |
|
---|
239 | wndEdit.add(new Button("button1", 80, 495, 131, 32, addButton));
|
---|
240 | wndEdit.add(new Button("button2", 310, 495, 131, 32, cancelButton));
|
---|
241 |
|
---|
242 | wndEdit.add(new Button("close", 449, 12, 51, 51, Utils.loadImg("SmallCloseButton.png")));
|
---|
243 |
|
---|
244 | wndMessage = new Window("message", 290, 135, 220, 160);
|
---|
245 | wndMessage.add(new Label("label", 20, 15, 180, 12, "none", font12, Align.Center));
|
---|
246 | wndMessage.add(new Button("button", 70, 115, 80, 30, "OK", font12, Align.Center));
|
---|
247 |
|
---|
248 | wndDiagnostics = new Window("diagnostics", 0, 0, 400, 140, true);
|
---|
249 | }
|
---|
250 |
|
---|
251 | private void loadImages() {
|
---|
252 | File imageDir = new File("images/bottles");
|
---|
253 |
|
---|
254 | File[] images = imageDir.listFiles();
|
---|
255 |
|
---|
256 | for(int x=0; x<images.length; x++) {
|
---|
257 | BufferedImage[] imageArr = new BufferedImage[4];
|
---|
258 |
|
---|
259 | imageArr[0] = Utils.loadImg("bottles/"+images[x].getName());
|
---|
260 | imageArr[1] = WineDBClient.chopBottle(imageArr[0]);
|
---|
261 | imageArr[2] = Utils.brightenImage(imageArr[0]);
|
---|
262 | imageArr[3] = Utils.brightenImage(imageArr[1]);
|
---|
263 |
|
---|
264 | imageMap.put(images[x].getName(), imageArr);
|
---|
265 | }
|
---|
266 | }
|
---|
267 |
|
---|
268 | private String getIndexedField(int id, String table) {
|
---|
269 | Statement stmt = null;
|
---|
270 | ResultSet rs = null;
|
---|
271 | String name = "";
|
---|
272 |
|
---|
273 | if(id == 0)
|
---|
274 | return "";
|
---|
275 |
|
---|
276 | try {
|
---|
277 | stmt = conn.createStatement();
|
---|
278 | rs = stmt.executeQuery("SELECT name FROM "+table+" WHERE id='"+id+"'");
|
---|
279 | rs.next();
|
---|
280 |
|
---|
281 | name = rs.getString("name");
|
---|
282 | }catch(SQLException ex) {
|
---|
283 | System.out.println("SQLException: " + ex.getMessage());
|
---|
284 | System.out.println("SQLState: " + ex.getSQLState());
|
---|
285 | System.out.println("VendorError: " + ex.getErrorCode());
|
---|
286 | ex.printStackTrace();
|
---|
287 | }
|
---|
288 |
|
---|
289 | return name;
|
---|
290 | }
|
---|
291 |
|
---|
292 | private void loadWineList() {
|
---|
293 | frame = Utils.loadImg("Empty Cell.png");
|
---|
294 | brightFrame = Utils.brightenImage(frame);
|
---|
295 |
|
---|
296 | int x = 0, y = 0, yStart, height;
|
---|
297 |
|
---|
298 | yStart = 220;
|
---|
299 | for(int k=0; k<3; k++) {
|
---|
300 | x=54;
|
---|
301 | for(int i=0; i<10; i++) {
|
---|
302 | y = yStart;
|
---|
303 | for(int j=0; j<4; j++) {
|
---|
304 | locationMap.put((x<<12) + y, new Cell(x, y, Utils.getLoc(3, k+1, i+1, j+1), null, frame, brightFrame));
|
---|
305 |
|
---|
306 | y += 24;
|
---|
307 | }
|
---|
308 | x += 29;
|
---|
309 | }
|
---|
310 | yStart += 121;
|
---|
311 | }
|
---|
312 | x=54;
|
---|
313 | for(int i=0; i<10; i++) {
|
---|
314 | y = yStart;
|
---|
315 | for(int j=0; j<3; j++) {
|
---|
316 | locationMap.put((x<<12) + y, new Cell(x, y, Utils.getLoc(3, 4, i+1 ,j+1), null, frame, brightFrame));
|
---|
317 |
|
---|
318 | y += 24;
|
---|
319 | }
|
---|
320 | x += 29;
|
---|
321 | }
|
---|
322 |
|
---|
323 | yStart = 220;
|
---|
324 | for(int k=0; k<3; k++) {
|
---|
325 | x=349;
|
---|
326 | for(int i=0; i<10; i++) {
|
---|
327 | y = yStart;
|
---|
328 | for(int j=0; j<4; j++) {
|
---|
329 | locationMap.put((x<<12) + y, new Cell(x, y, Utils.getLoc(4, k+1, i+1, j+1), null, frame, brightFrame));
|
---|
330 |
|
---|
331 | y += 24;
|
---|
332 | }
|
---|
333 | x += 29;
|
---|
334 | }
|
---|
335 | yStart += 121;
|
---|
336 | }
|
---|
337 | x=349;
|
---|
338 | for(int i=0; i<10; i++) {
|
---|
339 | y = yStart;
|
---|
340 | for(int j=0; j<3; j++) {
|
---|
341 | locationMap.put((x<<12) + y, new Cell(x, y, Utils.getLoc(4, 4, i+1, j+1), null, frame, brightFrame));
|
---|
342 |
|
---|
343 | y += 24;
|
---|
344 | }
|
---|
345 | x += 29;
|
---|
346 | }
|
---|
347 |
|
---|
348 | yStart=237;
|
---|
349 | height = 7;
|
---|
350 | for(int k=0; k<3; k++) {
|
---|
351 | x=644;
|
---|
352 | for(int i=0; i<8; i++) {
|
---|
353 | y = yStart;
|
---|
354 | for(int j=0; j<height-1; j++) {
|
---|
355 | locationMap.put((x<<12) + y, new Cell(x, y, Utils.getLoc(2, k+1, i+1, j+1), null, frame, brightFrame));
|
---|
356 |
|
---|
357 | y += 24;
|
---|
358 | }
|
---|
359 | x += 29;
|
---|
360 | }
|
---|
361 | yStart += 149+(height-6)*24; //stupid hack
|
---|
362 | height--;
|
---|
363 | }
|
---|
364 |
|
---|
365 | yStart = 237;
|
---|
366 | for(int k=0; k<3; k++) {
|
---|
367 | x=880;
|
---|
368 | for(int i=0; i<6; i++) {
|
---|
369 | y = yStart;
|
---|
370 | for(int j=0; j<5; j++) {
|
---|
371 | locationMap.put((x<<12) + y, new Cell(x, y, Utils.getLoc(1, k+1, i+1, j+1), null, frame, brightFrame));
|
---|
372 |
|
---|
373 | y += 24;
|
---|
374 | }
|
---|
375 | x += 29;
|
---|
376 | }
|
---|
377 | yStart += 149;
|
---|
378 | }
|
---|
379 |
|
---|
380 | Connection conn = null;
|
---|
381 | Statement stmt = null;
|
---|
382 | ResultSet rs = null;
|
---|
383 |
|
---|
384 | try {
|
---|
385 | conn = DriverManager.getConnection("jdbc:mysql://localhost/wines", "root", "");
|
---|
386 |
|
---|
387 | stmt = conn.createStatement();
|
---|
388 | rs = stmt.executeQuery("SELECT * FROM wines");
|
---|
389 |
|
---|
390 | int loc, rack, newRack, section, col, row;
|
---|
391 |
|
---|
392 | WineBottle newBottle;
|
---|
393 | while (rs.next()) {
|
---|
394 | loc = rs.getInt("cellar_location");
|
---|
395 |
|
---|
396 | if(loc == 0)
|
---|
397 | continue;
|
---|
398 |
|
---|
399 | newRack = Utils.getRack(loc);
|
---|
400 |
|
---|
401 | if(newRack == 1)
|
---|
402 | newRack = 4;
|
---|
403 | else if(newRack == 2)
|
---|
404 | newRack = 3;
|
---|
405 | else if(newRack == 3)
|
---|
406 | newRack = 1;
|
---|
407 | else if(newRack == 4)
|
---|
408 | newRack = 2;
|
---|
409 |
|
---|
410 | int oldLoc = loc;
|
---|
411 | loc = (newRack << 24) + (loc & 0xFFFFFF);
|
---|
412 |
|
---|
413 | rack = Utils.getRack(loc);
|
---|
414 | section = Utils.getSection(loc);
|
---|
415 | col = Utils.getColumn(loc);
|
---|
416 | row = Utils.getRow(loc);
|
---|
417 | if(col == 0)
|
---|
418 | col = 10;
|
---|
419 |
|
---|
420 | boolean chopped = false;
|
---|
421 | switch(rack) {
|
---|
422 | case 1:
|
---|
423 | x = 54+29*(col-1);
|
---|
424 | y = 220+121*(section-1)+24*(row-1);
|
---|
425 | if(row == 5 || (row == 4 && section == 4))
|
---|
426 | chopped = true;
|
---|
427 | break;
|
---|
428 | case 2:
|
---|
429 | x = 349+29*(col-1);
|
---|
430 | y = 220+121*(section-1)+24*(row-1);
|
---|
431 | if(row == 5 || (row == 4 && section == 4))
|
---|
432 | chopped = true;
|
---|
433 | break;
|
---|
434 | case 3:
|
---|
435 | x = 644+29*(col-1);
|
---|
436 | y = 237+149*(section-1)+24*(row-1);
|
---|
437 |
|
---|
438 | if(section > 1)
|
---|
439 | y += 24;
|
---|
440 |
|
---|
441 | if(row == 8-section)
|
---|
442 | chopped = true;
|
---|
443 | break;
|
---|
444 | case 4:
|
---|
445 | x = 880+29*(col-1);
|
---|
446 | y = 237+149*(section-1)+24*(row-1);
|
---|
447 | if(row == 6)
|
---|
448 | chopped = true;
|
---|
449 | break;
|
---|
450 | }
|
---|
451 |
|
---|
452 | newBottle = new WineBottle(rs.getString("name"), getIndexedField(rs.getInt("winery_id"), "wineries"), rs.getInt("vintage"), getIndexedField(rs.getInt("country_id"), "countries"), getIndexedField(rs.getInt("region_id"), "regions"), getIndexedField(rs.getInt("variety_id"), "varieties"), rs.getString("date_added"), rs.getInt("size"), rs.getInt("price"), rs.getString("image"));
|
---|
453 | if(!chopped)
|
---|
454 | locationMap.put((x<<12) + y, new Cell(x, y, oldLoc, newBottle, imageMap.get(rs.getString("image"))[0], imageMap.get(rs.getString("image"))[2]));
|
---|
455 | else
|
---|
456 | locationMap.put((x<<12) + y, new Cell(x, y, oldLoc, newBottle, imageMap.get(rs.getString("image"))[1], imageMap.get(rs.getString("image"))[3]));
|
---|
457 | wineMap.put(rs.getInt("id"), newBottle);
|
---|
458 | }
|
---|
459 | }catch(SQLException ex) {
|
---|
460 | System.out.println("SQLException: " + ex.getMessage());
|
---|
461 | System.out.println("SQLState: " + ex.getSQLState());
|
---|
462 | System.out.println("VendorError: " + ex.getErrorCode());
|
---|
463 | ex.printStackTrace();
|
---|
464 | }
|
---|
465 | }
|
---|
466 |
|
---|
467 | private synchronized void handleGameEvents() {
|
---|
468 | switch(gameState) {
|
---|
469 | }
|
---|
470 | }
|
---|
471 | ;
|
---|
472 | private synchronized void render(Graphics g) {
|
---|
473 | g.setColor(Color.black);
|
---|
474 | g.fillRect(0, 0, RES_X, RES_Y);
|
---|
475 |
|
---|
476 | Point e;
|
---|
477 | Iterator<Cell> it;
|
---|
478 | Cell cur;
|
---|
479 |
|
---|
480 | switch(gameState) {
|
---|
481 | case Main:
|
---|
482 | wndMain.draw(g);
|
---|
483 |
|
---|
484 | e = frmMain.getMousePosition();
|
---|
485 |
|
---|
486 | it = locationMap.values().iterator();
|
---|
487 | Cell selected = null;
|
---|
488 | while(it.hasNext()) {
|
---|
489 | cur = it.next();
|
---|
490 | if(e != null && cur.getX() <= e.x && e.x < cur.getX()+25 && cur.getY() <= e.y && e.y < cur.getY()+24) {
|
---|
491 | cur.drawBright(g);
|
---|
492 | if(cur.bottle != null)
|
---|
493 | selected = cur;
|
---|
494 | }else
|
---|
495 | cur.draw(g);
|
---|
496 | }
|
---|
497 |
|
---|
498 | if(selected != null)
|
---|
499 | selected.drawDescription(g, e.x, e.y, fontCustom14);
|
---|
500 | break;
|
---|
501 | case ChangeBottle:
|
---|
502 | wndMain.draw(g);
|
---|
503 |
|
---|
504 | e = frmMain.getMousePosition();
|
---|
505 |
|
---|
506 | it = locationMap.values().iterator();
|
---|
507 | while(it.hasNext()) {
|
---|
508 | it.next().draw(g);
|
---|
509 | }
|
---|
510 |
|
---|
511 | wndEdit.draw(g);
|
---|
512 | break;
|
---|
513 | case ChangeIcon:
|
---|
514 | wndMain.draw(g);
|
---|
515 |
|
---|
516 | e = frmMain.getMousePosition();
|
---|
517 |
|
---|
518 | it = locationMap.values().iterator();
|
---|
519 | while(it.hasNext()) {
|
---|
520 | it.next().draw(g);
|
---|
521 | }
|
---|
522 |
|
---|
523 | wndEdit.draw(g);
|
---|
524 | g.drawImage(iconEditor, (RES_X-480)/2, 578, null);
|
---|
525 |
|
---|
526 | Iterator<BufferedImage[]> iter = imageMap.values().iterator();
|
---|
527 |
|
---|
528 | int i=0, x=(RES_X-480)/2+2, y=580;
|
---|
529 | while(iter.hasNext()) {
|
---|
530 | if(x-2 <= e.x && e.x < x+28 && y-2 <= e.y && e.y < y+27)
|
---|
531 | g.drawImage(iter.next()[2], x, y, null);
|
---|
532 | else
|
---|
533 | g.drawImage(iter.next()[0], x, y, null);
|
---|
534 |
|
---|
535 | x += 30;
|
---|
536 |
|
---|
537 | i ++;
|
---|
538 | if(i >= 16) {
|
---|
539 | x=(RES_X-480)/2+2;
|
---|
540 | y += 29;
|
---|
541 | i = 0;
|
---|
542 | }
|
---|
543 | }
|
---|
544 |
|
---|
545 |
|
---|
546 | break;
|
---|
547 | }
|
---|
548 |
|
---|
549 | switch(auxState) {
|
---|
550 | case None:
|
---|
551 | break;
|
---|
552 | case MsgBox:
|
---|
553 | wndMessage.draw(g);
|
---|
554 | break;
|
---|
555 | }
|
---|
556 |
|
---|
557 | if(showFps)
|
---|
558 | drawDiagnostics(g);
|
---|
559 | }
|
---|
560 |
|
---|
561 | public void showMessage(String text) {
|
---|
562 | auxState = AuxState.MsgBox;
|
---|
563 | ((Label) wndMessage.getMember("label")).setText(text);
|
---|
564 | }
|
---|
565 |
|
---|
566 | private void drawDiagnostics(Graphics g) {
|
---|
567 | wndDiagnostics.draw(g);
|
---|
568 |
|
---|
569 | g.setColor(Color.green);
|
---|
570 | g.setFont(fontTT);
|
---|
571 | g.drawString("Unthrottled FPS: "+lastFrameCount, 0, 15);
|
---|
572 | g.drawString("Monitor Refresh Rate: "+refreshRate, 0, 30);
|
---|
573 | }
|
---|
574 |
|
---|
575 | private void updateSelectedWines(String search) {
|
---|
576 | Connection conn = null;
|
---|
577 | Statement stmt = null;
|
---|
578 | ResultSet rs = null;
|
---|
579 |
|
---|
580 | Iterator<WineBottle> it = selectedWines.iterator();
|
---|
581 |
|
---|
582 | while(it.hasNext())
|
---|
583 | it.next().unselect();
|
---|
584 | selectedWines.clear();
|
---|
585 |
|
---|
586 | if(search.equals(""))
|
---|
587 | return;
|
---|
588 |
|
---|
589 | try {
|
---|
590 | conn = DriverManager.getConnection("jdbc:mysql://localhost/wines", "root", "");
|
---|
591 |
|
---|
592 | stmt = conn.createStatement();
|
---|
593 | rs = stmt.executeQuery("SELECT id FROM wines WHERE name LIKE '%" + search + "%' AND cellar_location != 0");
|
---|
594 |
|
---|
595 | WineBottle cur;
|
---|
596 | while(rs.next()) {
|
---|
597 | cur = wineMap.get(rs.getInt("id"));
|
---|
598 | cur.select();
|
---|
599 | selectedWines.add(cur);
|
---|
600 | }
|
---|
601 | }catch(SQLException ex) {
|
---|
602 | System.out.println("SQLException: " + ex.getMessage());
|
---|
603 | System.out.println("SQLState: " + ex.getSQLState());
|
---|
604 | System.out.println("VendorError: " + ex.getErrorCode());
|
---|
605 | ex.printStackTrace();
|
---|
606 | }
|
---|
607 | }
|
---|
608 |
|
---|
609 | private synchronized void detectMouseOver(Graphics g) {
|
---|
610 | Point e = frmMain.getMousePosition();
|
---|
611 |
|
---|
612 | if(e == null)
|
---|
613 | return;
|
---|
614 |
|
---|
615 | switch(gameState) {
|
---|
616 | case Main:
|
---|
617 | break;
|
---|
618 | }
|
---|
619 | }
|
---|
620 |
|
---|
621 | private synchronized void handleMouseInput(MouseEvent e) {
|
---|
622 | if(!started)
|
---|
623 | return;
|
---|
624 |
|
---|
625 | selectText(null);
|
---|
626 |
|
---|
627 | Iterator<Cell> it;
|
---|
628 | Cell cur;
|
---|
629 |
|
---|
630 | switch (auxState) {
|
---|
631 | case None:
|
---|
632 | switch (gameState) {
|
---|
633 | case Main:
|
---|
634 | if(wndMain.getMember("search").isClicked(e.getX(), e.getY()))
|
---|
635 | selectText((Textbox)wndMain.getMember("search"));
|
---|
636 | else if(wndMain.getMember("close").isClicked(e.getX(), e.getY()))
|
---|
637 | done = true;
|
---|
638 |
|
---|
639 | it = locationMap.values().iterator();
|
---|
640 | while(it.hasNext()) {
|
---|
641 | cur = it.next();
|
---|
642 | if(cur.getX() <= e.getX() && e.getX() < cur.getX()+25 && cur.getY() <= e.getY() && e.getY() < cur.getY()+24) {
|
---|
643 | if(cur.bottle == null) {
|
---|
644 | ((Textbox)wndEdit.getMember("name")).setText("");
|
---|
645 | ((Textbox)wndEdit.getMember("vineyard")).setText("");
|
---|
646 | ((Textbox)wndEdit.getMember("country")).setText("");
|
---|
647 | ((Textbox)wndEdit.getMember("region")).setText("");
|
---|
648 | ((Textbox)wndEdit.getMember("variety")).setText("");
|
---|
649 | ((Textbox)wndEdit.getMember("vintage")).setText("");
|
---|
650 | ((Textbox)wndEdit.getMember("price")).setText("");
|
---|
651 |
|
---|
652 | if(curSize != -1)
|
---|
653 | ((Button)wndEdit.getMember("size"+(curSize+1))).setImage(bottle_icons[curSize][0]);
|
---|
654 | curSize = -1;
|
---|
655 |
|
---|
656 | Calendar calendar = Calendar.getInstance();
|
---|
657 | SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
|
---|
658 | ((Label)wndEdit.getMember("date added")).setText(dateFormat.format(calendar.getTime()));
|
---|
659 |
|
---|
660 | curImageName = "";
|
---|
661 | ((Button)wndEdit.getMember("icon")).setImage(nullImage);
|
---|
662 |
|
---|
663 | ((Button)wndEdit.getMember("button1")).setImage(addButton);
|
---|
664 | ((Button)wndEdit.getMember("button2")).setImage(cancelButton);
|
---|
665 | }else {
|
---|
666 | ((Textbox)wndEdit.getMember("name")).setText(cur.bottle.getName());
|
---|
667 | ((Textbox)wndEdit.getMember("vineyard")).setText(cur.bottle.getVineyard());
|
---|
668 | ((Textbox)wndEdit.getMember("country")).setText(cur.bottle.getCountry());
|
---|
669 | ((Textbox)wndEdit.getMember("region")).setText(cur.bottle.getRegion());
|
---|
670 | ((Textbox)wndEdit.getMember("variety")).setText(cur.bottle.getVariety());
|
---|
671 | ((Textbox)wndEdit.getMember("vintage")).setText(Integer.toString(cur.bottle.getVintage()));
|
---|
672 |
|
---|
673 | switch(cur.bottle.getSize()) {
|
---|
674 | case 375:
|
---|
675 | curSize = 0;
|
---|
676 | break;
|
---|
677 | case 750:
|
---|
678 | curSize = 1;
|
---|
679 | break;
|
---|
680 | case 1500:
|
---|
681 | curSize = 2;
|
---|
682 | break;
|
---|
683 | case 3000:
|
---|
684 | curSize = 3;
|
---|
685 | break;
|
---|
686 | }
|
---|
687 | ((Button)wndEdit.getMember("size"+(curSize+1))).setImage(bottle_icons[curSize][1]);
|
---|
688 |
|
---|
689 | ((Textbox)wndEdit.getMember("price")).setText(Integer.toString(cur.bottle.getPrice()));
|
---|
690 | ((Label)wndEdit.getMember("date added")).setText(cur.bottle.getDateAdded());
|
---|
691 |
|
---|
692 | ((Button)wndEdit.getMember("icon")).setImage(imageMap.get(cur.bottle.getImageName())[0]);
|
---|
693 | curImageName = cur.bottle.getImageName();
|
---|
694 |
|
---|
695 | ((Button)wndEdit.getMember("button1")).setImage(saveButton);
|
---|
696 | ((Button)wndEdit.getMember("button2")).setImage(removeButton);
|
---|
697 | }
|
---|
698 | curCell = cur;
|
---|
699 | gameState = GameState.ChangeBottle;
|
---|
700 | break;
|
---|
701 | }
|
---|
702 | }
|
---|
703 |
|
---|
704 | break;
|
---|
705 | case ChangeBottle:
|
---|
706 | if(wndEdit.getMember("name").isClicked(e.getX(), e.getY()))
|
---|
707 | selectText((Textbox)wndEdit.getMember("name"));
|
---|
708 | else if(wndEdit.getMember("vineyard").isClicked(e.getX(), e.getY()))
|
---|
709 | selectText((Textbox)wndEdit.getMember("vineyard"));
|
---|
710 | else if(wndEdit.getMember("country").isClicked(e.getX(), e.getY()))
|
---|
711 | selectText((Textbox)wndEdit.getMember("country"));
|
---|
712 | else if(wndEdit.getMember("region").isClicked(e.getX(), e.getY()))
|
---|
713 | selectText((Textbox)wndEdit.getMember("region"));
|
---|
714 | else if(wndEdit.getMember("variety").isClicked(e.getX(), e.getY()))
|
---|
715 | selectText((Textbox)wndEdit.getMember("variety"));
|
---|
716 | else if(wndEdit.getMember("vintage").isClicked(e.getX(), e.getY()))
|
---|
717 | selectText((Textbox)wndEdit.getMember("vintage"));
|
---|
718 | else if(wndEdit.getMember("price").isClicked(e.getX(), e.getY()))
|
---|
719 | selectText((Textbox)wndEdit.getMember("price"));
|
---|
720 | else if(wndEdit.getMember("change_icon").isClicked(e.getX(), e.getY()))
|
---|
721 | gameState = GameState.ChangeIcon;
|
---|
722 | else if(wndEdit.getMember("button1").isClicked(e.getX(), e.getY())) {
|
---|
723 | if(curCell.bottle == null) {
|
---|
724 | String name, winery, vintage, country, region, variety, location, date_added, date_drank, rating, price, image;
|
---|
725 | int loc_num, rack, section, column, row, winery_id, country_id, region_id, variety_id, size;
|
---|
726 |
|
---|
727 | name = ((Textbox)wndEdit.getMember("name")).getText();
|
---|
728 | name = name.replace("'", "\\'");
|
---|
729 | if(name.equals("")) {
|
---|
730 | showMessage("Name is blank");
|
---|
731 | return;
|
---|
732 | }
|
---|
733 |
|
---|
734 | vintage = ((Textbox)wndEdit.getMember("vintage")).getText();
|
---|
735 | if(vintage.equals("")) {
|
---|
736 | showMessage("No vintage specified");
|
---|
737 | return;
|
---|
738 | }
|
---|
739 |
|
---|
740 | /*if(line.substring(0, 1).equals("\"")) {
|
---|
741 | winery = line.substring(0, line.indexOf(",", line.lastIndexOf("\"")));
|
---|
742 | line = line.substring(line.indexOf(",", line.lastIndexOf("\""))+1);
|
---|
743 | winery = winery.substring(1, winery.length()-1);
|
---|
744 | }else {
|
---|
745 | winery = line.substring(0, line.indexOf(","));
|
---|
746 | line = line.substring(line.indexOf(",")+1);
|
---|
747 | winery = winery.trim();
|
---|
748 | }
|
---|
749 | winery_id = getId(winery, "wineries");
|
---|
750 |
|
---|
751 | country = line.substring(0, line.indexOf(","));
|
---|
752 | line = line.substring(line.indexOf(",")+1);
|
---|
753 | if(country.equals("U.S.A."))
|
---|
754 | country = "USA";
|
---|
755 | country_id = getId(country, "countries");
|
---|
756 |
|
---|
757 | if(line.substring(0, 1).equals("\"")) {
|
---|
758 | region = line.substring(0, line.indexOf(",", line.lastIndexOf("\"")));
|
---|
759 | line = line.substring(line.indexOf(",", line.lastIndexOf("\""))+1);
|
---|
760 | region = region.substring(1, region.length()-1);
|
---|
761 | }else {
|
---|
762 | region = line.substring(0, line.indexOf(","));
|
---|
763 | line = line.substring(line.indexOf(",")+1);
|
---|
764 | region = region.trim();
|
---|
765 | }
|
---|
766 | region_id = getId(region, "regions");
|
---|
767 |
|
---|
768 | variety = line.substring(0, line.indexOf(","));
|
---|
769 | line = line.substring(line.indexOf(",")+1);
|
---|
770 | variety_id = getId(variety, "varieties");*/
|
---|
771 |
|
---|
772 | location = Integer.toString(curCell.getLocation());
|
---|
773 |
|
---|
774 | /*rating = line.substring(0, line.indexOf(","));
|
---|
775 | line = line.substring(line.indexOf(",")+1);*/
|
---|
776 |
|
---|
777 | date_drank = "0000-00-00";
|
---|
778 |
|
---|
779 | size = 0;
|
---|
780 | System.out.println("curSize is currently "+curSize);
|
---|
781 | switch(curSize) {
|
---|
782 | case 0:
|
---|
783 | size = 375;
|
---|
784 | break;
|
---|
785 | case 1:
|
---|
786 | size = 750;
|
---|
787 | break;
|
---|
788 | case 2:
|
---|
789 | size = 1500;
|
---|
790 | break;
|
---|
791 | case 3:
|
---|
792 | size = 3000;
|
---|
793 | break;
|
---|
794 | default:
|
---|
795 | showMessage("No bottle size selected");
|
---|
796 | return;
|
---|
797 | }
|
---|
798 |
|
---|
799 | price = ((Textbox)wndEdit.getMember("price")).getText();
|
---|
800 | if(price.equals("")) {
|
---|
801 | showMessage("No price specified");
|
---|
802 | return;
|
---|
803 | }
|
---|
804 |
|
---|
805 | image = curImageName;
|
---|
806 | if(image.equals("")) {
|
---|
807 | showMessage("No image selected");
|
---|
808 | return;
|
---|
809 | }
|
---|
810 |
|
---|
811 | /*String winery_id_string, country_id_string, region_id_string, variety_id_string;
|
---|
812 |
|
---|
813 | if(winery_id == 0)
|
---|
814 | winery_id_string = "NULL";
|
---|
815 | else
|
---|
816 | winery_id_string = "'"+winery_id+"'";
|
---|
817 |
|
---|
818 | if(country_id == 0)
|
---|
819 | country_id_string = "NULL";
|
---|
820 | else
|
---|
821 | country_id_string = "'"+country_id+"'";
|
---|
822 |
|
---|
823 | if(region_id == 0)
|
---|
824 | region_id_string = "NULL";
|
---|
825 | else
|
---|
826 | region_id_string = "'"+region_id+"'";
|
---|
827 |
|
---|
828 | if(variety_id == 0)
|
---|
829 | variety_id_string = "NULL";
|
---|
830 | else
|
---|
831 | variety_id_string = "'"+variety_id+"'";*/
|
---|
832 |
|
---|
833 | System.out.println(location);
|
---|
834 | try {
|
---|
835 | Statement stmt = conn.createStatement();
|
---|
836 | stmt.executeUpdate("INSERT INTO wines (name, winery_id, vintage, country_id, region_id, variety_id, date_added, date_drank, size, price, image, cellar_location) VALUES ('"+name+"', NULL, '"+vintage+"', NULL, NULL, NULL, CURDATE(), '"+date_drank+"', '"+size+"', '"+price+"', '"+image+"', '"+location+"')");
|
---|
837 | //stmt.executeUpdate("INSERT INTO wines (name, winery_id, vintage, country_id, region_id, variety_id, date_added, date_drank, size, image, cellar_location) VALUES ('"+name+"', "+winery_id_string+", '"+vintage+"', "+country_id_string+", "+region_id_string+", "+variety_id_string+", '"+date_added+"', '"+date_drank+"', '"+size+"', '"+image+"', '"+loc_num+"')");
|
---|
838 | }catch(SQLException ex) {
|
---|
839 | // handle any errors
|
---|
840 | System.out.println("SQLException: " + ex.getMessage());
|
---|
841 | System.out.println("SQLState: " + ex.getSQLState());
|
---|
842 | System.out.println("VendorError: " + ex.getErrorCode());
|
---|
843 | }
|
---|
844 | }else
|
---|
845 | gameState = GameState.ChangeIcon;
|
---|
846 | }else if(wndEdit.getMember("button2").isClicked(e.getX(), e.getY())) {
|
---|
847 | if(curCell.bottle == null) {
|
---|
848 | gameState = GameState.Main;
|
---|
849 | }else
|
---|
850 | gameState = GameState.ChangeIcon;
|
---|
851 | }else if(wndEdit.getMember("close").isClicked(e.getX(), e.getY()))
|
---|
852 | gameState = GameState.Main;
|
---|
853 | else {
|
---|
854 | for(int x=0; x<4; x++) {
|
---|
855 | if(wndEdit.getMember("size"+(x+1)).isClicked(e.getX(), e.getY())) {
|
---|
856 | if(curSize != -1)
|
---|
857 | ((Button)wndEdit.getMember("size"+(curSize+1))).setImage(bottle_icons[curSize][0]);
|
---|
858 | ((Button)wndEdit.getMember("size"+(x+1))).setImage(bottle_icons[x][1]);
|
---|
859 | curSize = x;
|
---|
860 | System.out.println("curSize set to "+curSize);
|
---|
861 | }
|
---|
862 | }
|
---|
863 | }
|
---|
864 | break;
|
---|
865 | case ChangeIcon:
|
---|
866 | int i = e.getX()-((RES_X-480)/2), j = e.getY()-578;
|
---|
867 |
|
---|
868 | if(0 <= i && 0 <= i/30 && i/30 < 16) {
|
---|
869 | i /= 30;
|
---|
870 |
|
---|
871 | if(0 <= j && 0 <= j/29 && i+16*(j/29) < imageMap.values().size()) {
|
---|
872 | ((Button)wndEdit.getMember("icon")).setImage(imageMap.values().toArray(new BufferedImage[0][0])[i+16*(j/29)][0]);
|
---|
873 | curImageName = imageMap.keySet().toArray(new String[0])[i+16*(j/29)];
|
---|
874 | }
|
---|
875 | }
|
---|
876 |
|
---|
877 | gameState = GameState.ChangeBottle;
|
---|
878 | break;
|
---|
879 | }
|
---|
880 | break;
|
---|
881 | case MsgBox:
|
---|
882 | if (wndMessage.getMember("button").isClicked(e.getX(), e.getY()))
|
---|
883 | auxState = AuxState.None;
|
---|
884 | break;
|
---|
885 | }
|
---|
886 | }
|
---|
887 |
|
---|
888 | private synchronized void handleMouseRelease(MouseEvent e) {
|
---|
889 |
|
---|
890 | }
|
---|
891 |
|
---|
892 | private synchronized void handleKeyboardInput(KeyEvent e) {
|
---|
893 | if (selectedText != null) {
|
---|
894 | selectedText.handleEvent(e);
|
---|
895 | if(selectedText == wndMain.getMember("search")) {
|
---|
896 | updateSelectedWines(((Textbox)wndMain.getMember("search")).getText());
|
---|
897 | }
|
---|
898 | }else if (e.getKeyCode() == KeyEvent.VK_ESCAPE)
|
---|
899 | done = true;
|
---|
900 | else if(e.getKeyCode() == KeyEvent.VK_S)
|
---|
901 | showFps = !showFps;
|
---|
902 | else if(e.getKeyCode() == KeyEvent.VK_X) {
|
---|
903 | if(gameState == GameState.Main)
|
---|
904 | gameState = GameState.ChangeBottle;
|
---|
905 | else
|
---|
906 | gameState = GameState.Main;
|
---|
907 | }
|
---|
908 | }
|
---|
909 |
|
---|
910 | public void mousePressed(MouseEvent e) {
|
---|
911 | handleMouseInput(e);
|
---|
912 | }
|
---|
913 |
|
---|
914 | public void mouseReleased(MouseEvent e) {
|
---|
915 | handleMouseRelease(e);
|
---|
916 | }
|
---|
917 |
|
---|
918 | public void mouseEntered(MouseEvent e) {
|
---|
919 |
|
---|
920 | }
|
---|
921 |
|
---|
922 | public void mouseExited(MouseEvent e) {
|
---|
923 |
|
---|
924 | }
|
---|
925 |
|
---|
926 | public void mouseClicked(MouseEvent e) {
|
---|
927 |
|
---|
928 | }
|
---|
929 |
|
---|
930 | public void keyTyped(KeyEvent e) {
|
---|
931 |
|
---|
932 | }
|
---|
933 |
|
---|
934 | public synchronized void keyPressed(KeyEvent e) {
|
---|
935 | handleKeyboardInput(e);
|
---|
936 | }
|
---|
937 |
|
---|
938 | public void keyReleased(KeyEvent e) {
|
---|
939 |
|
---|
940 | }
|
---|
941 |
|
---|
942 | private void selectText(Textbox text) {
|
---|
943 | if (selectedText != null)
|
---|
944 | selectedText.setSelected(false);
|
---|
945 | selectedText = text;
|
---|
946 |
|
---|
947 | if (text != null)
|
---|
948 | text.setSelected(true);
|
---|
949 | }
|
---|
950 |
|
---|
951 | public static void main(String[] args) {
|
---|
952 | try {
|
---|
953 | PrintStream st = new PrintStream(new FileOutputStream("err.txt",true));
|
---|
954 | System.setErr(st);
|
---|
955 | System.setOut(st);
|
---|
956 | System.out.println("-----[ Session started on " + Utils.dateString() + " ]-----");
|
---|
957 |
|
---|
958 | Class.forName("com.mysql.jdbc.Driver").newInstance();
|
---|
959 | conn = DriverManager.getConnection("jdbc:mysql://localhost/wines", "root", "");
|
---|
960 |
|
---|
961 | GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
|
---|
962 | GraphicsDevice device = env.getDefaultScreenDevice();
|
---|
963 | new WineDBClient(device);
|
---|
964 | } catch (Exception e) {
|
---|
965 | e.printStackTrace();
|
---|
966 | }
|
---|
967 | System.exit(0);
|
---|
968 | }
|
---|
969 | } |
---|