TicTacToe game in java

Thanks alot for offering change to ask u people about problem we face it in java .. iam student in java course and i have project which i find difficulty to solve the problem.. this project is need to implement the Java Applet . it is the game of TicTacToe game ..two class need to be created.one of them has n-by -n(4 bye 4). the constructor inlialize the empty table to all zeros . the TicTacToe game require two players. Whereever the first player selcts a cell of the table , assigne 1 as a number to the selected cell. assing 2 wherever the second player selects a cell The value of the cell connot to be changed. it keeps its value after the first assignation . your player are allowed to select the cells they are interseted in.To this end. the enter the number of rwo and number to column that defind the postion of a cell.The program keeps askind the player n-by-n times . Finaly the progam display the state of the table...
i hope some one answet to me soon .. i will be thanksfull for who could help me ..
thanks alot .. wating for the answer ..

heres a 3x3 one :)
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.Calendar;
public class TicTacToe extends JPanel
     private JButton b[][];
     private JButton newGame;
     private JPanel innerPanel;
     private JPanel gamePanel;
     private JTextArea statistics;
     private String symbol = "x";
     private int x;
     private int o;
     private boolean myturn;
     private JLabel lab;
     private int day, year, month;
     public TicTacToe()
          super();
          Calendar cal = Calendar.getInstance();
          day = cal.get(Calendar.DATE);
          year = cal.get(Calendar.YEAR);
          month = (cal.get(Calendar.MONTH) + 1);
          lab = new JLabel("" + day + "/" + month + "/" + year );
          innerPanel = new JPanel();
          innerPanel.setLayout(new GridLayout(1,2));
          gamePanel = new JPanel();
          b = new     JButton[3][3];
          x=o=0;
          setLayout(new BorderLayout());
          gamePanel.setLayout(new GridLayout(3,3));
          initialize(true);
          add(lab, BorderLayout.NORTH);
          statistics = new JTextArea();
          statistics.setEnabled(false);
          innerPanel.add(gamePanel);
          innerPanel.add(statistics);
          add(innerPanel,BorderLayout.CENTER);
          printStatistics();
     private ActionListener createActionListener(JButton button)
          final JButton b = button;
          ActionListener a =
                    new ActionListener()
                         public void actionPerformed(ActionEvent ae)
                              doPlay(b);
          return a;
     private void doPlay(JButton b)
          if (b.getText().equals(""))
               b.setText(symbol);
               if (winCondition(symbol))
                    enableGame(false);
                    if (symbol.equals("x"))
                         x++;
                    else
                         o++;
                    printStatistics();
               if (symbol.equals("x"))
                    symbol = "o";
               else
                    symbol = "x";
     private boolean winCondition(String s)
          boolean condition = true;
          for (int i=0 ;i<3 ;i++ )
               condition = true;
               for (int j=0; j<3 ;j++ )
                    condition = (condition && b[i][j].getText().equals(s));
               if (condition)
                    return true;
          for (int i=0 ;i<3 ;i++ )
               condition = true;
               for (int j=0; j<3 ;j++ )
                    condition = (condition && b[j].getText().equals(s));
               if (condition)
                    return true;
          condition = true;
          for (int i=0; i<3 ; i++ )
               condition = (condition && b[i][i].getText().equals(s));
          if (condition)
               return true;
          condition = true;
          for (int i=0;i<3 ;i++ )
               condition = (condition && b[i][2-i].getText().equals(s));
          if (condition)
               return true;
          return false;
     private void enableGame(boolean flag)
          for (int i=0;i<3;i++)
               for (int j=0;j<3;j++)
                    b[i][j].setEnabled(flag);
     private void printStatistics()
          String print = "Player\tWins" +
                         "\nPlayer X\t" + x +
                         "\nPlayer O\t" +o;
          statistics.setText(print);
     public void initialize(boolean recreate)
          for (int i=0; i<3; i++)
               for (int j=0; j<3; j++)
                    if (recreate)
                         b[i][j]= new JButton();
                    b[i][j].addActionListener(createActionListener(b[i][j]));
                    if (recreate)
                         gamePanel.add(b[i][j]);
          if (recreate)
               newGame = new JButton("New Game");
          newGame.addActionListener
               new ActionListener()
                    public void actionPerformed(ActionEvent ae)
                         for (int i=0; i<3; i++)
                              for (int j=0; j<3; j++)
                                   setButtonCaption("",i,j);
                         enableGame(true);
          if (recreate)
               add(newGame,BorderLayout.SOUTH);
     public void setButtonCaption(String s,int row, int column)
          b[row][column].setText(s);
     public static void main(String[] args)
          //SplashScreen splash = new SplashScreen(1200, 1200,1);
          //splash.show();
          //dia sp = new dia(12);
          //sp.show();
          JFrame f = new JFrame("TicTacToe");
          Container c = f.getContentPane();
          TicTacToe t = new TicTacToe();
          f.addWindowListener
               new WindowAdapter()
                    public void windowClosing(WindowEvent we)
                         System.exit(0);
          c.add(t,BorderLayout.CENTER);
          f.setSize(300,200);
          f.show();

