-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSevenPreCleanup.java
129 lines (98 loc) · 4.78 KB
/
SevenPreCleanup.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
import java.awt.*; //IMPORT ALL .AWT METHODS
import java.awt.event.*;
import javax.swing.*; //IMPORT ALL JAVAX SWING CLASSES/METHODS
import javax.swing.border.*;
import java.util.*;
import java.lang.*;
import java.lang.Object;
public class Six extends JFrame implements ActionListener
{
/*
setDefaultCloseOperation(SecondAttempt.DISPOSE_ON_CLOSE);
setSize(600,600);
setVisible(true);
* */
public Six()
{
setSize(444,410); //Set Size Of JFrame
Populate(); //Jump & Link To JPanel Creation & Working
}
public void Populate() //Code Jump & Link
{
JPanel WindowContents = new JPanel(); // Create New JPanel Called WindowContects
BorderLayout borderlayout = new BorderLayout(); //Creates BorderLayout Object
WindowContents.setLayout(borderlayout); //Sets Border Layout Using BorderLayout Object
WindowContents.setSize(600,600); //Set Size Of Windows Contents
WindowContents.setVisible(true); //Set Window Contents To Be Visible
WindowContents.setLayout(new GridLayout(3, 4)); //Sets Ordered Grid LAyout For JPanel
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Icon IconArray[] = new ImageIcon[12]; //Create Array For Images
IconArray[0] = new ImageIcon("bart0.jpg"); //Step Through Populate Each Array Entry With Each Image
IconArray[1] = new ImageIcon("bart1.jpg");
IconArray[2] = new ImageIcon("bart2.jpg");
IconArray[3] = new ImageIcon("bart3.jpg");
IconArray[4] = new ImageIcon("bart4.jpg");
IconArray[5] = new ImageIcon("bart5.jpg");
IconArray[6] = new ImageIcon("bart6.jpg");
IconArray[7] = new ImageIcon("bart7.jpg");
IconArray[8] = new ImageIcon("bart8.jpg");
IconArray[9] = new ImageIcon("bart9.jpg");
IconArray[10] = new ImageIcon("bart10.jpg");
IconArray[11] = new ImageIcon("bart11.jpg"); //Final Step Through
/*MattButton*/JButton JTileArray[] = new /*MattButton*/JButton[12];//Declare Array To Hold JButtons
int counter = 0; //Initialise Counter For While Loop
while(counter<12)
{
JButton tile = new JButton(IconArray[counter]); //Create New JButton With Image called Tile
tile.addActionListener(this); //AddActionListener To This Tile
//tile.setOpaque(true); //Idea For Transparency (REDUNDANT REMOVE)
JTileArray[counter] = tile ; //Walks Over Creating JTiles With Each BartImage To Corresponding Button In J Tile Array
//JTileArray[counter].addActionListener(this); //ATTEMPTING TO ADD ACTION LISTENER (REDUNDANT REMOVE)
counter = counter + 1; //
}
counter = counter-counter;
while(counter<12)
{
WindowContents.add(JTileArray[counter]); //Add Each JTile From Array To Panel
counter = counter + 1;
}
counter = counter - counter; //ResetLoop Counter
//JTileArray[0].setVisible(false); //Sets First J Tile To False
setContentPane(WindowContents); //Set The JPanel (WindowsContents To JFrame)
}
public static void main(String [] args)
{
Six ShowMe = new Six();
ShowMe.setVisible(true);
}
@Override
public void actionPerformed(ActionEvent e)
{
JButton something = (JButton) e.getSource(); //Something Stores The Tile That Clicks The Button
//Icon StoreImage = something.getImage(); //Stores The Image Of The Tile That Has Been Clicked
//ImageIcon[12] = StoreImage;
//NOTWORKINGRE-VISIBLECODE//something.setVisible(true); //Sets The Clicked Image To False
//BIN//Icon IconStorage[] = new ImageIcon[];
/*PROOFOFWORKING*/ //something.setOpaque(false);
/*PROOFOFWORKING*/ //something.setContentAreaFilled(false);
/*PROOFOFWORKING*/ //something.setBorderPainted(false);
/*IMAGEASSIGNMENTCODE*/ Icon GreyBox = new ImageIcon("bart0.jpg"); //Stores The Grey Box As An Image
/*IMAGEASSIGNMENTCODE*/ JButton tile2 = new JButton(GreyBox); //Assigns The Grey Box To A JButton
/*DEBUG DO ALL TRANSFERS NOT COME THROUGH*/ tile2.setOpaque(false);
/*THEY DONT*/ tile2.setContentAreaFilled(false);
/*THEY DONT*/ tile2.setBorderPainted(false);
tile2.setVisible(true);
//ATTEMPTEDBORDERCODE// Border thickBorder = new LineBorder(Color.WHITE, 12);
//ATTEMPTEDBORDERCODE// tile2.setBorder(thickBorder);
//10//JTileArray[0].setImage(ImageIcon[12]); //Sets The First Tile Of The Grid to the stored image that was clicked
/*GENERAL ASSIGNMENT FOR ALL CODE*/ //something = tile2; //GreyBox Tile "SHOULD" Replace The Tile That Was Clicked But It Doesn't
/*Code*/ something.setIcon(GreyBox);
//WORKINGINVISIBLECODE//something.setVisible(false);
}
//System.out.println("BUtton is clicked " + e.getSource()); Prrof That The Action Is Working
}
/*
* Want to declare a variable to store the source of the action event
* so that i can then set this variable to false
* GOAL: To Set The Button Click To Turn Invisible
* */