hey there. I have the following code. I am trying to build an applet that displays all possible (92) ways of arranging eight queens on a chess board with no two of them on the same column, row, or diagonal. I built this as an application and it ran fine. I made the necessary modifications of my Eksi class to construct an applet, but it won't repaint(). can anyone lend their experience and show me what I am doing wrong. I think my problem is specifically on line 77 of my code. thank you!

import javax.swing.*;
   import java.awt.*;

   public class Eksi extends JApplet{
      private Kutia[][] k;
      private int count = 0;
      public void init(){}
   
      public void paint(Graphics g){
         g.setColor(Color.blue);
         g.fillRect(0, 0, 500, 500);
      
         for(int i = 0; i < 8; i++){
            for(int j = 0; j < 8; j++){
               if((i+j)%2 == 0){
                  g.setColor(Color.black);
               }
               else{
                  g.setColor(Color.red);
               }
               g.fillRect(50 + i*20, 50 + j*20, 20, 20);
            }
         
         }
      	
         if(k != null){
            System.out.println("Gagi");
            count++;
            for(int i = 0; i < 8; i++){
               for(int j = 0; j < 8; j++){
                  g.setColor(Color.white);
                  g.drawString(k[i][j].figura(), i*20 + 52, j*20 + 70);
                  g.setColor(Color.black);
                  g.drawString("Mundesia " + count, 140, 30);
               
               }			
            }
         
         }
      	
      }
   
      public void ndihmesePaint(Kutia[][] ituk){
         k = ituk;
         System.out.println("Ngadhnjim");
         repaint();
      
      }
   
      public static void main(String[] args){
         int variable = 0;
         Model mod = new Model();
         VeproMeMatrica vm = new VeproMeMatrica();
         String[] ar = vm.permutim("8");
         int[][] xarg = vm.ConvertPermute(ar);
         Eksi ek = new Eksi();
         Kutia[][] x = new Kutia[8][8];
      
      
         for(int k = 0; k < vm.Factoriel(8); k++){
            variable++;
            for(int i = 0; i < x.length; i++){
               for(int j = 0; j < x.length; j++){
                  if((i == 0 & j == xarg[k][0] - 1) || (i == 1 & j == xarg[k][1] - 1) || (i == 2 & j == xarg[k][2] - 1) || (i == 3 & j == xarg[k][3] - 1) || (i == 4 & j == xarg[k][4] - 1) || (i == 5 & j == xarg[k][5] - 1) || (i == 6 & j == xarg[k][6] - 1) || (i == 7 & j == xarg[k][7] - 1)){
                     x[i][j] = new Kutia(i, j , "M");
                  
                  }
                  else{
                     x[i][j] = new Kutia(i, j, "");;
                  
                  }
               }
            }
         	
         //-------------------------------------------------------------------				
         
            ek.ndihmesePaint(x);//this line is never being executed. I don't get it why!!
            try { Thread.sleep(2000); }
               catch (InterruptedException e) { }
         
         }
      	//-------------------------------------------------------------------
      
      //-------------------------------------------------------------------     
      		
      }
   }

look here http://www.daniweb.com/software-development/java/threads/352362

this thread contains basis drawing methods

- don't extends topLayoutContainer(lots of bugs), purpose publish shortiest code to some example depot
- don't call thread.sleep(int), withOut any purposes, just lock repaint on EDT
- and same advices from your prevoius thread, because you don't learn anything from ...., forgot for that code, start again

1/ create topLayoutContainer
2/ create JPanel, put that to the topLayoutContainer(preffer JFrame with BorderLayout.CENTER) by using some LayoutManage
3/ setVisible for topLayoutContainer
4/ put here two JButtons (from example)
5/ replace stars with you chessBoard
6/ everything must works

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.