My tic tac toe board is done, but I need it to show up in the Dialog box, not the console, how would I do that?
Here is my code:

javax.swing.JOptionPane.showMessageDialog(null, "\n-------");


for (int i = 0; i < 3; i++) {
System.out.print("| ");
for (int j = 0; j < 3; j++)
System.out.print(spot[j] + " | ");
javax.swing.JOptionPane.showMessageDialog(null, "\n--------");

Ok, I'm taking a look at it, but first you should know that when you post code, you should use the code tags like so:

[ code ]leave out the spaces in the tags[ /code ]

and when you're using a specific language like you did (i.e. Java) you use it like so:

[ code=java ]leave out the spaces in the tags[ /code ]

Now, although I'm able to figure it out myself, you have one '{' and no '}' in your code. It's not because you're talking to humans instead of the compiler that you don't have to be correct anymore. :) If your code and idea behind it wouldn't be that simple, it would be hard for us to know what you are really trying to do.

Others will appreciate it more when you follow rules like this and therefor will be more willing to help you out.

Black Box

javax.swing.JOptionPane.showMessageDialog(null, "\n-------");

    for (int i = 0; i < 3; i++) {
      System.out.print("| ");
      for (int j = 0; j < 3; j++)
        System.out.print(spot[i][j] + " | ");
      javax.swing.JOptionPane.showMessageDialog(null, "\n--------");
  		  }

I have the board, it works, but when I try making a messagebox instead of a console, I'm confused...

Ok, I'm assuming you want everything to appear in the message box. First of all, everything you give System.out.print, will be printed to your console, no matter what. The easiest way to get this done in your case is to do the following. Instead of printing what you want bit by bit to your messagebox, you should place it al in one string. So, don't use System.out.print, but use something like myString = myString + " | "; or something.

Then after your loops, you can create your messagebox and give your string to it as parameter.

That should pretty much do it. However, it seems that you're trying to work your way into Swing and I suggest you learn swing like it's supposed to be learned: from the beginning.

Black Box

waoh woah woah, thanks for the help, but I like it simple, I only got to arrays in my book so, everything I did so far has been simple, nothing to advance, thats why I have about 3 to 4 pages of code.

I can understand that you want to keep it simple, really, I think everyone wants everything to be simple. The thing is, diving head first in Swing and trying everything wrong, right and different until it works is:
1. a lot of work.
2. not going to teach you something because you won't know the exact reason why it works this time, but not any other time.
3. because of 1 & 2 a lot harder instead of simple...

So, either wait a bit with Swing, or try to put more time in it so you can learn it "the easy way".

Black Box

Yes, moving your console app over to a Swing component isn't just a matter of stuffing the output into a message box. Message boxes don't work like the console at all. You will need to work with frames/panels and either arrays of components or custom 2D painting with mouse listeners.

It gets deep pretty quickly once you decide to move into GUI programming and as Black Box noted, you need to start at the beginning.

If you do go that route and get a bit of understanding of Swing under your belt, feel free to post back with questions on what components and techniques can be used to build your interface.

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.