Similar Messages

  • How to make a TicTacToe game in Java?

    My assignment requires me to make a java applet tic tac toe game. I have come as far as creating panels and adding 9 buttons to the center panel. The logic defeats me. I have looked around at the web for source code but everything looks fairly complicated. Here's what I have so far:
    import java.awt.*;
    import java.awt.event.*;
    import java.applet.*;
    public class Homework5 extends Applet {
    Panel northPanel = new Panel();
    Panel southPanel = new Panel();
    Panel eastPanel = new Panel();
    Panel westPanel = new Panel();
    Panel mainPanel = new Panel();
    Button resetButton = new Button ("Tic Tac Toe");
    Button squares[];
    public void init() {
    setLayout(new BorderLayout());
    northPanel.setBackground(Color.orange);
    southPanel.setBackground(Color.orange);
    eastPanel.setBackground(Color.orange);
    westPanel.setBackground(Color.orange);
    mainPanel.setBackground(Color.orange);
    add("North", northPanel);
    add("South", southPanel);
    add("East", eastPanel);
    add("West", westPanel);
    add("Center", mainPanel);
    resetButton.setFont(new Font("Arial", Font.PLAIN, 12));
    northPanel.add(resetButton);
    mainPanel.setLayout(new GridLayout(3,3));
    squares = new Button[9];
    for ( int i = 0; i < 9; i++ ) {
    squares[i] = new Button();
    //squares.addActionListener(this);
    squares[i].setFont(new Font("Serif", Font.BOLD, 20));
    mainPanel.add(squares[i]);
    Can someone explain to me where I should go from here?
    Thanks.

    I figured it out. :-)
    I had to use 2 arrays (one to create the button and another to hold the X's and O's in memory). I also had to call on the getSource method for the values in my array. This is where I was getting stuck initially. 3 hours and 2 mountain dews later, I was all warm and fuzzy when it compiled without an error. :-)
    You can see it in action here:
    http://www.vnoel.com/pcc/cs162/applets/knarayan/homework5.html

  • Want help in developing my first game in java!!

    I want to develop a tetris game in java..can any one help me on this..basically i m new to java programming, i want to know abt the graphical part ..how to make that.. i will code the rest..I want to make an application rather than an applet..

    look at the Java2D demo that comes with the JDK
    it has lots of source code and just about everything you'll need to do in Tetris (technology wise) is in there, except the game logic.
    when you're ready to move into 3D and heavier apps, try this book:
    Practical Java Game Programming
    http://www.amazon.com/exec/obidos/tg/detail/-/1584503262/102-3570681-1096110?v=glance

  • Can I Write a * Game in Java?

    I have noticed loads of topics lately along the lines of "Can I write a quake style shooter in java" or "could I write a mmporg in Java" and similar for almost every style of game. I'd just like to make a quick point on this:
    Java is a programming language. At the stage it has reached now it can do anything any other programming language can do. It's strengths and weaknesses may be different from those of C, C++, Visual Basic, Lisp or whatever other languages people use regularly, but when it gets right down to it Java isn't the problem. If you can design it effectively then you can implement it in any complete language. It may not be easy but it is possible. The answer to this question is invariably yes.
    These forums are far more useful for asking practical questions rather than asking conceptual ones. A better question might be "how would I best start to design a * to be implemented in Java?"

    Yeah thats a good point. I think that Java has been so popular for so long that it can pretty well do anything as long as the designer designs it properly.
    I've made a http web server, and just yesterday I made a pong style game. Java works for almost anything. Take a cruse through the Java Programming forum. People there are using Java to sort money things and everything.

  • Making Games in Java!!!

    hey i want to make a game in java but i want to get a lot more ideas about what the game should be like and what it should do. I want to actually work with someone else to make the game and then we can sell it or something like that. So if anyone is interested just make a reply OR e-mail me at [email protected] thanks.

    hey i want to make a game in java but i want to get a
    lot more ideas about what the game should be like and
    what it should do. I want to actually work with
    someone else to make the game and then we can sell it
    or something like that. So if anyone is interested
    just make a reply OR e-mail me at [email protected]
    thanks.This post is an email harvester's dream.

  • ı  cant  still  play   at  yahoo  games   after  java   upgrade,  why    someone    doesn't  hall  me

    ı  have  mac  book  air   ,  mac  os  mountain  lion   x   8    2    and  java   7   9  is  loaded...ı  cant  play    at  yahoo  games   after  java  upgradede  to   7 9  ,  ı  have  been   writing  here   to  expect  someone  hear me   and  help  me?   is  this   just  for   trade   or    help  customers    to  solve   problems  they  meet...ı   want  apple  professionals    hear   and  help  me  !!!  what  can  ı  do?    all  were   done  properly  but   when  ı   enter  yahoo  lounge   and  attemp  to    join  a  table   ,   it  quits   and    ı  cant  join  then  it  says  error  lodging....can  someone  help  me  ,  pls  urgent  !!!!

    ı  have  mac  book  air   ,  mac  os  mountain  lion   x   8    2    and  java   7   9  is  loaded...ı  cant  play    at  yahoo  games   after  java  upgradede  to   7 9  ,  ı  have  been   writing  here   to  expect  someone  hear me   and  help  me?   is  this   just  for   trade   or    help  customers    to  solve   problems  they  meet...ı   want  apple  professionals    hear   and  help  me  !!!  what  can  ı  do?    all  were   done  properly  but   when  ı   enter  yahoo  lounge   and  attemp  to    join  a  table   ,   it  quits   and    ı  cant  join  then  it  says  error  lodging....can  someone  help  me  ,  pls  urgent  !!!!

  • Space Game In Java

    Hi Java Game Developers
    Me and a friend from work developed a game in Java. Its at www.spacemercenaries.com
    If you want to play click on play sm, this will load the client applet.
    It will also ask you to confirm a certificate, this is because the applet uses sockets to connect to the server and if you view battles it saves a copy of the battle to your machine (the files will be stored in your home directory for the use logged on - to see the directory open the java console and you sould find it there)
    If you have any questions or comments please feel free to ask and comment :-)

    You should write a JFrame version of the game so it runs faster. Also that means that if your web browser's java plugin doesn't work but you have java installed (like me) then you can still play the game. If you need help porting, I'll do it.
    Just a thought.
    For free Java Games/Apps and a free tech support, go to my website at
    www.freewebs.com/masternerdguy

  • Need help creating text based game in Java

    Alright, I'm taking a big leap and I'm jumping a little out of league here. Anyways here are my two classes...I'm sure I've got plenty of errors :-/ One other thing. I have only programmed the battle section of the program so don't worry about the other 5 sections when fixing the code.
    import cs1.Keyboard;
    public class Knights
        public static void main (String[] args)
            // Object Declaration
            KnightsAccount player1 = new Account (1, 100, 200);
            // variable declarations
            boolean run = true;
            int choice;
            // Game Start
            System.out.println ("Welcome to Knights.");
            System.out.println ("--------------------------------------");
            System.out.println ("You are a level 1 character.  With 100 HP and 200 gold...good luck.");
            System.out.println ();
            while (run == true)
                System.out.println ();
                System.out.println ("Enter the number of the option you would like to do");
                System.out.println ();
                System.out.println ("1. Battle");
                System.out.println ("2. Train");
                System.out.println ("3. Work");
                System.out.println ("4. Rest");
                System.out.println ("5. Stats");
                System.out.println ("6. Quit");
                choice = Keyboard.readInt();
                if (choice == 1)
                    player1.battle();
                else if (choice == 2)
                    player1.train();
                else if (choice == 3)
                    player1.work();
                else if (choice == 4)
                    player1.rest();
                else if (choice == 5)
                    player1.stats();
                else
                    run = false;
    }And here is the second class...
    import java.util.Random;
    public class KnightsAccount
        public String winner;
        public int exp = 0;
        public void Account (int level, int hitPoints, int gold) {}
        public battle ()
            Random generator = new Random();
            int pumpkinHP = 80;
            int playerAttack, pumpkinAttack;
            System.out.println ("Engaged in combat with an Evil Pumpkin!");
            while (hitPoints > 0 && pumpkinHP > 0)
                if (pumpkinHP > 0)
                    playerAttack = generator.nextInt(15);
                    hitPoints -= playerAttack;
                    System.out.println ("Player 1 attacked Evil Pumpkin for " + playerAttack + ".");
                    System.out.println ("Evil Pumpkin has " + hitPoints + " HP left.");
                if (pumpkinHP <= 0)
                    pumpkinDead();
                if (hitPoints > 0 && !(pumpkinHP <= 0))
                    pumpkinAttack = generator.nextInt(12);
                    hitPoints -= pumpkinAttack;
                    System.out.println ("Evil Pumpkin attacked Player1 for " + pumpkinAttack + ".");
                    System.out.println ("Player 1 has " + pumpkinHP + " HP left.");
                if (hitPoints <= 0)
                    playerDead();
            return winner;
        private pumpkinDead ()
            System.out.println ("Success!  You have defeated the Evil Pumpkin with " + hitPoints + "HP left!");
            System.out.println ("For you good deed you earned 20 exp.");
            exp += 20;
            return exp;
        private void playersDead ()
            System.out.println ("You have been defeated.  Go home before we pelt melty cheeze at you.");
    }Whoever can help me I'd be grateful. I know there are probably a lot of things wrong here. Also if some of you could post your AIM or MSN so that I can get some one on one help on any of the smaller problems I run acrost that would help a lot too.
    Duke dollars to whoever helps me ;)
    AIM: Trebor DoD
    MSN: [email protected]

    You should really create a GameCharacter object that contains the
    statistics for a character (player or non-player) in the game.
    public class GameCharacter {
       private double attackStrength;
       private double defenseStrength;
       private String name;
       private String[] bodyParts;
       private Random = new Random();
    public GameCharacter(String name, String[] bodyParts, double attackSt, double defenseSt){
       this.attackStrength = attackSt;
       this.defenseStrength = defenseSt;
       this.bodyParts = bodyParts;
       this.name = name;
    // put lots of methods in here to get and set the information
    public String getName(){
      return this.name;
    public String getRandomBodyPart(){
       return this.bodyParts[random.nextInt(this.bodyParts.length)];
    }You then create your "knight" character and your "rabid pumpkin"
    character.
    Your fight method then just takes two GameCharacter objects and uses
    the information they contain to fight the battle.
    public void fight(GameCharacter a, GameCharacter b) {
       boolean fightOver = false;
       Random rn = new Random();
       double attackValue;
       while(!fightOver) {
           attackValue = a.getAttackStrength()*rn.nextDouble();
           System.out.println(a.getName()+" attacks "+b.getName()+"'s "+b.getRandomBodyPart()+" for "+attackValue+" points");
    }The above is not the fighting loop of course. I just put it in to
    demostrate how the fight method can be made generic. It takes any
    two characters and uses their defensive and attack information to
    calculate the fight outcome. It also uses the descriptions that the characters have
    to make the fight more interesting. (the getRandomBodyPart method in
    particular)
    matfud

  • Ping Pong Game In Java

    Ello,
    Im Trying to write a simple ping pong game in a java netbeans.
    the problem is that i got the ball to move but it doesnt seem to move around the screen just in the same direction. heres the code:
    * PingPong.java
    * Created on 23 November 2006, 15:33
    * @author  rshabbir
    import java.awt.*;
    import java.awt.geom.*;
    import javax.swing.*;
    public class PingPongGame extends javax.swing.JFrame {
        /** Creates new form PingPong */
        public PingPongGame() {
            initComponents();
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
        // <editor-fold defaultstate="collapsed" desc=" Generated Code ">
        private void initComponents() {
            jPanel1 = new javax.swing.JPanel();
            jLabel1 = new javax.swing.JLabel();
            jButton1 = new javax.swing.JButton();
            jButton2 = new javax.swing.JButton();
            jButton5 = new javax.swing.JButton();
            jButton6 = new javax.swing.JButton();
            jPanel3 = new DrawingPanel();
            getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            setTitle("PING PONG");
            jPanel1.setBackground(new java.awt.Color(0, 0, 0));
            jPanel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
            jLabel1.setFont(new java.awt.Font("Brush Script MT", 1, 14));
            jLabel1.setForeground(new java.awt.Color(255, 255, 255));
            jLabel1.setText("CONTROL PANEL");
            jButton1.setFont(new java.awt.Font("Brush Script MT", 1, 12));
            jButton1.setText("BAT");
            jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
                public void mouseClicked(java.awt.event.MouseEvent evt) {
                    jButton1MouseClicked(evt);
            jButton2.setFont(new java.awt.Font("Brush Script MT", 1, 12));
            jButton2.setText("SPEED");
            jButton2.addMouseListener(new java.awt.event.MouseAdapter() {
                public void mouseClicked(java.awt.event.MouseEvent evt) {
                    jButton2MouseClicked(evt);
            jButton5.setFont(new java.awt.Font("Brush Script MT", 1, 12));
            jButton5.setText("BALL");
            jButton5.addMouseListener(new java.awt.event.MouseAdapter() {
                public void mouseClicked(java.awt.event.MouseEvent evt) {
                    jButton5MouseClicked(evt);
            jButton6.setFont(new java.awt.Font("Brush Script MT", 1, 12));
            jButton6.setText("EXIT");
            jButton6.addMouseListener(new java.awt.event.MouseAdapter() {
                public void mouseClicked(java.awt.event.MouseEvent evt) {
                    jButton6MouseClicked(evt);
            org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
            jPanel1.setLayout(jPanel1Layout);
            jPanel1Layout.setHorizontalGroup(
                jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(jPanel1Layout.createSequentialGroup()
                    .addContainerGap()
                    .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                        .add(jLabel1)
                        .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                            .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel1Layout.createSequentialGroup()
                                .add(jButton2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED))
                            .add(org.jdesktop.layout.GroupLayout.TRAILING, jButton1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                        .add(jButton6, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .add(jButton5, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addContainerGap(60, Short.MAX_VALUE))
            jPanel1Layout.setVerticalGroup(
                jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(jPanel1Layout.createSequentialGroup()
                    .addContainerGap()
                    .add(jLabel1)
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 15, Short.MAX_VALUE)
                    .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                        .add(jButton1)
                        .add(jButton5))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                        .add(jButton6)
                        .add(jButton2))
                    .addContainerGap(38, Short.MAX_VALUE))
            getContentPane().add(jPanel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 290, 140));
            jPanel3.setBackground(new java.awt.Color(0, 0, 0));
            org.jdesktop.layout.GroupLayout jPanel3Layout = new org.jdesktop.layout.GroupLayout(jPanel3);
            jPanel3.setLayout(jPanel3Layout);
            jPanel3Layout.setHorizontalGroup(
                jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(0, 290, Short.MAX_VALUE)
            jPanel3Layout.setVerticalGroup(
                jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(0, 370, Short.MAX_VALUE)
            getContentPane().add(jPanel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 140, 290, 370));
            pack();
        }// </editor-fold>
        private void jButton6MouseClicked(java.awt.event.MouseEvent evt) {
    // TODO add your handling code here:
        private void jButton5MouseClicked(java.awt.event.MouseEvent evt) {
    // TODO add your handling code here:
        private void jButton2MouseClicked(java.awt.event.MouseEvent evt) {
        private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {
         * @param args the command line arguments
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new PingPongGame().setVisible(true);
        // Variables declaration - do not modify
        private javax.swing.JButton jButton1;
        private javax.swing.JButton jButton2;
        private javax.swing.JButton jButton5;
        private javax.swing.JButton jButton6;
        private javax.swing.JLabel jLabel1;
        private javax.swing.JPanel jPanel1;
        private DrawingPanel jPanel3;
        // End of variables declaration
    class DrawingPanel extends JPanel
        int x,y,xdir=1,ydir=2 ;
        int interval = 30;
        int x_pos = 10;
        int y_pos = 10;
        int radius = 5;
        int x_speed = 10;
        int y_speed = 10;
        int jframesize_x = 280;
        int jframesize_y = 280;
        //int x = 150, y = 100, r=50;      // Position and radius of the circle
        //int dx = 8, dy = 5;              // Trajectory of circle
    public void paintComponent(Graphics g)
           Rectangle2D rect;
          Ellipse2D e;
           GradientPaint gp;
           Graphics2D gg;
           super.paintComponent(g);
           setBackground(new java.awt.Color(0, 0, 0));
           gg = (Graphics2D)g;
           gg.setColor(Color.red);
           rect = new Rectangle2D.Float(40, 30, 60, 20);
           gg.draw(rect);
           gg.fill(rect);
           gg = (Graphics2D)g;
           gg.setColor(Color.red);
           rect = new Rectangle2D.Float(110, 30, 60, 20);
           gg.draw(rect);
           gg.fill(rect);
           gg = (Graphics2D)g;
           gg.setColor(Color.red);
           rect = new Rectangle2D.Float(180, 30, 60, 20);
           gg.draw(rect);
           gg.fill(rect);
           gg = (Graphics2D)g;
           gg.setColor(Color.green);
           rect = new Rectangle2D.Float(40, 60, 60, 20);
           gg.draw(rect);
           gg.fill(rect);
           gg = (Graphics2D)g;
           gg.setColor(Color.green);
           rect = new Rectangle2D.Float(110, 60, 60, 20);
           gg.draw(rect);
           gg.fill(rect);
           gg = (Graphics2D)g;
           gg.setColor(Color.green);
           rect = new Rectangle2D.Float(180, 60, 60, 20);
           gg.draw(rect);
           gg.fill(rect);
           gg = (Graphics2D)g;
           gg.setColor(Color.blue);
           rect = new Rectangle2D.Float(40, 90, 60, 20);
           gg.draw(rect);
           gg.fill(rect);
           gg = (Graphics2D)g;
           gg.setColor(Color.blue);
           rect = new Rectangle2D.Float(110, 90, 60, 20);
           gg.draw(rect);
           gg.fill(rect);
           gg = (Graphics2D)g;
           gg.setColor(Color.blue);
           rect = new Rectangle2D.Float(180, 90, 60, 20);
           gg.draw(rect);
           gg.fill(rect);
           gg = (Graphics2D)g;
           gg.setColor(Color.yellow);
           rect = new Rectangle2D.Float(40, 120, 60, 20);
           gg.draw(rect);
           gg.fill(rect);
           gg = (Graphics2D)g;
           gg.setColor(Color.yellow);
           rect = new Rectangle2D.Float(110, 120, 60, 20);
           gg.draw(rect);
           gg.fill(rect);
           gg = (Graphics2D)g;
           gg.setColor(Color.yellow);
           rect = new Rectangle2D.Float(180, 120, 60, 20);
           gg.draw(rect);
           gg.fill(rect);
           gg = (Graphics2D)g;
           gg.setColor(Color.magenta);
           rect = new Rectangle2D.Float(110, 150, 60, 20);
           gg.draw(rect);
           gg.fill(rect);
           gg = (Graphics2D)g;
           gg.setColor(Color.magenta);
           rect = new Rectangle2D.Float(110, 180, 60, 20);
           gg.draw(rect);
           gg.fill(rect);
           gg = (Graphics2D)g;
           gg.setColor(Color.magenta);
           rect = new Rectangle2D.Float(110, 210, 60, 20);
           gg.draw(rect);
           gg.fill(rect);
           gg = (Graphics2D)g;
           gg.setColor(Color.pink);
           rect = new Rectangle2D.Float(180, 150, 60, 20);
           gg.draw(rect);
           gg.fill(rect);
           gg = (Graphics2D)g;
           gg.setColor(Color.pink);
           rect = new Rectangle2D.Float(180, 180, 60, 20);
           gg.draw(rect);
           gg.fill(rect);
           gg = (Graphics2D)g;
           gg.setColor(Color.pink);
           rect = new Rectangle2D.Float(180, 210, 60, 20);
           gg.draw(rect);
           gg.fill(rect);
           gg = (Graphics2D)g;
           gg.setColor(Color.cyan);
           rect = new Rectangle2D.Float(40, 150, 60, 20);
           gg.draw(rect);
           gg.fill(rect);
           gg = (Graphics2D)g;
           gg.setColor(Color.cyan);
           rect = new Rectangle2D.Float(40, 180, 60, 20);
           gg.draw(rect);
           gg.fill(rect);
           gg = (Graphics2D)g;
           gg.setColor(Color.cyan);
           rect = new Rectangle2D.Float(40, 210, 60, 20);
           gg.draw(rect);
           gg.fill(rect);
           gg = (Graphics2D)g;
           gg.setColor(Color.white);
           rect = new Rectangle2D.Float(110, 350, 60, 10);
           gg.draw(rect);
           gg.fill(rect);
           //g.fillOval (x_pos - radius, y_pos - radius, 2 * radius, 2 * radius);
            try{
               Thread.sleep(15);
           } catch(InterruptedException E){}
           repaint();
           x_pos++;
           y_pos++;
           repaint();
            e = new Ellipse2D.Float(x,y,10,10); 
            gp = new GradientPaint(150,50, Color.white, 200,100, Color.white, true);
            gg.setPaint(gp);
            gg.fill(e);
            try{
               Thread.sleep(15);
           } catch(InterruptedException E){}
           repaint();
           x=x+1;
           y=y+1;
           repaint();
           if(x > jframesize_x - radius)
            x_speed = -1;
          else if(x < radius)
             x_speed = +1;
          x += x_speed;
          y += x_speed;
          x--;
          y--;
          //if ((x - r + x_pos < 0) || (x + r + x_pos > jframesize_x)) x_pos = x_pos;
          //if ((y - r + y_pos < 0) || (y + r + y_pos > jframesize_y)) y_pos = y_pos;
          //x += x_pos;  y += y_pos;
          //repaint(x-r-x_pos, y-r-x_pos, 2*r, 2*r);   // repaint old position of circle
          //repaint(x-r, y-r, 2*r, 2*r);  
         // try { Thread.sleep(50); } catch (InterruptedException e) { ; }
           

    go away. u just dont want to helpFuck off jackfuck.
    You whined the same thing in the other thread when people asked for code tags. You have also got lots of actual advice and suggestions in your other thread and ignore them all.
    Crossposting is rude but I suppose we should not expect any better from you because so far all you have demonstrated on this site is that you are rude, incredibly stupid and lazy.

  • How do i play yahoo games without java

    installing java to run games on my galaxy tab

    It is not possible to run Java based browser plugins in Android. Oracle, the people who make Java and Google, the people who make Android are currently in a legal battle. I would not expect Oracle to be releasing a Java plugin for Android due to this legal fight.
    As a workaround I would suggest searching the Android market (Play Store) for the type of game you want to play. There are hundreds of free and paid game apps in the store.

  • Basic Football Manager Game in Java

    [http://bygfoot.sourceforge.net/new/about/]
    Hi,
    I would like to create a basic Football Manager Game for the desktop using Netbeans.
    Is this the only package I will need to create this Game for the Desktop?
    What Java skills will I need to learn to create this game?
    Thanks in Advance
    Edited by: wakesta on Jul 5, 2010 11:10 AM

    You will need to know some of this Java. You should also become familiar with basic programming concepts, for that I would suggest a study of contemporary texts on programming--not on learning Java or a language specifically, but on programming itself.

  • Cell phone Games and Java

    I am not sure if this is the right place to post this topic if it is not please tell me were to post it thanks. sorry in adv.
    hi i have been programing apps in java for a little wile and was wondering how to make games for cell phone that are java enabled and how it would differ from normal desktop apps as there arent as many keys on a cell phone and the methods and classes i would need to extend and interfaces i would need to implement any help would be a greatful
    thanks
    nibur

    Here's a pretty good thread: http://forum.java.sun.com/thread.jsp?forum=406&thread=429254
    You can also try searching all forums, use the little search box in the lower right corner of this page: http://forum.java.sun.com/

  • Online Games and Java

    Hi. I'm running a 2Ghz Macbook with OSX 10.5.2 and I can't seem to play any games online and the sites always say that java isn't compatible.
    The site's I'm trying to play games on are www.playandwin.co.uk and also yahoo games. I've tried with both safari and firebox and same error everytime.
    When checking java in the application part of finder, it says i've got J2SE 5.0 and 1.4.2 and i've tried both but still nothing. Any ideas or suggestions ? I've tempted to install windows but really don't want to go to that extreme if possible but really want to play the games.

    Interesting fix. Being new to Macs I am not sure how that happened to you. I checked my Safari's info and Open with Rosetta was already unchecked. It's not that I cannot completely play Java games on Pogo, but if the game window does not crash, the game table will be blank and the chat text area will be shown, or the chat text area will be blank while the game table shows up.
    It is frustrating. Still, I think it is more to do with the developers and web designers than with our out of the box settings. In comparison, the majority of Windows PC's can play games on Pogo, Yahoo, MSN, etc., without much more than downloading and install ActiveX.
    If a Windows PC and a Mac both have the same version of Java installed, and all required platform updates are installed, respectively, what common sense reasoning would be behind the conflict that either platform would have with interacting with a Java based online gaming site?
    The coders do not write for the lesser number of site traffic. Hard to swallow, but it is my honest opinion. Still, I gave up frustrations I could count on when I shut down my PC for the last time and I do not intend to allow a lack of gaming to get me down as a new Mac user.

  • Yahoo games requires Java update

    then no matter what I can't get games. Even after update it keeps telling me the version is out of date. Anybody have a fix (again)??

    Thanks but I did all of that, no joy. This is a recurring problem with Apple and Java that always prevents Yahoo games from working. The Java version that Apple allows is always behind the most current version the rest of the world uses.

  • How do you deploy a stand alone app/game in java

    I have a few questions regarding creating a stand alone app for java.
    1) What is the best way to deploy it? how would I create the exe, etc. I've read that you can create executable jars but this doesn't seem like something that would be user friendly
    2) Is there a way to deploy the game/app with it's own JVM so the hosts machine doesn't have to have it installed? How would I go about doing this?
    3) How would I run the app in full screen? What libraries are available?
    Any other advice/comments welcome.

    @morgair: There are plenty of good reasons for using Java to develop software, even when you only plan on targeting Windows. As good as Java distribution is there is no way to guarantee that they a) have Java installed and more likely b) have the version you target installed. Telling a user that they need to go to a second website in order to download and install more software is a huge turn off.
    Most PC users have no experience with a .jar so when they download it they just don't know what to do (even if all they need to do is double-click just like a .exe). Giving out an executable .jar is another turnoff.
    sarcasteak wrote:
    1) What is the best way to deploy it? how would I create the exe, etc. I've read that you can create executable jars but this doesn't seem like something that would be user friendlyIn terms of the .exe, Java does not create .exe's. There are some java to native compilers that will turn your java code into a natice .exe that will run on it's own or with a bundled library. However they are either old, buggy and badly supported, or extremely expensive (googling Java native compiler should give you some good results). There are also plenty 'java to exe' pieces of software. Rather then compiling the java code to native code they wrap the .jar up inside a .exe. When you run the .exe it unpacks the .jar and runs it. To the user it looks like a .exe, however it's still just an executable jar and still requires Java to be pre-installed on their machine in order to run (although some can offer custom error messages if Java is not found).
    If Java is setup, then executable jars are essentially act the same as exe's. For creating them, if you are using NetBeans then they are already available in the project/dist folder after you build. You can also do it on the command line but I never need to so I don't know how. However as a tutorial [this site looks promising|http://neptune.netcomp.monash.edu.au/javahelp/howto/jar.htm].
    I personally use a small .exe which I built using the D programming language. It reads from a text file in the same directory and executes each line in turn. Typically all the text file contains is 'java -jar MyProg.jar'. This way my .jars for the user looks like a .exe.
    Instead of a .exe you could also use a .bat. There are also some .bat to .exe converters online, although I haven't tried any of them so use at your own risk.
    sarcasteak wrote:
    2) Is there a way to deploy the game/app with it's own JVM so the hosts machine doesn't have to have it installed? How would I go about doing this?Yes, you are allowed to redistribute the Sun Java runtime. Just zip up the JRE on your machine and include it with the app/game. You'll also need to ensure that whatever starts the jar uses your unzipped JRE and not the JRE on their machine. The exe I described above also allows this by having the text file contain something like: './my_jre/bin/java -jar MyProg.jar'.
    But first you should also take a look at the license restrictions, they should be in the JREs directory. For example you must redistribute the complete JRE which is a problem if your app is just a few megabytes (when zipped the runtime is usually over 30mb). There are probably plenty of topics on this forum which already discuss redistribution of the JRE.
    sarcasteak wrote:
    3) How would I run the app in full screen? What libraries are available?If it's an app then it should be approximately:
    JFrame frame = new JFrame();
    frame.setExtendedState(JFrame.MAXIMIZED_BOTH);or;
    JFrame frame = new JFrame();
    frame.setExtendedState(frame.getExtendedState() | JFrame.MAXIMIZED_BOTH);However if you want a proper full screen then you need to use the [Full-Screen exclusive mode|http://java.sun.com/docs/books/tutorial/extra/fullscreen/exclusivemode.html], approximately:
    JFrame frame = new JFrame();
    GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().setFullScreenWindow( frame );I've also heard plenty of people recommend using java web-start for desktop java apps. Personally I've never used it, but it's something you might want to research.
    Edited by: jl235 on Jun 22, 2009 3:03 AM

Maybe you are looking for

  • Quicktime Player Pro won't play any movies?

    Ever since I restored my computer about a month ago, my Quicktime Player won't play any video formats correctly. .avi files don't play anymore, and mp4 files only play sound with the screen black. Then when I try to close the application, I get the p

  • New GL, profit center update

    New GL is working for this GL entry Credit cash A/C 900100 1000 Debit expense 500100 1000 CTR A PTR A After document splitting, system is showing Credit cash A/C 900100 1000 CTR A PTR A Debit expense 500100 1000 CTR A PTR A GL Entry Credit cash A/C 9

  • Ios7 - emails showing as unread in hotmail

    So I just downloaded ios7 and my little email icon is now showing that I have 6719 unread email messages - even though I don't. They're all in one of my hotmail email accounts, not any of my other ones (either hotmail or gmail). When I search for the

  • 'FTP_COMMAND'   error

    HI Friends,    I want to download sme txt file to ftp server.    i am using the FM "FTP_CONNECT" & "FTP_COMMAND".   here "FTP_CONNECT" is working fine  but "FTP_COMMAND" gives the following error. "open hb_file.txt errno 22: Invalid argument "       

  • Albanian keyboard

    Hi, I would like to ask you a simple question regarding to Keyboard Languages. I tried to change my keyboard in Albanian, but I couldn't find it in the list!!! Can you please update the list and add albanian language since the other OS have it and yo