help plss..emergency.

Thread Solved

Join Date: Mar 2007
Posts: 7
Reputation: TingTing is an unknown quantity at this point 
Solved Threads: 0
TingTing's Avatar
TingTing TingTing is offline Offline
Newbie Poster

help plss..emergency.

 
0
  #1
Mar 23rd, 2007
this is my 1st time to post. help pls.
can anyone help me program tictactoe (java w/ gui)? req. are comp vs player, player vs player, 2d array, replay, undo..plssss...i need your help rep asap..thank u very much :cheesy: .. pls
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 4,190
Reputation: peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of 
Solved Threads: 483
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is offline Offline
Code tags enforcer

Re: help plss..emergency.

 
0
  #2
Mar 23rd, 2007
I think you come to wrong forum. We do not do others people homework/coursework/assigments, we try to help and solve problems with in code you already writen.
So if you did your work and have problem with code, please kindly post your code with problem description and we will try to help you.
Otherwise do your job and come back when you face difficulties...
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)

LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 7
Reputation: TingTing is an unknown quantity at this point 
Solved Threads: 0
TingTing's Avatar
TingTing TingTing is offline Offline
Newbie Poster

Re: help plss..emergency.

 
0
  #3
Mar 23rd, 2007
Originally Posted by peter_budo View Post
I think you come to wrong forum. We do not do others people homework/coursework/assigments, we try to help and solve problems with in code you already writen.
So if you did your work and have problem with code, please kindly post your code with problem description and we will try to help you.
Otherwise do your job and come back when you face difficulties...
thank u..ah... yah i have the player vs player...

my prob now is, ... i use mouselistener to add image to the tictactoe(instead of x and o).. i want to know how to remove the image when i click on "new game" button.. what is the syntax and how to remove image...

another prob is how to save the "action" of mouse click..for the replay..or are there any other solution for this? right now im thinking of saving the "action" into a vector.. is this possible?

tyvm
JavaIdiot
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 101
Reputation: cms271828 is an unknown quantity at this point 
Solved Threads: 4
cms271828 cms271828 is offline Offline
Junior Poster

Re: help plss..emergency.

 
0
  #4
Mar 24th, 2007
Hmmm,

Well I'm assuming you're using JPanel, or extending JPanel and thus using paintComponent(Graphics g) method.

The you draw image using g.drawImage(image,x,y,this);

So to remove the image, I would have some boolean or array that is updated when you press new game, then you can call repaint() on the JPanel object, and if you have some kind of IF statement by the drawImage, you can remove it.

Thats what I would do, how are you actually drawing the images in at the moment?
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 7
Reputation: TingTing is an unknown quantity at this point 
Solved Threads: 0
TingTing's Avatar
TingTing TingTing is offline Offline
Newbie Poster

Re: help plss..emergency.

 
0
  #5
Mar 24th, 2007
Originally Posted by cms271828 View Post
Hmmm,

Well I'm assuming you're using JPanel, or extending JPanel and thus using paintComponent(Graphics g) method.

The you draw image using g.drawImage(image,x,y,this);

So to remove the image, I would have some boolean or array that is updated when you press new game, then you can call repaint() on the JPanel object, and if you have some kind of IF statement by the drawImage, you can remove it.

Thats what I would do, how are you actually drawing the images in at the moment?
thank you for the answer..hehe.. what i do on "new game" is.. each time i click on the new game button there would be a new frame, but the dispose() method is not functioning,, so there are alot of frames..how can i solve this? i want to close the previous frame..

i put
private static JFrame frame = new JFrame ("TicTacToe");under public class

then:
public void actionPerformed(ActionEvent e){
if (e.getActionCommand().equals("New Game")){
// frame.dispose();//is not working..y?
// frame.setVisible(false);not working also..
JFrame frame = new JFrame("Tic-Tac-Toe");
frame.getContentPane().add (new TicTacToe());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setResizable(false);
frame.setVisible(true);
frame.pack();
}

after that:
public static void main (String[] args) {
JFrame frame = new JFrame("Tic-Tac-Toe");
frame.getContentPane().add (new TicTacToe());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setResizable(false);
frame.setVisible(true);
frame.pack();
}

.. im just beginning to learn java syntax is so hard
JavaIdiot
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 101
Reputation: cms271828 is an unknown quantity at this point 
Solved Threads: 4
cms271828 cms271828 is offline Offline
Junior Poster

Re: help plss..emergency.

 
0
  #6
Mar 24th, 2007
I'm not quite sure what your doing, you seem to be making a new JFrame for each move.
I would just use 1 JFrame containing a JPanel, or object from a class like NoughtsAndCrossesBoard extends JPanel.
Then do all the repainting inside there, you could have an array of 9 ints, each one either 0 for empty, 1 for X, 2 for O.
Then when you repaint, you just read off the array to see what you need.

So when you press new game, you will have:
public void actionPerformed(ActionEvent e)
{
if (e.getActionCommand().equals("New Game"))
{
for(int lp=0;lp<9;lp++) array[lp]=0;
noughtAndCrossesBoard.repaint();
}
}

Hope that helps
Last edited by cms271828; Mar 24th, 2007 at 3:46 pm.
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 7
Reputation: TingTing is an unknown quantity at this point 
Solved Threads: 0
TingTing's Avatar
TingTing TingTing is offline Offline
Newbie Poster

Re: help plss..emergency.

 
0
  #7
Mar 24th, 2007
Originally Posted by cms271828 View Post
I'm not quite sure what your doing, you seem to be making a new JFrame for each move.
I would just use 1 JFrame containing a JPanel, or object from a class like NoughtsAndCrossesBoard extends JPanel.
Then do all the repainting inside there, you could have an array of 9 ints, each one either 0 for empty, 1 for X, 2 for O.
Then when you repaint, you just read off the array to see what you need.

So when you press new game, you will have:
public void actionPerformed(ActionEvent e)
{
if (e.getActionCommand().equals("New Game"))
{
for(int lp=0;lp<9;lp++) array[lp]=0;
noughtAndCrossesBoard.repaint();
}
}

Hope that helps
i got what u mean.ty. but the compiler says that the repint() is a nonstatic method which cant be combine w/ my class tictatactoe

tictactoe.repaint();
JavaIdiot
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 101
Reputation: cms271828 is an unknown quantity at this point 
Solved Threads: 4
cms271828 cms271828 is offline Offline
Junior Poster

Re: help plss..emergency.

 
0
  #8
Mar 25th, 2007
I'm sure it can, you've just coded it badly.
If you send me your code, I'll take a look.
Email is cms271828@yahoo.co.uk
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 7
Reputation: TingTing is an unknown quantity at this point 
Solved Threads: 0
TingTing's Avatar
TingTing TingTing is offline Offline
Newbie Poster

Re: help plss..emergency.

 
0
  #9
Mar 25th, 2007
thank u.. but i finished it already yesterday except the computer-player and it's due today..yeah!! i can have my beauty sleep atlast!! hahaha...joke..

thank u for those who tried to help
JavaIdiot
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Java Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC