Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: java game code

  1. #1
    Junior Member
    Join Date
    Aug 2012
    Posts
    2
    My Mood
    Stressed
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default java game code

    i wanna create a game in java(net beans)...please help me out with code part.....my game is all about player guessing the number which is randomly picked by the program....firstly the main concept is 1.There will be 9 boxes appearing on the screen with numbers from 1 to 9 assigned to them randomly. 2.All the boxes will be hiding the numbers which are assigned to them. But one of the box will show its number. 3.Now its time for the player to select any one of the box except the box which is showing its number. 4.When the player picks up his desired box and clicks on it, two buttons gets highlightened on the screen named UP or DIP. 5.Now the player should think logically and guess whether the number in the box which the player has picked is just more or less than the number which is already shown. 6.If the player has guessed it correctly then the player will be awarded +50 points else -50 points. 7.In the same manner the player continues to play the whole game until there are no more boxes hiding their numbers. please i want help about the code


  2. #2
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: java game code

    Looks likey you have a good start so far.

    Split up what you have into a list, like you have started doing with the numbers. From there you can work on one part at a time. If you run into problems as you go post more questions. I (and many others here) will continue to provide assistance, but not really just write code for you.

  3. #3
    Junior Member
    Join Date
    Aug 2012
    Posts
    2
    My Mood
    Stressed
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: java game code

    then look in to my code......
    screen1


    import java.util.Random;
    import java.lang.*;
    public class screen1 extends javax.swing.JFrame {


    public screen1() {
    initComponents();
    }
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {

    jLabel1 = new javax.swing.JLabel();
    jButton1 = new javax.swing.JButton();
    jButton2 = new javax.swing.JButton();
    jButton3 = new javax.swing.JButton();

    setDefaultCloseOperation(javax.swing.WindowConstan ts.DO_NOTHING_ON_CLOSE);
    setBackground(new java.awt.Color(0, 204, 204));
    setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
    setIconImages(null);
    setUndecorated(true);

    jLabel1.setFont(new java.awt.Font("Jokerman", 1, 36)); // NOI18N
    jLabel1.setForeground(new java.awt.Color(0, 102, 153));
    jLabel1.setText(" UP OR DIP");

    jButton1.setBackground(new java.awt.Color(102, 255, 255));
    jButton1.setFont(new java.awt.Font("Tempus Sans ITC", 1, 18)); // NOI18N
    jButton1.setForeground(new java.awt.Color(153, 102, 255));
    jButton1.setText("START");
    jButton1.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    jButton1ActionPerformed(evt);
    }
    });

    jButton2.setBackground(new java.awt.Color(102, 255, 255));
    jButton2.setFont(new java.awt.Font("Tempus Sans ITC", 1, 18)); // NOI18N
    jButton2.setForeground(new java.awt.Color(153, 102, 255));
    jButton2.setText("INSTRUCTIONS");
    jButton2.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    jButton2ActionPerformed(evt);
    }
    });

    jButton3.setBackground(new java.awt.Color(102, 255, 255));
    jButton3.setFont(new java.awt.Font("Tempus Sans ITC", 1, 18)); // NOI18N
    jButton3.setForeground(new java.awt.Color(153, 102, 255));
    jButton3.setText("QUIT");
    jButton3.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    jButton3ActionPerformed(evt);
    }
    });

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout .Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addContainerGap(javax.swing.GroupLayout.DEFAULT_S IZE, Short.MAX_VALUE)
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.TRAILING)
    .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 176, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 176, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 176, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addGap(217, 217, 217))
    .addGroup(layout.createSequentialGroup()
    .addGap(139, 139, 139)
    .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 319, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addContainerGap(157, Short.MAX_VALUE))
    );
    layout.setVerticalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout .Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addGap(16, 16, 16)
    .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addPreferredGap(javax.swing.LayoutStyle.Component Placement.UNRELATED)
    .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addPreferredGap(javax.swing.LayoutStyle.Component Placement.RELATED, 59, Short.MAX_VALUE)
    .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addGap(53, 53, 53)
    .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addGap(66, 66, 66))
    );

    pack();
    }// </editor-fold>

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
    setVisible(false);
    new screen2().setVisible(true);
    }

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
    System.exit(0);
    }

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
    setVisible(false);
    new S3().setVisible(true);
    }
    public static void main(String args[]) {

    java.awt.EventQueue.invokeLater(new Runnable() {

    public void run() {

    new screen1().setVisible(true);
    }
    });
    }
    // Variables declaration - do not modify
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JLabel jLabel1;
    // End of variables declaration
    }


    screen 2


    public class screen2 extends javax.swing.JFrame {

    public screen2() {
    initComponents();
    }


    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {

    jScrollPane1 = new javax.swing.JScrollPane();
    jTextArea1 = new javax.swing.JTextArea();
    jScrollPane2 = new javax.swing.JScrollPane();
    jTextArea2 = new javax.swing.JTextArea();
    jButton2 = new javax.swing.JButton();
    jScrollPane3 = new javax.swing.JScrollPane();
    jTextArea3 = new javax.swing.JTextArea();
    jButton1 = new javax.swing.JButton();
    jLabel2 = new javax.swing.JLabel();

    jTextArea1.setColumns(20);
    jTextArea1.setRows(5);
    jScrollPane1.setViewportView(jTextArea1);

    jTextArea2.setBackground(new java.awt.Color(153, 255, 255));
    jTextArea2.setColumns(20);
    jTextArea2.setFont(new java.awt.Font("Papyrus", 0, 13)); // NOI18N
    jTextArea2.setRows(5);
    jTextArea2.setText("1.There will be 10 boxes appearing on the screen wiyh numbers from 0 to 9 assigned to them.\n2.All the boxes will be hiding the numbers which are assigned to them. But one of the box will show its number.\n3.Now its time for the player to select any one of the box except the box which is showing its number.\n4.When the player picks up his desired box and clicks on it, two buttons gets highlightened on the screen named UP or DIP.\n5.Now the player should think logically and guess whether the number in the box which the player has picked is just more or less than the number which is already shown.\n\n");
    jTextArea2.setCursor(new java.awt.Cursor(java.awt.Cursor.TEXT_CURSOR));
    jScrollPane2.setViewportView(jTextArea2);

    jButton2.setText("jButton2");

    setDefaultCloseOperation(javax.swing.WindowConstan ts.DO_NOTHING_ON_CLOSE);
    setResizable(false);

    jTextArea3.setColumns(20);
    jTextArea3.setFont(new java.awt.Font("Kristen ITC", 1, 13)); // NOI18N
    jTextArea3.setRows(5);
    jTextArea3.setText("1.There will be 9 boxes appearing on the screen with numbers from 1 to 9 assigned to them.\n2.All the boxes will be hiding the numbers which are assigned to them. But one of the box will show its number.\n3.Now its time for the player to select any one of the box except the box which is showing its number.\n4.When the player picks up his desired box and clicks on it, two buttons gets highlightened on the screen named UP or DIP.\n5.Now the player should think logically and guess whether the number in the box which the player has picked is just more or less than the number which is already shown.\n6.If the player has guessed it correctly then the plyer will be awarded +50 points or else -50 points.\n7.In the same manner the player continues to play the whole game until there are no more boxes hiding their numbers.\n");
    jTextArea3.setEnabled(false);
    jScrollPane3.setViewportView(jTextArea3);

    jButton1.setBackground(new java.awt.Color(153, 204, 255));
    jButton1.setFont(new java.awt.Font("Kristen ITC", 1, 11)); // NOI18N
    jButton1.setText("BACK");
    jButton1.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    jButton1ActionPerformed(evt);
    }
    });

    jLabel2.setFont(new java.awt.Font("Showcard Gothic", 1, 36)); // NOI18N
    jLabel2.setText(" instructions");
    jLabel2.setMaximumSize(new java.awt.Dimension(205, 55));

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout .Alignment.LEADING)
    .addGroup(javax.swing.GroupLayout.Alignment.TRAILI NG, layout.createSequentialGroup()
    .addContainerGap(javax.swing.GroupLayout.DEFAULT_S IZE, Short.MAX_VALUE)
    .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 202, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addGap(476, 476, 476))
    .addGroup(layout.createSequentialGroup()
    .addGap(88, 88, 88)
    .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 1039, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addContainerGap(96, Short.MAX_VALUE))
    .addGroup(javax.swing.GroupLayout.Alignment.TRAILI NG, layout.createSequentialGroup()
    .addGap(0, 0, Short.MAX_VALUE)
    .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 1104, javax.swing.GroupLayout.PREFERRED_SIZE))
    );
    layout.setVerticalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout .Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addGap(22, 22, 22)
    .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 83, Short.MAX_VALUE)
    .addPreferredGap(javax.swing.LayoutStyle.Component Placement.RELATED)
    .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 282, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addPreferredGap(javax.swing.LayoutStyle.Component Placement.UNRELATED)
    .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addGap(6, 6, 6))
    );

    pack();
    }// </editor-fold>

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {

    setVisible(false);
    new screen1().setVisible(true);
    }


    public static void main(String args[]) {

    java.awt.EventQueue.invokeLater(new Runnable() {

    public void run() {
    new screen2().setVisible(true);
    }
    });
    }
    // Variables declaration - do not modify
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JTextArea jTextArea1;
    private javax.swing.JTextArea jTextArea2;
    private javax.swing.JTextArea jTextArea3;
    // End of variables declaration
    }


    screen 3

    import game.screen6;
    import java.util.Random;
    public class S3 extends javax.swing.JFrame {


    public S3() {
    initComponents();
    }


    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {

    jLabel1 = new javax.swing.JLabel();
    jButton14 = new javax.swing.JButton();
    jButton15 = new javax.swing.JButton();
    jButton16 = new javax.swing.JButton();
    jLabel2 = new javax.swing.JLabel();
    jButton1 = new javax.swing.JButton();
    jButton2 = new javax.swing.JButton();
    jButton3 = new javax.swing.JButton();
    jButton4 = new javax.swing.JButton();
    jButton5 = new javax.swing.JButton();
    jButton6 = new javax.swing.JButton();
    jButton7 = new javax.swing.JButton();
    jButton8 = new javax.swing.JButton();
    jButton9 = new javax.swing.JButton();
    jTextField1 = new javax.swing.JTextField();

    setDefaultCloseOperation(javax.swing.WindowConstan ts.DO_NOTHING_ON_CLOSE);

    jLabel1.setFont(new java.awt.Font("Chiller", 1, 48)); // NOI18N
    jLabel1.setForeground(new java.awt.Color(102, 51, 255));
    jLabel1.setText(" UP OR DIP ");

    jButton14.setBackground(new java.awt.Color(153, 153, 255));
    jButton14.setFont(new java.awt.Font("Tempus Sans ITC", 1, 36)); // NOI18N
    jButton14.setForeground(new java.awt.Color(102, 51, 255));
    jButton14.setText("UP");
    jButton14.setSelected(true);
    jButton14.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    jButton14ActionPerformed(evt);
    }
    });

    jButton15.setBackground(new java.awt.Color(153, 153, 255));
    jButton15.setFont(new java.awt.Font("Tempus Sans ITC", 1, 36)); // NOI18N
    jButton15.setForeground(new java.awt.Color(102, 51, 255));
    jButton15.setText("DIP");
    jButton15.setSelected(true);
    jButton15.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    jButton15ActionPerformed(evt);
    }
    });

    jButton16.setBackground(new java.awt.Color(153, 153, 255));
    jButton16.setFont(new java.awt.Font("Tempus Sans ITC", 1, 24)); // NOI18N
    jButton16.setText("BACK");
    jButton16.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    jButton16ActionPerformed(evt);
    }
    });

    jLabel2.setFont(new java.awt.Font("Bradley Hand ITC", 1, 24)); // NOI18N
    jLabel2.setText(" points");

    jButton1.setBackground(new java.awt.Color(153, 153, 255));
    jButton1.setFont(new java.awt.Font("Jokerman", 1, 48)); // NOI18N
    jButton1.setForeground(new java.awt.Color(102, 51, 255));
    jButton1.setText("0");
    jButton1.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    jButton1ActionPerformed(evt);
    }
    });

    jButton2.setBackground(new java.awt.Color(153, 153, 255));
    jButton2.setFont(new java.awt.Font("Jokerman", 0, 48)); // NOI18N
    jButton2.setForeground(new java.awt.Color(102, 51, 255));
    jButton2.setText("0");
    jButton2.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    jButton2ActionPerformed(evt);
    }
    });

    jButton3.setBackground(new java.awt.Color(153, 153, 255));
    jButton3.setFont(new java.awt.Font("Jokerman", 1, 48)); // NOI18N
    jButton3.setForeground(new java.awt.Color(102, 51, 255));
    jButton3.setText("0");
    jButton3.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    jButton3ActionPerformed(evt);
    }
    });

    jButton4.setBackground(new java.awt.Color(153, 153, 255));
    jButton4.setFont(new java.awt.Font("Jokerman", 1, 48)); // NOI18N
    jButton4.setForeground(new java.awt.Color(102, 51, 255));
    jButton4.setText("0");
    jButton4.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    jButton4ActionPerformed(evt);
    }
    });

    jButton5.setBackground(new java.awt.Color(153, 153, 255));
    jButton5.setFont(new java.awt.Font("Jokerman", 1, 48)); // NOI18N
    jButton5.setForeground(new java.awt.Color(102, 51, 255));
    jButton5.setText("0");
    jButton5.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    jButton5ActionPerformed(evt);
    }
    });

    jButton6.setBackground(new java.awt.Color(153, 153, 255));
    jButton6.setFont(new java.awt.Font("Jokerman", 1, 48)); // NOI18N
    jButton6.setForeground(new java.awt.Color(102, 51, 255));
    jButton6.setText("0");
    jButton6.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    jButton6ActionPerformed(evt);
    }
    });

    jButton7.setBackground(new java.awt.Color(153, 153, 255));
    jButton7.setFont(new java.awt.Font("Jokerman", 1, 48)); // NOI18N
    jButton7.setForeground(new java.awt.Color(102, 51, 255));
    jButton7.setText("0");
    jButton7.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    jButton7ActionPerformed(evt);
    }
    });

    jButton8.setBackground(new java.awt.Color(153, 153, 255));
    jButton8.setFont(new java.awt.Font("Jokerman", 1, 48)); // NOI18N
    jButton8.setForeground(new java.awt.Color(102, 51, 255));
    jButton8.setText("0");
    jButton8.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    jButton8ActionPerformed(evt);
    }
    });

    jButton9.setBackground(new java.awt.Color(153, 153, 255));
    jButton9.setFont(new java.awt.Font("Jokerman", 1, 48)); // NOI18N
    jButton9.setForeground(new java.awt.Color(102, 51, 255));
    jButton9.setText("0");
    jButton9.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    jButton9ActionPerformed(evt);
    }
    });

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout .Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addGap(35, 35, 35)
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addGap(25, 25, 25)
    .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 674, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addGroup(layout.createSequentialGroup()
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addGap(103, 103, 103)
    .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addGroup(javax.swing.GroupLayout.Alignment.TRAILI NG, layout.createParallelGroup(javax.swing.GroupLayout .Alignment.LEADING)
    .addComponent(jButton7, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)))
    .addGap(133, 133, 133)
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.LEADING, false)
    .addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    .addComponent(jButton5, javax.swing.GroupLayout.DEFAULT_SIZE, 90, Short.MAX_VALUE)
    .addComponent(jButton8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    .addGap(115, 115, 115)
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.LEADING, false)
    .addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE, 90, Short.MAX_VALUE)
    .addComponent(jButton6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    .addComponent(jButton9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
    .addContainerGap(130, Short.MAX_VALUE))
    .addGroup(layout.createSequentialGroup()
    .addComponent(jButton16)
    .addGap(109, 109, 109)
    .addComponent(jButton14, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addPreferredGap(javax.swing.LayoutStyle.Component Placement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    .addComponent(jButton15)
    .addGap(122, 122, 122)
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.LEADING, false)
    .addGroup(layout.createSequentialGroup()
    .addGap(10, 10, 10)
    .addComponent(jTextField1))
    .addComponent(jLabel2))
    .addGap(94, 94, 94))))
    );
    layout.setVerticalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout .Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addContainerGap()
    .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addGap(67, 67, 67)
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.BASELINE)
    .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addGap(40, 40, 40)
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.BASELINE)
    .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(jButton6, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addGap(35, 35, 35)
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.BASELINE)
    .addComponent(jButton7, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(jButton8, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(jButton9, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
    .addGap(119, 119, 119)
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.BASELINE)
    .addComponent(jButton16)
    .addComponent(jButton14)))
    .addGroup(javax.swing.GroupLayout.Alignment.TRAILI NG, layout.createSequentialGroup()
    .addPreferredGap(javax.swing.LayoutStyle.Component Placement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    .addComponent(jLabel2)
    .addPreferredGap(javax.swing.LayoutStyle.Component Placement.RELATED)
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.BASELINE)
    .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(jButton15))))
    .addGap(50, 50, 50))
    );

    pack();
    }// </editor-fold>

    private void jButton14ActionPerformed(java.awt.event.ActionEven t evt) {
    new screen5().setVisible(true);
    }

    private void jButton16ActionPerformed(java.awt.event.ActionEven t evt) {
    setVisible(false);
    new screen1().setVisible(true);
    }

    private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {
    String str=evt.getActionCommand();
    if(str.equals("0"))
    jButton6.setText("?");
    }

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
    String str=evt.getActionCommand();
    if(str.equals("0"))
    jButton1.setText("?");
    }

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
    String str=evt.getActionCommand();
    if(str.equals("0"))
    jButton2.setText("?");
    }

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
    String str=evt.getActionCommand();
    if(str.equals("0"))
    jButton3.setText("?");
    }

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
    String str=evt.getActionCommand();
    if(str.equals("0"))
    jButton4.setText("?");
    }

    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {
    String str=evt.getActionCommand();
    if(str.equals("0"))
    jButton5.setText("?");
    }

    private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {
    String str=evt.getActionCommand();
    if(str.equals("0"))
    jButton7.setText("?");
    }

    private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {
    String str=evt.getActionCommand();
    if(str.equals("0"))
    jButton8.setText("?");
    }

    private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {
    String str=evt.getActionCommand();
    if(str.equals("0"))
    jButton9.setText("?");
    }

    private void jButton15ActionPerformed(java.awt.event.ActionEven t evt) {
    new screen6().setVisible(true);
    }

    public static void main(String args[]) {

    java.awt.EventQueue.invokeLater(new Runnable() {

    public void run() {
    new S3().setVisible(true);
    }
    });
    }
    // Variables declaration - do not modify
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton14;
    private javax.swing.JButton jButton15;
    private javax.swing.JButton jButton16;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton6;
    private javax.swing.JButton jButton7;
    private javax.swing.JButton jButton8;
    private javax.swing.JButton jButton9;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JTextField jTextField1;
    // End of variables declaration
    }


    screen 4


    public class screen4 extends javax.swing.JFrame {


    public screen4() {
    initComponents();
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {

    jLabel3 = new javax.swing.JLabel();
    jLabel1 = new javax.swing.JLabel();
    jTextField1 = new javax.swing.JTextField();
    jLabel2 = new javax.swing.JLabel();
    jLabel4 = new javax.swing.JLabel();
    jButton1 = new javax.swing.JButton();

    jLabel3.setText("jLabel3");

    setDefaultCloseOperation(javax.swing.WindowConstan ts.DO_NOTHING_ON_CLOSE);
    setBackground(new java.awt.Color(153, 255, 255));
    setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
    setResizable(false);

    jLabel1.setFont(new java.awt.Font("Papyrus", 1, 36)); // NOI18N
    jLabel1.setText("You'r total score is... ");

    jTextField1.setText(" 0");
    jTextField1.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    jTextField1ActionPerformed(evt);
    }
    });

    jLabel2.setBackground(new java.awt.Color(102, 255, 255));
    jLabel2.setFont(new java.awt.Font("Showcard Gothic", 1, 48)); // NOI18N
    jLabel2.setForeground(new java.awt.Color(51, 153, 255));
    jLabel2.setText(" You won!!!!");

    jLabel4.setFont(new java.awt.Font("HP PSG", 1, 48)); // NOI18N
    jLabel4.setForeground(new java.awt.Color(0, 51, 102));
    jLabel4.setText("CONGRATULATIONS!!!!");

    jButton1.setBackground(new java.awt.Color(51, 153, 255));
    jButton1.setFont(new java.awt.Font("Tempus Sans ITC", 1, 18)); // NOI18N
    jButton1.setForeground(new java.awt.Color(0, 51, 255));
    jButton1.setText("HOME");
    jButton1.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    jButton1ActionPerformed(evt);
    }
    });

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout .Alignment.LEADING)
    .addGroup(javax.swing.GroupLayout.Alignment.TRAILI NG, layout.createSequentialGroup()
    .addGap(0, 0, Short.MAX_VALUE)
    .addComponent(jLabel1)
    .addGap(68, 68, 68))
    .addGroup(layout.createSequentialGroup()
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.LEADING)
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.TRAILING)
    .addGroup(layout.createSequentialGroup()
    .addContainerGap()
    .addComponent(jButton1))
    .addGroup(layout.createSequentialGroup()
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addGap(177, 177, 177)
    .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addGroup(layout.createSequentialGroup()
    .addGap(63, 63, 63)
    .addComponent(jLabel4)))
    .addGap(54, 54, 54)))
    .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 489, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addContainerGap())
    );
    layout.setVerticalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout .Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addComponent(jLabel1)
    .addPreferredGap(javax.swing.LayoutStyle.Component Placement.RELATED)
    .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addPreferredGap(javax.swing.LayoutStyle.Component Placement.RELATED)
    .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addPreferredGap(javax.swing.LayoutStyle.Component Placement.UNRELATED)
    .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addPreferredGap(javax.swing.LayoutStyle.Component Placement.RELATED, 27, Short.MAX_VALUE)
    .addComponent(jButton1)
    .addGap(22, 22, 22))
    );

    pack();
    }// </editor-fold>

    private void jTextField1ActionPerformed(java.awt.event.ActionEv ent evt) {
    // TODO add your handling code here:
    }

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
    setVisible(false);
    new screen1().setVisible(true);
    }


    public static void main(String args[]) {

    java.awt.EventQueue.invokeLater(new Runnable() {

    public void run() {
    new screen4().setVisible(true);
    }
    });
    }
    // Variables declaration - do not modify
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JTextField jTextField1;
    // End of variables declaration
    }


    screen5


    public class screen5 extends javax.swing.JFrame {


    public screen5() {
    initComponents();
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {

    jLabel1 = new javax.swing.JLabel();
    jButton1 = new javax.swing.JButton();

    setDefaultCloseOperation(javax.swing.WindowConstan ts.EXIT_ON_CLOSE);

    jLabel1.setFont(new java.awt.Font("Papyrus", 1, 48)); // NOI18N
    jLabel1.setText("You Selected....");

    jButton1.setText("jButton1");
    jButton1.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    jButton1ActionPerformed(evt);
    }
    });

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout .Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addGap(142, 142, 142)
    .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addGroup(layout.createSequentialGroup()
    .addContainerGap()
    .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 372, javax.swing.GroupLayout.PREFERRED_SIZE)))
    .addContainerGap(18, Short.MAX_VALUE))
    );
    layout.setVerticalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout .Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addGap(22, 22, 22)
    .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addContainerGap(135, Short.MAX_VALUE))
    );

    pack();
    }// </editor-fold>

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
    // TODO add your handling code here:
    }


    public static void main(String args[]) {

    java.awt.EventQueue.invokeLater(new Runnable() {

    public void run() {
    new screen5().setVisible(true);
    }
    });
    }
    // Variables declaration - do not modify
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    // End of variables declaration
    }


    screen 6

    /*
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    */
    package game;

    /**
    *
    * @author hp
    */
    public class screen6 extends javax.swing.JFrame {

    /**
    * Creates new form screen6
    */
    public screen6() {
    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.
    */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {

    jLabel1 = new javax.swing.JLabel();
    jButton1 = new javax.swing.JButton();

    setDefaultCloseOperation(javax.swing.WindowConstan ts.EXIT_ON_CLOSE);

    jLabel1.setFont(new java.awt.Font("Papyrus", 1, 48)); // NOI18N
    jLabel1.setText("You Selected...");

    jButton1.setText("jButton1");

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout .Alignment.LEADING)
    .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
    .addGroup(layout.createSequentialGroup()
    .addGap(141, 141, 141)
    .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 108, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addContainerGap())
    );
    layout.setVerticalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout .Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addContainerGap()
    .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addGap(18, 18, 18)
    .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addContainerGap(168, Short.MAX_VALUE))
    );

    pack();
    }// </editor-fold>

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
    /*
    * Set the Nimbus look and feel
    */
    //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
    /*
    * If Nimbus (introduced in Java SE 6) is not available, stay with the
    * default look and feel. For details see
    * How to Set the Look and Feel (The Java™ Tutorials > Creating a GUI With JFC/Swing > Modifying the Look and Feel)
    */
    try {
    for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
    if ("Nimbus".equals(info.getName())) {
    javax.swing.UIManager.setLookAndFeel(info.getClass Name());
    break;
    }
    }
    } catch (ClassNotFoundException ex) {
    java.util.logging.Logger.getLogger(screen6.class.g etName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (InstantiationException ex) {
    java.util.logging.Logger.getLogger(screen6.class.g etName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (IllegalAccessException ex) {
    java.util.logging.Logger.getLogger(screen6.class.g etName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (javax.swing.UnsupportedLookAndFeelException ex) {
    java.util.logging.Logger.getLogger(screen6.class.g etName()).log(java.util.logging.Level.SEVERE, null, ex);
    }
    //</editor-fold>

    /*
    * Create and display the form
    */
    java.awt.EventQueue.invokeLater(new Runnable() {

    public void run() {
    new screen6().setVisible(true);
    }
    });
    }
    // Variables declaration - do not modify
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    // End of variables declaration
    }

    .....nw help me out plzzzzzzzzzzzzzzzzz

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: java game code

    Please Edit your post and wrap your code with
    [code=java]
    <YOUR CODE HERE>
    [/code]
    to get highlighting and preserve formatting.

    What specific questions do you have about your code? There is way too much code posted for most of us to go through without something specific to look for. If you are having a problem with one part of the code, try to extract the code for that problem into a small program that compiles, executes and shows the problem.
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    Aug 2012
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: java game code

    I can't read code. Please post again

Similar Threads

  1. code for 3 card brag game
    By jay_tee92 in forum Object Oriented Programming
    Replies: 1
    Last Post: December 20th, 2011, 11:51 AM
  2. Checkers game code
    By mxthiry in forum What's Wrong With My Code?
    Replies: 3
    Last Post: November 13th, 2011, 12:50 PM
  3. Can anyone please help me with this java code for minesweeper game!
    By Mahela in forum What's Wrong With My Code?
    Replies: 5
    Last Post: January 25th, 2011, 08:10 AM
  4. Help With Java Game Code
    By CheekySpoon in forum What's Wrong With My Code?
    Replies: 0
    Last Post: April 26th, 2010, 04:07 PM
  5. Robo Code - The funny Java Programming Game
    By Freaky Chris in forum The Cafe
    Replies: 20
    Last Post: October 8th, 2009, 03:42 PM