Mercurial > hg > pub > prymula > com
view anielskiepuzzle/src/trefle/Trefle.java @ 7:bb29f1c89c99
immposiblerush-0.230919-0_PKG
author | prymula <prymula76@outlook.com> |
---|---|
date | Thu, 01 Feb 2024 21:49:30 +0100 |
parents | 2787f5e749ae |
children |
line wrap: on
line source
/* Trefle - ukladanka z puzzli Przemyslaw R. Pieraszczyk 20-01-2021 licencja - GPL powered by ATOM */ package trefle; import java.awt.*; // Toolkit import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JButton; //import javax.swing.JComponent; import javax.swing.JMenuBar; import javax.swing.JMenu; import javax.swing.JMenuItem; import javax.swing.JOptionPane; import javax.swing.Box; import javax.swing.JTextArea; import javax.swing.JDialog; import javax.swing.JTextField; import javax.swing.JCheckBox; import javax.swing.BorderFactory; import javax.swing.WindowConstants; import java.awt.event.*; import java.awt.event.ActionListener; //import java.awt.event.KeyListener; import java.awt.event.ActionEvent; import java.awt.event.WindowEvent; import java.awt.event.WindowAdapter; import java.awt.event.ComponentAdapter; import java.awt.event.ComponentEvent; import java.awt.event.ItemEvent; import java.awt.event.MouseListener; import java.awt.event.MouseEvent; //import java.awt.event.KeyEvent; import java.util.*; //Timer //import java.awt.Robot; import java.awt.Toolkit; import java.beans.*; //property change stuff import java.io.BufferedReader; import java.io.InputStream; import java.io.OutputStream; import java.io.InputStreamReader; import java.io.IOException; import java.io.*; import java.awt.image.BufferedImage; import java.awt.image.*; import javax.imageio.ImageIO; import javax.imageio.*; public class Trefle extends JPanel implements ActionListener { static JMenuBar menuBar; static JMenu menu, info, menu2, nowplay; static JMenuItem menuItem, menuExit, menuInfo, menuPref; static JFrame frame; //static boolean go=false; //static JPanel screen; static Trefle trefle; static Timer timer = new Timer(); //static Actions actions; //static Mata mata; private Graphics bg; private Image bufor; static private int x; static private int y; //private Mata mata; //private Puste puste; //static boolean zaczynamy; static int nmove; BufferedImage imageNow; static Mouse mouse; static MouseMotion mouseMotion; //Image img; //Image cell[]=new Image[6*4]; static CellPicture origPicture[][] = new CellPicture[6][4]; static CellPicture cellPicture[][] = new CellPicture[6][4]; static CellPicture wallPaper[][] = new CellPicture[6][4]; //static CellWallPaper wallPaper[][] = new CellWallPaper[6][4]; static CellPicture dragAndDrop; BufferedImage wallPaperImage=null; BufferedImage borderImage=null; BufferedImage startScreen=null; boolean startscreen=true; static boolean go=false; static int getBorderX; static int getBorderY; static int iw,ih,tw,th; static int move; public Trefle (){ menuBar = new JMenuBar(); menu = new JMenu("Plik"); menuBar.add(menu); //menu2 = new JMenu("Options"); //menuBar.add(menu2); // przenosi INFO na prawa strone menuBar.add(Box.createHorizontalGlue()); info = new JMenu("Info"); // kierunek wyswietlania menu info.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); menuBar.add(info); nowplay = new JMenu("Nowa Gra"); nowplay.setToolTipText("Rozpoczyna nowa gre."); menu.add(nowplay); menuItem = new JMenuItem("Anielica", null); menuItem.setActionCommand("NewGame1"); menuItem.addActionListener(this); menuItem.setToolTipText("Piekna Anielica"); nowplay.add(menuItem); menuItem = new JMenuItem("Zielony", null); menuItem.setActionCommand("NewGame2"); menuItem.addActionListener(this); menuItem.setToolTipText("Zielony Archaniol"); nowplay.add(menuItem); menuItem = new JMenuItem("Niebieski", null); menuItem.setActionCommand("NewGame3"); menuItem.addActionListener(this); menuItem.setToolTipText("Niebieski Archaniol"); nowplay.add(menuItem); menuItem = new JMenuItem("Na Linie", null); menuItem.setActionCommand("NewGame4"); menuItem.addActionListener(this); menuItem.setToolTipText("Aniol na linie"); nowplay.add(menuItem); //menuItem = new JMenuItem("Pojedynczy", null); //menuItem.setActionCommand("NewGame0"); //menuItem.addActionListener(this); //menuItem.setToolTipText("Wlasciwie nic nie miesza"); //nowplay.add(menuItem); //to nie //menu.add(menuItem); menu.addSeparator(); menuExit = new JMenuItem("Wyjscie", null); menuExit.setActionCommand("EndGame"); menuExit.addActionListener(this); menuExit.setToolTipText("Wyjscie z programu"); menu.add(menuExit); menuInfo = new JMenuItem("Pomoc", null); menuInfo.setActionCommand("Help"); menuInfo.addActionListener(this); menuInfo.setToolTipText("HOWTO"); info.add(menuInfo); menuInfo = new JMenuItem("O Programie", null); menuInfo.setActionCommand("About"); menuInfo.addActionListener(this); menuInfo.setToolTipText("Informacje o programie"); info.add(menuInfo); LoadWallPaper(); LoadBorder(); LoadStartScreen(); } public void actionPerformed(final ActionEvent e) { // Nowa gra if(e.getActionCommand().equals("NewGame1")) { imageNow = LoadPicture("/aniol.JPG"); CropImage(); MixImage(); ZerosWallPaper(); dragAndDrop =null; //= new CellPicture(0,0,0,0,null,0); // inicjujemy wydmuszke z image=null go=true; startscreen=false; this.repaint(); //nmove=0; move=0; //mata.setMixedFields(0); System.out.println("ZACZNAMY"); //screen.setVisible(true); //nPuzzle.repaint(); } else if(e.getActionCommand().equals("NewGame2")) { imageNow = LoadPicture("/zielony_archaniol.jpg"); CropImage(); MixImage(); ZerosWallPaper(); dragAndDrop = null; //new CellPicture(0,0,0,0,null,0); // inicjujemy wydmuszke z image=null go=true; startscreen=false; this.repaint(); move=0; System.out.println("ZACZNAMY"); //screen.setVisible(true); //nPuzzle.repaint(); } else if(e.getActionCommand().equals("NewGame3")) { imageNow = LoadPicture("/niebieski_archaniol.jpg"); CropImage(); MixImage(); ZerosWallPaper(); dragAndDrop = null; //new CellPicture(0,0,0,0,null,0); // inicjujemy wydmuszke z image=null go=true; startscreen=false; this.repaint(); move=0; System.out.println("ZACZNAMY"); //screen.setVisible(true); //nPuzzle.repaint(); } else if(e.getActionCommand().equals("NewGame4")) { imageNow = LoadPicture("/nalinie.jpg"); CropImage(); MixImage(); ZerosWallPaper(); dragAndDrop = null; //new CellPicture(0,0,0,0,null,0); // inicjujemy wydmuszke z image=null go=true; startscreen=false; this.repaint(); move=0; System.out.println("ZACZNAMY"); //screen.setVisible(true); //nPuzzle.repaint(); } // Zakonczenie else if(e.getActionCommand().equals("EndGame")) { System.exit(0); } else if(e.getActionCommand().equals("About")) { String s2=" Program napisany na podstawie fragmentow kodow,\n", s3=" wyszukanych w wyszukiwarce Google,\n", s4=" plus wlasna inwencja\n\n", s5=" Przemyslaw R. Pietraszczyk - styczen 2021\n", s6=" Licencja: GPL\n\n", s7=" Stworzono w oparciu o OpenJDK 11 oraz ANT\n\n", s8=" o/s: "+System.getProperty("os.name")+" ver: "+System.getProperty("os.version")+"\n", s9=" java ver: "+System.getProperty("java.vm.version")+"\n"; JOptionPane.showMessageDialog(frame, s2+s3+s4+s5+s6+s7+s8+s9, "Anielskie Puzzle - 0.2-1", JOptionPane.PLAIN_MESSAGE); } else if(e.getActionCommand().equals("Help")) { String s1="Ukladanka polegajaca na metodzie przeciagnij i upusc elementow z prawej strony na lewa.\n Dokladniej mowiac nalezy kliknac i przytrzymac lewy klawisz myszki na elemencie\n z prawej strony a nastepnie nie puszczajac przycisku,\n przesunac obrazek nad lewa kratownice, umieszczajac element w wybranym punkcie,\n poprzez puszczenie lewego przycisku myszki.\n Po prawidlowym ulozeniu wszystkich obrazkow w jeden duzy obraz,\n aplikacja wyswietli okienko z iloscia wykonanych posuniec.\n", s2="Dozwolone jest rowniez przenoszenie elementow z lewej na prawa strone,\n jak i w zasiegu jednej kratownicy.", s3="\n"; JOptionPane.showMessageDialog(frame, s1+s2+s3, "Pomoc", JOptionPane.PLAIN_MESSAGE); } } private static void createAndShowGUI() { frame=new JFrame("Anielskie Puzzle"); //mata = new Mata(); //mata.setUnmixedFields(); // menuBar z konstruktora final int frameWidth = 1200; //1300; final int frameHeight = 680; final int GNOMEPANEL=80; // nieco nizej niz panel final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); //frame.setBounds((int) screenSize.getWidth() - frameWidth, // (int) screenSize.getHeight() - frameHeight, frameWidth, frameHeight); frame.setBounds((int) screenSize.getWidth() - frameWidth, GNOMEPANEL, frameWidth, frameHeight); frame.setResizable(false); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); trefle= new Trefle(); //screen = new PuzzleCanvas(true, mata); frame.add(trefle); //trefle.setPreferredSize(new Dimension(1200, 640)); trefle.setBounds(5,5, 1170,640); // 1200, 640 //frame.add(screen); //nPuzzle.setVisible(true); frame.add(menuBar); frame.setJMenuBar(menuBar); frame.setLayout(null); //frame.setSize(250,400); // 400 x 400 frame.setVisible(true); mouse = new Mouse(); mouseMotion = new MouseMotion(); mouse.setCanvas(trefle); frame.addMouseListener(mouse); frame.addMouseMotionListener(mouseMotion); //addMouseListener(mouse); //frame.addKeyListener(actions); frame.setFocusable(true); // zapobiega utracie KeyEvent po wyjsciu z SoundDialog i ResetDialog /* frame.addFocusListener(new FocusListener(){ public void focusGained(FocusEvent e){ //System.out.println("Focus GAINED:"+e); } public void focusLost(FocusEvent e){ //System.out.println("Focus LOST:"+e); // FIX FOR GNOME/XWIN FOCUS BUG e.getComponent().requestFocus(); } }); */ //dragAndDrop = new CellPicture(0,0,0,0,null,0); // inicjujemy wydmuszke z image=null timer.schedule(new KeyTicks(), 0, 1000); // lepiej 1000 //zaczynamy=true; } protected void paintComponent(Graphics g){ super.paintComponent(g); //int i, j; int fontSize = 60; //y=60; //System.out.println("MATA: "+mata); //if (mata != null) { g.setFont(new Font("Serif", Font.PLAIN, fontSize)); //g.setForeground(Color.BLACK); g.setColor(Color.BLACK); //g.drawImage(imageNow, 0,0,this); if (startscreen){ g.drawImage(startScreen, 130+getInsets().left, 40+getInsets().top, null); // 160 + getInsets().left } if (go){ for (int y=0;y<6;y++){ for (int x=0; x<4;x++){ //int i = y*4+x; // jesli na tapecie nie ma obrazka wyswietla szachownice if (wallPaper[y][x] == null) g.drawImage(wallPaperImage, x*wallPaperImage.getWidth(null)+getInsets().left, y*wallPaperImage.getHeight(null)+getInsets().top, null); else g.drawImage(wallPaper[y][x].image, x*wallPaper[y][x].w+getInsets().left, y*wallPaper[y][x].h+getInsets().top, null); // wallPaper[y][x]=new CellWallPaper(wallPaperImage.getWidth(null)*x, wallPaperImage.getHeight(null)*y,wallPaperImage.getWidth(null), wallPaperImage.getHeight(null), wallPaperImage, i); } } //if (go){ for (int y=0;y<6;y++){ for (int x=0; x<4;x++){ int i = y*4+x; // g.drawImage(cell[y*4+x], 650+x*tw+getInsets().left, y*th+getInsets().top, null); if(cellPicture[y][x]==null){ g.drawImage(wallPaperImage, 496+124+x*wallPaperImage.getWidth(null)+getInsets().left, y*wallPaperImage.getHeight(null)+getInsets().top, null); System.out.println("ADRESS: "+cellPicture[y][x]); } else g.drawImage(cellPicture[y][x].image, 496+124+x*cellPicture[y][x].w+getInsets().left, y*cellPicture[y][x].h+getInsets().top, null); //} else // g.drawImage(wallPaper[y][x].image, 496+124+x*wallPaper[y][x].w+getInsets().left, y*wallPaper[y][x].h+getInsets().top, null); } } if (dragAndDrop != null){ if (dragAndDrop.image != null){ System.out.println("JUZ JESTEM!"); System.out.println("X: "+dragAndDrop.x); System.out.println("Y: "+dragAndDrop.y); g.drawImage(dragAndDrop.image, dragAndDrop.x, dragAndDrop.y, null); } } if (getBorderX !=0 | getBorderY != 0){ //System.out.println("RRYSUJE BORDER"); g.drawImage(borderImage, getBorderX*tw+getInsets().left, getBorderY*th+getInsets().top, null); } } } private void LoadBorder(){ try { borderImage = ImageIO.read(getClass().getResourceAsStream("/border.png")); // "/nazwa_pliku" } catch (IOException ioe) { ioe.printStackTrace(); } } private BufferedImage LoadPicture(String name){ BufferedImage image=null; try { image = ImageIO.read(getClass().getResourceAsStream(name)); // "/nazwa_pliku" } catch (IOException ioe) { ioe.printStackTrace(); } iw=image.getWidth(null); ih=image.getHeight(null); tw=iw/4; th=ih/6; return image; } private void LoadWallPaper() { try { wallPaperImage = ImageIO.read(getClass().getResourceAsStream("/wallpaper.jpg")); // "/nazwa_pliku" } catch (IOException ioe) { ioe.printStackTrace(); } /* for (int y=0;y<6;y++){ for (int x=0; x<4;x++){ int i = y*4+x; wallPaper[y][x]=null; // wallPaper[y][x]=new CellWallPaper(wallPaperImage.getWidth(null)*x, wallPaperImage.getHeight(null)*y,wallPaperImage.getWidth(null), wallPaperImage.getHeight(null), wallPaperImage, i); } } */ } private void LoadStartScreen() { try { startScreen = ImageIO.read(getClass().getResourceAsStream("/start.jpg")); } catch (IOException ioe) { ioe.printStackTrace(); } } private void ZerosWallPaper() { for (int y=0;y<6;y++){ for (int x=0; x<4;x++){ int i = y*4+x; wallPaper[y][x]=null; // wallPaper[y][x]=new CellWallPaper(wallPaperImage.getWidth(null)*x, wallPaperImage.getHeight(null)*y,wallPaperImage.getWidth(null), wallPaperImage.getHeight(null), wallPaperImage, i); } } } private void CropImage (){ CropImageFilter f; FilteredImageSource fis; for (int y=0;y<6;y++){ for (int x=0; x<4;x++){ f=new CropImageFilter(tw*x, th*y, tw,th); fis=new FilteredImageSource(imageNow.getSource(), f); int i = y*4+x; //cell[i]=createImage(fis); cellPicture[y][x]=new CellPicture(tw*x, th*y, tw, th, createImage(fis), i); origPicture[y][x]=new CellPicture(tw*x, th*y, tw, th, createImage(fis), i); mouse.set(tw,th); } } } private void MixImage(){ for (int i=0; i<48; i++){ //int si = (int) (Math.random()*24); int sy = (int) (Math.random()*6); int sx = (int) (Math.random()*4); //int di = (int) (Math.random()*24); int dy = (int) (Math.random()*6); int dx = (int) (Math.random()*4); //Image tmp = cell[si]; //cell[si]=cell[di]; //cell[di]=tmp; CellPicture tmp_c = cellPicture[sy][sx]; cellPicture[sy][sx]=cellPicture[dy][dx]; cellPicture[dy][dx]=tmp_c; //tmp_c = origPicture[sy][sx]; //origPicture[sy][sx]=origPicture[dy][dx]; //origPicture[dy][dx]=tmp_c; } } public static void main(final String[] args) { javax.swing.SwingUtilities.invokeLater(new RunnableImplementation()); } private static final class RunnableImplementation implements Runnable { public void run(){ createAndShowGUI(); } } static private class CellPicture { public int x, y, w, h, n; public Image image; //public boolean view; public CellPicture(int x, int y, int w, int h, Image img, int n){ this.x=x; this.y=y; this.w=w; this.h=h; this.n=n; // numer porzadkowy this.image=img; // biezacy obrazek // this.view=true; } public void set(int _x, int _y){ this.x=_x; this.y=_y; } } /* static private class CellWallPaper extends CellPicture { public Image store; // kopia ukladanki public CellWallPaper(int x, int y, int w, int h, Image img, int n){ super(x,y,w,h,img,n); store = null; } } */ static class KeyTicks extends TimerTask { //int cellGetIndex, cellPutIndex; // indeksy z obszaru do obszaru Coordinate cellGetCoor, cellPutCoor; Coordinate dragGetCoor=null; //static CellPicture dragAndDrop; boolean redraw = false; int tmpx=0, tmpy=0; boolean fromLeft=false, fromRight=false; //int arr[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24}; public void run() { if (go){ cellGetCoor=mouse.getCell(); cellPutCoor=mouse.putCell(); int gety=getBorderY=(cellGetCoor.y-(th/2))/th; // plus korekta y od belki (th/2) int getx=getBorderX=cellGetCoor.x/tw; int test = cellGetCoor.x/tw-5; int puty=(cellPutCoor.y-(th/2))/th; int putx=cellPutCoor.x/tw; //int tmpx=0,tmpy=0; //System.out.println("KLIKNIETO NA x:"+((cellGetCoor.x/tw))+" y:"+(cellGetCoor.y/th)-20)); //System.out.println("KLIKNIETO NA x:"+(cellGetCoor.x/tw)+" y:"+gety+" test:"+test); //trefle.repaint(); System.out.println("cellPutCoor.y: "+cellPutCoor.y+" cellPutCoor.x: "+cellPutCoor.x); System.out.println("PATYK"); if (cellGetCoor.click && !redraw && cellGetCoor.y-(th/2)>44 && cellGetCoor.y<645 && cellGetCoor.x<1122){ System.out.println("przerysowuje -1 x:"+cellGetCoor.x+" y:"+cellGetCoor.y); redraw=true; //System.out.println("cellGetCoor:"+cellGetCoor+" gety:"+gety+" getx:"+getx+" wallPaper:"+wallPaper[gety][getx]); // drag z lewej strony if (getx<4 && cellGetCoor.x/tw<4 && cellGetCoor.y-(th/2)/th>=0 && wallPaper[gety][getx]!=null && wallPaper[gety][getx].image!=null){ //if (wallPaper[gety][getx]!=null) dragAndDrop=new CellPicture(cellGetCoor.x, cellGetCoor.y, tw, th, wallPaper[gety][getx].image, wallPaper[gety][getx].n); //else // dragAndDrop=null; System.out.println("Jestem na lewo"); tmpx=cellGetCoor.x/tw; tmpy=(cellGetCoor.y-(th/2))/th; fromLeft=true; } // drag z prawej strony else if (cellGetCoor.x/tw>4 && cellGetCoor.y-(th/2)/th>=0 && cellPicture[gety][getx-5]!=null && cellPicture[gety][getx-5].image!=null){ // bylo z origPicture //dragAndDrop=new CellPicture(cellGetCoor.x, cellGetCoor.y, tw, th, cellPicture[gety][getx-5].image, cellPicture[gety][getx-5].n); dragAndDrop=new CellPicture(cellGetCoor.x, cellGetCoor.y, tw, th, cellPicture[gety][getx-5].image, cellPicture[gety][getx-5].n); System.out.println("Jestem naprawo"); tmpx=cellGetCoor.x/tw-5; tmpy=(cellGetCoor.y-(th/2))/th; fromRight=true; } else { System.out.println("Jestem ELSE"); redraw=false; //return; } //cellPicture[gety][getx-5].view=false; System.out.println("przerysowuje - 2 x:"+tmpx+" y:"+tmpy); } else if(!cellGetCoor.click && redraw) { System.out.println("puszczono"); redraw=false; if (dragAndDrop.image!=null){ if(dragGetCoor.x/tw<4){ // drag z prawej na lewo if (fromRight){ if (wallPaper[(dragGetCoor.y-(th/2))/th][dragGetCoor.x/tw]==null) { //wallPaper[(dragGetCoor.y-(th/2))/th][dragGetCoor.x/tw]=new CellPicture(dragAndDrop.image.getWidth(null)*x, dragAndDrop.image.getHeight(null)*y,dragAndDrop.image.getWidth(null), dragAndDrop.image.getHeight(null), dragAndDrop.image, dragAndDrop.n); wallPaper[(dragGetCoor.y-(th/2))/th][dragGetCoor.x/tw]=new CellPicture(tw*x, th*y,tw, th, dragAndDrop.image, dragAndDrop.n); System.out.println("Dokuje na lewo"); dragAndDrop.image=null; //cellPicture[(cellGetCoor.y-(th/2)/th)][cellGetCoor.x/tw]=null; System.out.println(" coor.y"+puty+" coor.x"+putx); System.out.println(" tmpy"+tmpy+" tmpx"+tmpx); //cellPicture[puty][putx]=null; cellPicture[tmpy][tmpx]=null; fromRight=false; } else { dragAndDrop.image=null; } move++; } // drag z lewej na lewo else if (fromLeft){ if (wallPaper[(dragGetCoor.y-(th/2))/th][dragGetCoor.x/tw]==null){ //System.out.println("CELL:"+dragAndDrop.image); wallPaper[(dragGetCoor.y-(th/2))/th][dragGetCoor.x/tw]=new CellPicture(tw*x, th*y,tw, th, dragAndDrop.image, dragAndDrop.n); System.out.println("Dokuje na lewo"); dragAndDrop.image=null; //cellPicture[(cellGetCoor.y-(th/2)/th)][cellGetCoor.x/tw]=null; System.out.println(" coor.y"+puty+" coor.x"+putx); System.out.println(" tmpy"+tmpy+" tmpx"+tmpx); //cellPicture[puty][putx]=null; wallPaper[tmpy][tmpx]=null; fromLeft=false; } else { dragAndDrop.image=null; } move++; } } // drag spowrotem na prawo z lewj else if (dragGetCoor.x/tw>4){ if(fromLeft){ if (cellPicture[(dragGetCoor.y-(th/2))/th][dragGetCoor.x/tw-5]==null){ System.out.println("Dokuje z lewa na prawo"); cellPicture[(dragGetCoor.y-(th/2))/th][dragGetCoor.x/tw-5]=new CellPicture(tw*x, th*y,tw, th, dragAndDrop.image, dragAndDrop.n); dragAndDrop.image=null; wallPaper[tmpy][tmpx]=null; fromLeft=false; } else { dragAndDrop.image=null; } } else if(fromRight){ if (cellPicture[(dragGetCoor.y-(th/2))/th][dragGetCoor.x/tw-5]==null){ System.out.println("Dokuje z prawa na prawo"); cellPicture[(dragGetCoor.y-(th/2))/th][dragGetCoor.x/tw-5]=new CellPicture(tw*x, th*y,tw, th, dragAndDrop.image, dragAndDrop.n); dragAndDrop.image=null; cellPicture[tmpy][tmpx]=null; fromRight=false; } else { dragAndDrop.image=null; } } } else { dragAndDrop.image=null; fromLeft=false; fromRight=false; } } } else { System.out.println("POZA ZAKRESEM"); } //System.out.println("DRAGANDDROP:"+dragAndDrop); dragGetCoor = mouseMotion.get(); //if(dragGetCoor.x!=0 && dragGetCoor.y!=0){ System.out.println("drag x: "+dragGetCoor.x+" drag y: "+dragGetCoor.y+" xputcoor:"+putx+" yputcoor:"+puty); if (dragAndDrop!=null) dragAndDrop.set(dragGetCoor.x, dragGetCoor.y); //} trefle.repaint(); if (arranged()){ String s1="Ulozyles wszystkie puzzle !\n", s2="Wykonales "+move+" ruchow.\n"; JOptionPane.showMessageDialog(frame, s1+s2, "Podsumowanie", JOptionPane.PLAIN_MESSAGE); go=false; } System.out.println("PO ARRANGED"); } } private boolean arranged(){ int i=0, a=0; for (int y=0;y<6;y++){ for (int x=0;x<4;x++){ if (wallPaper[y][x] != null){ if (wallPaper[y][x].n==origPicture[y][x].n){ a++; } } i++; } } System.out.println("A: "+a); if(a==24) return true; return false; } } }