-
the int is not to blame
have you tried using the validate() method of the gui component?
sometimes the changes you make in a GUI do not actually happen until you call that, or do a resize operation.
I think that the int is changed. I see no reason why it shouldn't be. It's just that this change does not reflect in the drawing of the program.
-
yea, unfortunately, ive tried that too.
The thing is, if i did this as an applet, and call the combobox to change the int, nothing happens, but... if i press restart on the java applet shower, then the new grid appears :rolleyes:
Just something stupid, so the int must be changing
-
funny
it must be a language detail that I'm missing too.
Try to make the int non static.
and take a look at your contructors and when it's an applet your paint method as well
-
I think I might have located some possible causes of the problem.
you confuse me a bit with the size and bSize variables so I'll use only one named 'size' and I will mean your bSize
you confuse me with the for statement too.
So it's one of two things
I) Most probable, if I get the general idea of the program correctly:
the last part of the for : lineSize = lineSize+size;
and then in the check you have lineSize < area.length * size
I'm not getting your logic completely but I think that no matter what size is the for will be executed a standard amount of times.
II)When you change the size variable the area array does not change.
It remains as it were.
So if you wanted it to change...
what you should do is:
Instead of changing the static variable do either of these two:
1) make a constuctor for the myJPanel:
//instance variables
int size ;
int[][] area;
//constructor
...(int s){
super();
size =s;
area[][] = new int[size][size];
}
then in the GUI code you should write
mainJPanel.remove(myPanel);
mainJPanel.add( new MyPanel(6));
2) make a simple method that will change the array as well as the sze variable
update_data(int s){
size = s;
area = new int[size][size];
}
Code:
lineSize = lineSize+size;
Code:
Code:
lineSize = lineSize+size;
-
well i had started messing with things,and with that extra bit of help you gave then, i managed to work it out. Cheers! :)
-
ok! I'm glad you made it.