But how could I possible figure out what would be a legal move or not? I think I've missed a few part in my lousy design.

I have a Vector that contains 9x9 Jpanels that makes upp the Squares of my board-I have an Array containing all the illegal squares(in the corners, the ones painted black that shouldn't have been in the first place.. GridLayout..)

So, when I press my mouse, I see if I'm grabbing a JLabel (my Gamepiece) and then I get the index of the parent Jpanel. When I release my mousebutton I check if the square is empty and then I can get the index of that Jpanel

But.. then what, I have two indexnumbers..? My Math isn't very good.. is there really a magic formula to control that thing?Or should I store every objects row and column somehow, then I could see if the difference between the "fromSquare" and "targetSquare" row,column are 0,2 or 2,0. One of them must be 0 and I can only jump one square.

Then.. of course.. I must check wether or not the square I'm jumping contains a Jlabel too .. :/

And if you ever get into using wierd shapes, like a Risk board style. I found it fast enough to create a ini file that listed all the areas.

1 2 3 4 5 6 7 8

[areas]1=Brazil12102=Canada23693=United_States2330

[borders]border1 = 725border2 = 910312

I use built in java ini reader and a string tokenizer.

The first part holds the area names ( under scores _ = spaces), then follows the x and y for the pieces.

The second part holds all your borders. I found setting up this ini file I could create a board game with some really wierd shaped areas. Works well for games that require a risk look and feel.

I would like to develop a map maker to create the ini file, but havent got around to it yet.

The coolest thing I found, another developer showed me. Was to take the origenal PNG and create a grayscale GIF of the image. The player always sees the hi res color PNG. The GIF is just for processing background things.

Then take area 1 Brazil and make the RBG 1,1,1

Canada would be RBG 2,2,2 and so on.

Thus you can take the GIF image and any x y coordiante and figure out where you are from the RBG value. This also allows you to highlight areas by changing the RBG value to a real color like RED on the file then displaying a sub image, thus it looks like your highlighting the area. Works good for mouse clicks.

How do i remove the Jlabel symbolizing the ball i just jumped?The GamePieces resides in a Vector, but removing them from there does nothing (gamePieces.remove(index)).I suppose I have to remove the Label itself from the Jpanel where it resides somehow?

// initialise the board to the shape and peg// configuration you like here. Read it from a file// might be nicefor (intx=0;x<10;x++) {for(inty=0;y<10;y++) {board[x][y] = newTile();board[x][y].isValid = true;

I will try that, as soon as I've done the Swing verison. It was my courseleader (I spend my evenings after work to dig into Java) that suggested going the Swing way instead of 2D.

Well, now I have it running, as soon as I can get the Jpanel that I Jump to remove it's JLabel. i tried the removeAll() which won't do it. It doesn't update my view at least. And I can't use the removeComponent() since I don't have that Component in a variable. Fells stupid to try to "catch" that one, and actually I don't know how to do it?

Actually, "RISK" like games is exactly what I want to develop, once I get basic knowledge.

Do you have some "real" examples to show? I really like your idea with the .ini file.

I have some custom classes and such. Allot to post, but I'll be putting the project on Source Forge soon. So you'll be able to look at the source there. I'll add a link in my signature when I create the project on source forge. So just keep an eye open.

So, thanx for all the suggestions helping me out with my lousy peg solitaire.

So far, I've come to the conclusion that I should never ever never use Swing components for something like this.I don't understand them at all. I can't get why a removed non-existent component, for example, could be visible? I have to use setVisible(false) before I remove them (I can't do it afterwards, it's removed remeber) to get the ugly Icon to disappear? Somehow, I thought the Icon belonged to the Label? Anywya, i could do that it's ok.

Now, if someone could give me some rookie help.. I load a saved PlayBoard object using my

Now.. to actually update my game and my screen(now I don't recieve any messages, but nothing at all happens, I don't get any old board to continue playing with) ... what am I supposed to do? Will I have to run some code to actually put my objects back and run a validate() on my 81 JPanel squares or how is it all handled?

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org