/** * Paints the graphic component * * @param g Graphic component */ public void paint(Graphics g) { if (environment != null) { Sudoku env = (Sudoku) environment; Board board = env.getBoard(); int n = SudokuLanguage.DIGITS; int sqrt_n = (int) (Math.sqrt(n) + 0.1); g.setColor(Color.lightGray); Font font = g.getFont(); g.setFont(new Font(font.getName(), font.getStyle(), 20)); for (int i = 0; i < n; i++) { int ci = getCanvasValue(i); if (i % sqrt_n == 0) { g.drawLine(ci, DRAW_AREA_SIZE + MARGIN, ci, MARGIN); g.drawLine(DRAW_AREA_SIZE + MARGIN, ci, MARGIN, ci); } for (int j = 0; j < n; j++) { int cj = getCanvasValue(j); int value = board.get(i, j); if (value > 0) { g.setColor(Color.black); g.drawString("" + value, cj + CELL_SIZE / 5, ci + CELL_SIZE); g.setColor(Color.lightGray); } } } g.drawLine(DRAW_AREA_SIZE + MARGIN, DRAW_AREA_SIZE + MARGIN, DRAW_AREA_SIZE + MARGIN, MARGIN); g.drawLine(DRAW_AREA_SIZE + MARGIN, DRAW_AREA_SIZE + MARGIN, MARGIN, DRAW_AREA_SIZE + MARGIN); } }
public void actionPerformed(ActionEvent e) { if (e.getSource() == ok) { if (w.equals("Richtig")) { Information[] infos = new Information[2]; // if (SudokuFenster1.getPreis().equals("20")) { infos[0] = new Information( Information.AENDERN_GELD, Information.ART_UM_WERT, Integer.parseInt(SudokuFenster1.getPreis())); infos[1] = new Information(Information.AENDERN_GELD, Information.ART_UM_WERT, -5); SudokuFenster1.getSpiel().minispielEnde(infos); // } else if (SudokuFenster1.getPreis().equals("50")) { // infos[0] = new Information(Information.AENDERN_GELD, // Information.ART_UM_WERT, 50); // SudokuFenster1.getSpiel().minispielEnde(infos); // } else { // infos[0] = new Information(Information.AENDERN_GELD, // Information.ART_UM_WERT, 100); // SudokuFenster1.getSpiel().minispielEnde(infos); // } } else { Information[] infos = new Information[1]; infos[0] = new Information(Information.AENDERN_GELD, Information.ART_UM_WERT, -5); SudokuFenster1.getSpiel().minispielEnde(infos); } this.setVisible(false); if (su2 != null) su2.setVisible(false); if (su != null) su.setVisible(false); } }