| | |
I Need Help Please!
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Apr 2005
Posts: 3
Reputation:
Solved Threads: 0
hello experts!!!
im just a beginer.. thats wants to know alot..
i want to program my own tictactoe game.. but i dont have visual basic..can anybody plz.. give me some codes that i can edit my self with javascript or html.. if possible? can you make a tictactoe game with html or javascript?
plz let me know!!!
if so..
plz tell me the source codes. .so that i can just edit themm.. and put any pics.. or anything in it...
any help would greatly be apppreiciated..
thank you!!!
(my email - playboymaster911@bellsouth.net)
im just a beginer.. thats wants to know alot..
i want to program my own tictactoe game.. but i dont have visual basic..can anybody plz.. give me some codes that i can edit my self with javascript or html.. if possible? can you make a tictactoe game with html or javascript?
plz let me know!!!
if so..
plz tell me the source codes. .so that i can just edit themm.. and put any pics.. or anything in it...
any help would greatly be apppreiciated..
thank you!!!
(my email - playboymaster911@bellsouth.net)
•
•
Join Date: Apr 2005
Posts: 3
Reputation:
Solved Threads: 0
ok!
here...
this is what ive done so far..
but now what.. how can i save it as .exe or somethin.. i dotn got visual basic.. can u like make it for me to where i can just edit it and put any pics or music or anything?plz!!!!!!
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class TicTacToe extends JFrame implements ActionListener
{
public String play = "X's turn.";
public String one1 = " ";
public String two2 = " ";
public String three3 = " ";
public String four4 = " ";
public String five5 = " ";
public String six6 = " ";
public String seven7 = " ";
public String eight8 = " ";
public String nine9 = " ";
public boolean xTurn = true;
JButton one = new JButton(one1);
JButton two = new JButton(two2);
JButton three = new JButton(three3);
JButton four = new JButton(four4);
JButton five = new JButton(five5);
JButton six = new JButton(six6);
JButton seven = new JButton(seven7);
JButton eight = new JButton(eight8);
JButton nine = new JButton(nine9);
JLabel status = new JLabel(play);
public TicTacToe()
{
super("Tic-Tac-Toe");
setSize(200,200);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
Container contentArea = getContentPane();
GridBagLayout flowManager = new GridBagLayout();
GridBagConstraints pos = new GridBagConstraints();
contentArea.setLayout(flowManager);
one.addActionListener(this);
two.addActionListener(this);
three.addActionListener(this);
four.addActionListener(this);
five.addActionListener(this);
six.addActionListener(this);
seven.addActionListener(this);
eight.addActionListener(this);
nine.addActionListener(this);
pos.gridx=0; pos.gridy=0;
contentArea.add(one,pos);
pos.gridx=1; pos.gridy=0;
contentArea.add(two,pos);
pos.gridx=2; pos.gridy=0;
contentArea.add(three,pos);
pos.gridx=0; pos.gridy=1;
contentArea.add(four,pos);
pos.gridx=1; pos.gridy=1;
contentArea.add(five,pos);
pos.gridx=2; pos.gridy=1;
contentArea.add(six,pos);
pos.gridx=0; pos.gridy=2;
contentArea.add(seven,pos);
pos.gridx=1; pos.gridy=2;
contentArea.add(eight,pos);
pos.gridx=2; pos.gridy=2;
contentArea.add(nine,pos);
pos.gridx=1; pos.gridy=3;
contentArea.add(status,pos);
setContentPane(contentArea);
}
public void actionPerformed(ActionEvent event)
{
//O's Turn:
if(!(xTurn) && play=="O's turn." && event.getSource()==one){
one.setText("O");
xTurn=true;
status.setText("X's turn.");
}
else if(!(xTurn) && play=="O's turn." && event.getSource()==two){
two.setText("O");
xTurn=true;
status.setText("X's turn.");
}
else if(!(xTurn) && play=="O's turn." && event.getSource()==three){
three.setText("O");
xTurn=true;
status.setText("X's turn.");
}
else if(!(xTurn) && play=="O's turn." && event.getSource()==four){
four.setText("O");
xTurn=true;
status.setText("X's turn.");
}
else if(!(xTurn) && play=="O's turn." && event.getSource()==five){
five.setText("O");
xTurn=true;
status.setText("X's turn.");
}
else if(!(xTurn) && play=="O's turn." && event.getSource()==six){
six.setText("O");
xTurn=true;
status.setText("X's turn.");
}
else if(!(xTurn) && play=="O's turn." && event.getSource()==seven){
seven.setText("O");
xTurn=true;
status.setText("X's turn.");
}
else if(!(xTurn) && play=="O's turn." && event.getSource()==eight){
eight.setText("O");
xTurn=true;
status.setText("X's turn.");
}
else if(!(xTurn) && play=="O's turn." && event.getSource()==nine){
nine.setText("O");
xTurn=true;
status.setText("X's turn.");
}
//X's turn
if(xTurn && play=="X's turn." && event.getSource()==one){
one.setText("X");
xTurn=false;
status.setText("O's turn.");
}
else if(xTurn && play=="X's turn." && event.getSource()==two){
two.setText("X");
xTurn=false;
status.setText("O's turn.");
}
else if(xTurn && play=="X's turn." && event.getSource()==three){
three.setText("X");
xTurn=false;
status.setText("O's turn.");
}
else if(xTurn && play=="X's turn." && event.getSource()==four){
four.setText("X");
xTurn=false;
status.setText("O's turn.");
}
else if(xTurn && play=="X's turn." && event.getSource()==five){
five.setText("X");
xTurn=false;
status.setText("O's turn.");
}
else if(xTurn && play=="X's turn." && event.getSource()==six){
six.setText("X");
xTurn=false;
status.setText("O's turn.");
}
else if(xTurn && play=="X's turn." && event.getSource()==seven){
seven.setText("X");
xTurn=false;
status.setText("O's turn.");
}
else if(xTurn && play=="X's turn." && event.getSource()==eight){
eight.setText("X");
xTurn=false;
status.setText("O's turn.");
}
else if(xTurn && play=="X's turn." && event.getSource()==nine){
nine.setText("X");
xTurn=false;
status.setText("O's turn.");
}
}
public static void main(String[] args)
{ TicTacToe eg = new TicTacToe(); }
}
here...
this is what ive done so far..
but now what.. how can i save it as .exe or somethin.. i dotn got visual basic.. can u like make it for me to where i can just edit it and put any pics or music or anything?plz!!!!!!
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class TicTacToe extends JFrame implements ActionListener
{
public String play = "X's turn.";
public String one1 = " ";
public String two2 = " ";
public String three3 = " ";
public String four4 = " ";
public String five5 = " ";
public String six6 = " ";
public String seven7 = " ";
public String eight8 = " ";
public String nine9 = " ";
public boolean xTurn = true;
JButton one = new JButton(one1);
JButton two = new JButton(two2);
JButton three = new JButton(three3);
JButton four = new JButton(four4);
JButton five = new JButton(five5);
JButton six = new JButton(six6);
JButton seven = new JButton(seven7);
JButton eight = new JButton(eight8);
JButton nine = new JButton(nine9);
JLabel status = new JLabel(play);
public TicTacToe()
{
super("Tic-Tac-Toe");
setSize(200,200);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
Container contentArea = getContentPane();
GridBagLayout flowManager = new GridBagLayout();
GridBagConstraints pos = new GridBagConstraints();
contentArea.setLayout(flowManager);
one.addActionListener(this);
two.addActionListener(this);
three.addActionListener(this);
four.addActionListener(this);
five.addActionListener(this);
six.addActionListener(this);
seven.addActionListener(this);
eight.addActionListener(this);
nine.addActionListener(this);
pos.gridx=0; pos.gridy=0;
contentArea.add(one,pos);
pos.gridx=1; pos.gridy=0;
contentArea.add(two,pos);
pos.gridx=2; pos.gridy=0;
contentArea.add(three,pos);
pos.gridx=0; pos.gridy=1;
contentArea.add(four,pos);
pos.gridx=1; pos.gridy=1;
contentArea.add(five,pos);
pos.gridx=2; pos.gridy=1;
contentArea.add(six,pos);
pos.gridx=0; pos.gridy=2;
contentArea.add(seven,pos);
pos.gridx=1; pos.gridy=2;
contentArea.add(eight,pos);
pos.gridx=2; pos.gridy=2;
contentArea.add(nine,pos);
pos.gridx=1; pos.gridy=3;
contentArea.add(status,pos);
setContentPane(contentArea);
}
public void actionPerformed(ActionEvent event)
{
//O's Turn:
if(!(xTurn) && play=="O's turn." && event.getSource()==one){
one.setText("O");
xTurn=true;
status.setText("X's turn.");
}
else if(!(xTurn) && play=="O's turn." && event.getSource()==two){
two.setText("O");
xTurn=true;
status.setText("X's turn.");
}
else if(!(xTurn) && play=="O's turn." && event.getSource()==three){
three.setText("O");
xTurn=true;
status.setText("X's turn.");
}
else if(!(xTurn) && play=="O's turn." && event.getSource()==four){
four.setText("O");
xTurn=true;
status.setText("X's turn.");
}
else if(!(xTurn) && play=="O's turn." && event.getSource()==five){
five.setText("O");
xTurn=true;
status.setText("X's turn.");
}
else if(!(xTurn) && play=="O's turn." && event.getSource()==six){
six.setText("O");
xTurn=true;
status.setText("X's turn.");
}
else if(!(xTurn) && play=="O's turn." && event.getSource()==seven){
seven.setText("O");
xTurn=true;
status.setText("X's turn.");
}
else if(!(xTurn) && play=="O's turn." && event.getSource()==eight){
eight.setText("O");
xTurn=true;
status.setText("X's turn.");
}
else if(!(xTurn) && play=="O's turn." && event.getSource()==nine){
nine.setText("O");
xTurn=true;
status.setText("X's turn.");
}
//X's turn
if(xTurn && play=="X's turn." && event.getSource()==one){
one.setText("X");
xTurn=false;
status.setText("O's turn.");
}
else if(xTurn && play=="X's turn." && event.getSource()==two){
two.setText("X");
xTurn=false;
status.setText("O's turn.");
}
else if(xTurn && play=="X's turn." && event.getSource()==three){
three.setText("X");
xTurn=false;
status.setText("O's turn.");
}
else if(xTurn && play=="X's turn." && event.getSource()==four){
four.setText("X");
xTurn=false;
status.setText("O's turn.");
}
else if(xTurn && play=="X's turn." && event.getSource()==five){
five.setText("X");
xTurn=false;
status.setText("O's turn.");
}
else if(xTurn && play=="X's turn." && event.getSource()==six){
six.setText("X");
xTurn=false;
status.setText("O's turn.");
}
else if(xTurn && play=="X's turn." && event.getSource()==seven){
seven.setText("X");
xTurn=false;
status.setText("O's turn.");
}
else if(xTurn && play=="X's turn." && event.getSource()==eight){
eight.setText("X");
xTurn=false;
status.setText("O's turn.");
}
else if(xTurn && play=="X's turn." && event.getSource()==nine){
nine.setText("X");
xTurn=false;
status.setText("O's turn.");
}
}
public static void main(String[] args)
{ TicTacToe eg = new TicTacToe(); }
}
![]() |
Other Threads in the Java Forum
- Previous Thread: Help with overriding methods
- Next Thread: initialising objects help
Views: 1206 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for Java
3d @param affinetransform android api apple applet application arc arguments array arrays automation binary bluetooth byte c# chat class classes click client code color compare component corrupted database detection draw eclipse error event exception file fractal game givemetehcodez graphics gui guitesting helpwithhomework html ide image input integer j2me java java.xls javaprojects jmf jni jpanel julia keytool keyword linux list loop map method methods mobile netbeans newbie number object oracle pong print problem producer program programming project projectideas read recursion reflection rim scanner screen server set size sms socket sort sql string swing terminal test threads time transfer tree web windows






