473,399 Members | 2,774 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

dynamically chane icons on label

I am doing a project on Nqueens and i need dynamically show the movement of queens but the screen shows only the final o/p and not the proc ess of how is it working!How can i visualize each step!
i am giving a part of that code
Expand|Select|Wrap|Line Numbers
  1. //THIS FOR CREATING CHESS BOARD
  2. p3.setLayout(new GridLayout(i,i));
  3.                      gbl=new GridBagConstraints();
  4.                     for(int m=0;m<i;m++)
  5.                     {
  6.                         for(int n=0;n<i;n++)
  7.                         {    
  8.                             gbl.gridx=m;
  9.                             gbl.gridy=n;
  10.                             l[m][n]=new JLabel();
  11.                             l[m][n].setOpaque(true);
  12.                             if((m+n)%2==0)
  13.                             {
  14.                                 l[m][n].setBackground(Color.black);
  15.                                 l[m][n].setIcon(new ImageIcon("wb.jpg"));
  16.                                 p3.add(l[m][n],gbl);
  17.                             }
  18.                             else
  19.                             {    l[m][n].setBackground(Color.white);
  20.                                 l[m][n].setIcon(new ImageIcon("ww.jpg"));    
  21.                                 p3.add(l[m][n],gbl);
  22.                             }
  23.                         }
  24.                     }
  25. //THIS IS TO DYNAMICALLY GENERATE
  26. for(int hh=0;hh<n;hh++)
  27.         {    for(int m=0;m<n;m++)
  28.             {
  29.                 if(l[hh][m].getIcon()!=null)
  30.                     l[hh][m].setIcon(null);
  31.  
  32.             }
  33.         }
  34.  
  35.  
  36.         if((k+ii)%2==0)
  37.         {
  38.  
  39.             l[k][ii].setIcon(new ImageIcon("wb.jpg"));
  40.  
  41.             //p3.add(l,gbl);
  42.  
  43.         }
  44.         else
  45.         {
  46.  
  47.             l[k][ii].setIcon(new ImageIcon("ww.jpg"));
  48.  
  49.             //p3.add(l,gbl);
  50.  
  51.         }
Mar 29 '14 #1
1 1270
chaarmann
785 Expert 512MB
You can visualize it by using a debugger. In Eclipse switch to the "debug" view, set a breakpoint on line 3, start your program with "run"->"debug" and step through your program line by line.

Another way is to print out the variables in every line
for example with System.out.println("line xx: myVariable=" + myVariable)
Apr 2 '14 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Dave Bailey | last post by:
I am trying to populate a label on a web form Let’s say I have the following select statement “Select Wonum, Location, Priority, Equipment from Workorderâ€
1
by: Bob | last post by:
I have a requirement to show a label and x number of buttons in all of the pages. So i decided to write a Base Page class and added code for dynamically adding the label and buttons. For the...
2
by: Quentin Huo | last post by:
Hi: I have a user control and I want to dynamically create a Label control and TextBox control when the button "add more author name" is clicked. I did like this: 1. there is a...
3
by: Paulers | last post by:
Hello, I have an arraylist that looks like this: 1,4,6 I have buttons called button1, button4, button6. I would like to change the text on the buttons that corispond to the numbers in the...
1
by: jayanthigk2004 | last post by:
Folks, I need a working code to do the following or something similar. I have two icons in the screen. One to indicate right (a tick mark) and one to indicate wrong (a cross). If the user...
3
by: Dahab | last post by:
Hi, I'm looking for a way to dynamically generate a label and a button side by side dynamically. Label1 Button1 Label2 Button2 Label..n Button..n Is this possible with a container...
2
by: codecln | last post by:
How do i dynamically create a label in html using ajax ? please help me out in this basic issues...
1
by: sindhutiwari | last post by:
hi, My aim is to bind the data dynamically to a label the database which i have used is ms - access n the labels are also generated dynamically i have tried with label.databinding...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.