Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 35 additions & 5 deletions Puzzle Game/puzzleGame.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@


import java.awt.*;  
import javax.swing.*;  
import java.awt.event.*;  
public class puzzle extends JFrame implements ActionListener{  
JButton b1,b2,b3,b4,b5,b6,b7,b8,b9,next;  
puzzle(){  
super("Puzzle Game by rahulhgdev");  
super("Puzzle Game - JavaTpoint");  
 b1=new JButton("1");  
 b2=new JButton(" ");  
 b3=new JButton("3");  
Expand All @@ -20,16 +22,21 @@
b2.setBounds(70,30,50,40);  
b3.setBounds(130,30,50,40);  
b4.setBounds(10,80,50,40);  
b5.setBounds(70,800,50,40);  
b5.setBounds(70,80,50,40);  
b6.setBounds(130,80,50,40);  
b7.setBounds(10,130,500,40);  
b7.setBounds(10,130,50,40);  
b8.setBounds(70,130,50,40);  
b9.setBounds(130,130,50,40);  
next.setBounds(70,200,100,40);  

add(b1);add(b2);add(b3);add(b4). 
add(b1);add(b2);add(b3);add(b4);add(b5);add(b6);add(b7);add(b8);add(b9); add(next);  
b1.addActionListener(this);  
b2.addActionListener(this);   
b2.addActionListener(this);  
b3.addActionListener(this);  
b4.addActionListener(this);  
b5.addActionListener(this);  
b6.addActionListener(this);  
b7.addActionListener(this);  
b8.addActionListener(this);  
b9.addActionListener(this);  
next.addActionListener(this);  
Expand Down Expand Up @@ -88,6 +95,29 @@
else if(b8.getLabel().equals(" ")){ b8.setLabel(s); b5.setLabel(" ");}  
 }//end of if  

if(e.getSource()==b6){  

String s=b6.getLabel();  
if(b9.getLabel().equals(" ")){ b9.setLabel(s); b6.setLabel(" ");}  
else if(b3.getLabel().equals(" ")){ b3.setLabel(s); b6.setLabel(" ");}  
else if(b5.getLabel().equals(" ")){ b5.setLabel(s); b6.setLabel(" ");}  

 }//end of if  

if(e.getSource()==b7){  
String s=b7.getLabel();  
if(b4.getLabel().equals(" ")){ b4.setLabel(s); b7.setLabel(" ");}  
else if(b8.getLabel().equals(" ")){ b8.setLabel(s); b7.setLabel(" ");}  

 }//end of if  

if(e.getSource()==b8){  
String s=b8.getLabel();  
if(b7.getLabel().equals(" ")){ b7.setLabel(s); b8.setLabel(" ");}  
else if(b9.getLabel().equals(" ")){ b9.setLabel(s); b8.setLabel(" ");}  
else if(b5.getLabel().equals(" ")){ b5.setLabel(s); b8.setLabel(" ");}  

 }//end of if  

if(e.getSource()==b9){  
String s=b9.getLabel();  
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
# Puzzle-Game-In-Java-

UserName: prashantmore277
Name : Prashant More

- I fixed some major issues.