Advertisement
Guest User

Jeronimus

a guest
May 10th, 2016
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.47 KB | None | 0 0
  1. import java.util.Random;
  2. import java.math.BigInteger;
  3. import java.util.ArrayList;
  4. import java.awt.AlphaComposite;
  5.  
  6. import java.awt.Graphics;
  7. import java.awt.Rectangle;
  8. import java.awt.*;
  9. import javax.swing.*;
  10. import java.awt.event.*;
  11.  
  12.  
  13. class cliquesGame4 {
  14.  
  15.  
  16. public static void main(String[] args) {
  17.  
  18.  
  19. System.setProperty("java.util.Arrays.useLegacyMergeSort", "true");
  20. int border = 40;
  21. int squareSize = 665;
  22. int numberOfStudents = 17;
  23. int minConnections = 6;
  24. int maxConnections = 9;
  25. long seed = new Random().nextLong();
  26. new mainBody(minConnections, maxConnections, numberOfStudents, seed, squareSize, border);
  27. }
  28. }
  29.  
  30.  
  31. class mainBody extends JFrame implements ActionListener {
  32.  
  33.  
  34. int numberOfStudents, minConnections,maxConnections,squareSize,
  35. border,restartMinConnections,restartMaxConnections,restartNumberOfStudents,restartSquareSize;
  36.  
  37. long seed;
  38. boolean lock= true;
  39. double tileSize;
  40. Color setColor = Color.red;
  41. Color unsetColor = new Color(144,144,144);
  42.  
  43.  
  44. Random rnd;
  45.  
  46. Rectangle rectangleA = new Rectangle();
  47. Rectangle rectangleB = new Rectangle();
  48.  
  49. ArrayList<Integer> toBeSwitchedX = new ArrayList<Integer>();
  50. ArrayList<Integer> toBeSwitchedY = new ArrayList<Integer>();
  51. Student[] arrayOfStudents;
  52.  
  53. JPanel jPanel;
  54. JTextField textField, minTextField, maxTextField, studentsTextField, squareSizeTextField;
  55. JustButton[] jbX;
  56. JustButton[] jbY;
  57. MyButton[][] myButton;
  58. JCheckBox checkBox;
  59.  
  60. public void restart() {
  61.  
  62. ensureConsistency();
  63. minConnections=Integer.parseInt(minTextField.getText());
  64. maxConnections=Integer.parseInt(maxTextField.getText());
  65. numberOfStudents=Integer.parseInt(studentsTextField.getText());
  66. squareSize=Integer.parseInt(squareSizeTextField.getText());
  67. if (squareSize<550){
  68. squareSize=550;
  69. squareSizeTextField.setText("550");
  70. }
  71.  
  72. this.dispose();
  73. new mainBody(minConnections, maxConnections,numberOfStudents,seed,squareSize,border);
  74. }
  75.  
  76. public mainBody(int minConnections, int maxConnections, int numberOfStudents, long seed, int squareSize,int border) {
  77.  
  78. this.minConnections = minConnections;
  79. this.maxConnections = maxConnections;
  80. this.numberOfStudents = numberOfStudents;
  81. this.seed = seed;
  82. this.squareSize = squareSize;
  83. this.border = border;
  84.  
  85. restartMinConnections= minConnections;
  86. restartMaxConnections= maxConnections;
  87. restartNumberOfStudents= numberOfStudents;
  88. restartSquareSize= squareSize;
  89.  
  90. tileSize = (double)squareSize/(double)(numberOfStudents+1);
  91. rnd = new Random(seed);
  92.  
  93. createStudents(numberOfStudents);
  94. randomlyInterconnectStudents(minConnections, maxConnections);
  95. giveEachStudentColors();
  96. setupWindow();
  97. plotGraphicalRepresentation();
  98.  
  99. }
  100.  
  101. public void createStudents(int numberOfStudents) {
  102. arrayOfStudents = new Student[numberOfStudents];
  103. for (int i=0; i<numberOfStudents; i++) {
  104. arrayOfStudents[i] = new Student();
  105. }
  106. }
  107.  
  108. public void randomlyInterconnectStudents(int minConnections, int maxConnections){
  109. for (int i=0; i< numberOfStudents; i++) {
  110. int numberOfConnections = rnd.nextInt(maxConnections - (minConnections-1)) + minConnections;
  111. arrayOfStudents[i].arrayOfConnectedStudents = new int[numberOfConnections];
  112. }
  113. int flag;
  114. int studentToBeAdded;
  115. int studentsContained;
  116. for (int i=0; i<numberOfStudents; i++) {
  117. studentsContained = arrayOfStudents[i].arrayOfConnectedStudents.length;
  118. arrayOfStudents[i].arrayOfConnectedStudents = new int[studentsContained];
  119. for(int x=0; x<studentsContained; x++) {
  120. // lazy way of making sure no same students are contained in the array
  121. do {
  122. studentToBeAdded= rnd.nextInt(numberOfStudents)+1;
  123. flag = 0;
  124. for(int o=0; o<studentsContained; o++) {
  125. if (arrayOfStudents[i].arrayOfConnectedStudents[o] == studentToBeAdded) {flag = 1;}
  126. }
  127. }
  128. while (flag ==1);
  129. arrayOfStudents[i].arrayOfConnectedStudents[x]=studentToBeAdded;
  130. arrayOfStudents[studentToBeAdded-1].arrayListFromConnections.add(i+1);
  131. }
  132. }
  133. }
  134.  
  135. public void giveEachStudentColors() {
  136. for (int i=0; i<numberOfStudents; i++) {
  137. int studentsContained = arrayOfStudents[i].arrayOfConnectedStudents.length;
  138. int studentsFromConnections = arrayOfStudents[i].arrayListFromConnections.size();
  139. arrayOfStudents[i].colorOfStudent = BigInteger.valueOf(1).shiftLeft(i);
  140. for (int x=0; x<studentsContained; x++) {
  141. arrayOfStudents[i].colorOfStudent = arrayOfStudents[i].colorOfStudent.or(BigInteger.valueOf(1).shiftLeft(arrayOfStudents[i].arrayOfConnectedStudents[x]-1));
  142. }
  143. for (int x=0; x<studentsFromConnections; x++) {
  144. arrayOfStudents[i].colorOfStudent = arrayOfStudents[i].colorOfStudent.or(BigInteger.valueOf(1).shiftLeft(arrayOfStudents[i].arrayListFromConnections.get(x)-1));
  145. }
  146. // System.out.println(String.format("%"+Integer.toString(numberOfStudents)+"s", arrayOfStudents[i].colorOfStudent.toString(2)).replace(' ', '0'));
  147. String str = String.format("%"+Integer.toString(numberOfStudents)+"s", arrayOfStudents[i].colorOfStudent.toString(2)).replace(' ', '0');
  148. arrayOfStudents[i].colorString = str;
  149. arrayOfStudents[i].arrayColorOfStudent = new int[numberOfStudents];
  150. for (int x=0; x<numberOfStudents; x++) {
  151. arrayOfStudents[i].arrayColorOfStudent[x] = Character.getNumericValue(str.charAt(numberOfStudents-x-1));
  152. }
  153. }
  154. }
  155.  
  156. public void setupWindow() {
  157. this.setName("cliqueGame");
  158. jPanel = new JPanel();
  159.  
  160. jPanel.setLayout(null);
  161. jPanel.setBackground(Color.black);
  162.  
  163. checkBox = new JCheckBox("interlock Columns/Rows",true);
  164. checkBox.addActionListener(this);
  165. checkBox.setActionCommand("lock");
  166. checkBox.setBounds(0,(int)(squareSize+2),170,border);
  167. jPanel.add(checkBox);
  168.  
  169. minTextField = new JTextField(Integer.toString(restartMinConnections));
  170. maxTextField = new JTextField(Integer.toString(restartMaxConnections));
  171. studentsTextField = new JTextField(Integer.toString(restartNumberOfStudents));
  172. squareSizeTextField = new JTextField(Integer.toString(restartSquareSize));
  173.  
  174. minTextField.setActionCommand("miT");
  175. maxTextField.setActionCommand("maT");
  176. studentsTextField.setActionCommand("studentsT");
  177. squareSizeTextField.setActionCommand("squareT");
  178.  
  179. minTextField.addActionListener(this);
  180. maxTextField.addActionListener(this);
  181. studentsTextField.addActionListener(this);
  182. squareSizeTextField.addActionListener(this);
  183.  
  184. minTextField.setBounds((int)450+2,(int)(squareSize+2),(squareSize-450)/4,border);
  185. maxTextField.setBounds((int)450+((squareSize-450)/4)*1+2,(int)(squareSize+2),(squareSize-450)/4,border);
  186. studentsTextField.setBounds((int)450+((squareSize-450)/4)*2+2,(int)(squareSize+2),(squareSize-450)/4,border);
  187. squareSizeTextField.setBounds((int)450+((squareSize-450)/4)*3+2,(int)(squareSize+2),(squareSize-450)/4,border);
  188.  
  189. MyButton printMatrix = new MyButton(Color.green,Color.green,tileSize);
  190. printMatrix.setBounds((int)(tileSize*numberOfStudents)+1,0,(int)tileSize-3,(int)tileSize-3);
  191. printMatrix.addActionListener(this);
  192. printMatrix.setActionCommand("print");
  193.  
  194. jPanel.add(printMatrix);
  195.  
  196. jPanel.add(minTextField);
  197. jPanel.add(maxTextField);
  198. jPanel.add(studentsTextField);
  199. jPanel.add(squareSizeTextField);
  200.  
  201. textField = new JTextField("enter seed here+enter: "+Long.toString(seed));
  202. textField.setActionCommand("enter");
  203. textField. setBounds(172,(int)(squareSize+2),450-172,border);;
  204.  
  205. textField.addActionListener(this);
  206. jPanel.add(textField);
  207.  
  208. this.add(jPanel);
  209.  
  210. MyGlassPane glassPane = new MyGlassPane();
  211.  
  212. this.setGlassPane(glassPane);
  213. glassPane.setVisible(true);
  214.  
  215. this.setResizable(false);
  216. this.setSize((int)((tileSize)*(numberOfStudents+1)+5),(int)(tileSize*(numberOfStudents+1)+border+20));
  217. this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  218. this.setVisible(true);// try {Thread.sleep(1000);}catch (Exception e){}
  219. }
  220.  
  221. public void plotGraphicalRepresentation(){
  222. jbX = new JustButton[numberOfStudents];
  223. jbY = new JustButton[numberOfStudents];
  224. myButton = new MyButton[numberOfStudents][numberOfStudents];
  225.  
  226. for(int i=0; i<numberOfStudents;i++) {
  227. jbX[numberOfStudents-i-1] = new JustButton(Integer.toString(numberOfStudents-i-1));
  228. jbY[i]= new JustButton(Integer.toString(i));
  229. jbX[numberOfStudents-i-1].setBorder(null);
  230. jbY[i].setBorder(null);
  231. jbX[numberOfStudents-i-1].setFont(new Font("Arial", Font.PLAIN, (int)(tileSize-tileSize/5)));
  232. jbY[i].setFont(new Font("Arial", Font.PLAIN, (int)(tileSize-tileSize/5)));
  233. jbX[numberOfStudents-i-1].setBounds((int)(i*tileSize),0,(int)tileSize-1,(int)tileSize-1);
  234. jbY[i].setBounds((int)(tileSize*numberOfStudents),(int)(tileSize+i*tileSize),(int)tileSize-1,(int)tileSize-1);
  235. jPanel.add(jbX[numberOfStudents-i-1]);
  236. jPanel.add(jbY[i]);
  237. jbX[numberOfStudents-i-1].addActionListener(this);
  238. jbX[numberOfStudents-i-1].setActionCommand(Integer.toString(numberOfStudents-i-1)+"x");
  239. jbY[i].addActionListener(this);
  240. jbY[i].setActionCommand(Integer.toString(i)+"y");
  241. }
  242.  
  243. for (int i=0; i<numberOfStudents; i++) {
  244. for (int x=0; x<numberOfStudents; x++) {
  245. if (arrayOfStudents[i].colorString.charAt(x) == '1') {
  246. myButton[numberOfStudents-x-1][i] = new MyButton(setColor,setColor,tileSize);
  247. jPanel.add(myButton[numberOfStudents-x-1][i]);
  248. myButton[numberOfStudents-x-1][i].setBounds((int)(x*tileSize+1),(int)(tileSize+i*tileSize+1),(int)tileSize-3,(int)tileSize-3);
  249. myButton[numberOfStudents-x-1][i].addActionListener(this);
  250. myButton[numberOfStudents-x-1][i].setActionCommand("myButton");
  251. myButton[numberOfStudents-x-1][i].bit = 1;
  252. myButton[numberOfStudents-x-1][i].posX=numberOfStudents-x-1;
  253. myButton[numberOfStudents-x-1][i].posY=i;
  254.  
  255. } else {
  256. myButton[numberOfStudents-x-1][i] = new MyButton(unsetColor, unsetColor,tileSize);
  257. jPanel.add( myButton[numberOfStudents-x-1][i]);
  258. myButton[numberOfStudents-x-1][i].setBounds((int)(x*tileSize+1),(int)(tileSize+i*tileSize+1),(int)tileSize-3,(int)tileSize-3);
  259. myButton[numberOfStudents-x-1][i].addActionListener(this);
  260. myButton[numberOfStudents-x-1][i].setActionCommand("myButton");
  261. myButton[numberOfStudents-x-1][i].posX=numberOfStudents-x-1;
  262. myButton[numberOfStudents-x-1][i].posY=i;
  263.  
  264. }
  265. }
  266. }
  267.  
  268. jPanel.repaint();
  269. repaint();
  270. }
  271.  
  272. public void ensureConsistency() {
  273. restartNumberOfStudents = Integer.parseInt(studentsTextField.getText());
  274. restartMaxConnections = Integer.parseInt(maxTextField.getText());
  275. restartMinConnections = Integer.parseInt(minTextField.getText());
  276.  
  277. if (restartMaxConnections > restartNumberOfStudents) {
  278. restartMaxConnections = restartNumberOfStudents;
  279. maxTextField.setText(Integer.toString(restartMaxConnections));
  280. }
  281.  
  282. if (restartMinConnections > restartMaxConnections) {
  283. restartMinConnections = restartMaxConnections;
  284. minTextField.setText(Integer.toString(restartMaxConnections));
  285. }
  286. }
  287.  
  288. MyButton highButton;
  289. int counter = 0;
  290. int highlightX = 0;
  291. int highlightY = 0;
  292.  
  293. public void actionPerformed(ActionEvent e) {
  294.  
  295. String str=e.getActionCommand();
  296.  
  297.  
  298. if (str.equals("myButton")){
  299.  
  300.  
  301. MyButton tempButton = (MyButton)e.getSource();
  302.  
  303. int x = tempButton.posX;
  304. int y = tempButton.posY;
  305.  
  306. if (tempButton.highlight == 0 && counter == 0) {
  307.  
  308. highButton = tempButton;
  309. tempButton.switchHighlight();
  310. highlightX = x;
  311. highlightY = y;
  312. counter++;
  313.  
  314. } else if (tempButton.highlight == 1 && counter == 1) {
  315.  
  316. tempButton.switchHighlight();
  317. counter--;
  318.  
  319.  
  320. } else if (tempButton.highlight == 0 && counter ==1) {
  321.  
  322. counter--;
  323. highButton.switchHighlight();
  324.  
  325. if (highlightX < x ^ highlightX > x) {
  326. if (lock==true) {
  327. switchColumns(highlightX,x);
  328. switchRows(highlightX,x);
  329. } else {
  330. switchColumns(highlightX,x);
  331. }
  332. }
  333. if (highlightY < y ^ highlightY > y) {
  334.  
  335. if (lock==true) {
  336. switchColumns(highlightY,y);
  337. switchRows(highlightY,y);
  338. } else {
  339. switchRows(highlightY,y);
  340. }
  341. }
  342. }
  343. return;
  344. }
  345.  
  346.  
  347. if (str.equals("print")){
  348. for (int y=0; y< numberOfStudents;y++){
  349. System.out.println();
  350. for (int x=0; x< numberOfStudents;x++){
  351.  
  352. System.out.print(myButton[x][y].bit);
  353. }
  354. }
  355. return;
  356. }
  357.  
  358. if (str.equals("miT")){
  359. String s = minTextField.getText().replaceAll("[^\\d]", "");
  360. minTextField.setText(s);
  361. restartMinConnections = Integer.parseInt(s);
  362. ensureConsistency();
  363. return;
  364. }
  365.  
  366. if (str.equals("maT")){
  367. String s = maxTextField.getText().replaceAll("[^\\d]", "");
  368. maxTextField.setText(s);
  369. restartMaxConnections = Integer.parseInt(s);
  370. ensureConsistency();
  371. return;
  372. }
  373.  
  374. if (str.equals("studentsT")){
  375. String s = studentsTextField.getText().replaceAll("[^\\d]", "");
  376. studentsTextField.setText(s);
  377. restartNumberOfStudents = Integer.parseInt(s);
  378. ensureConsistency();
  379. return;
  380. }
  381.  
  382. if (str.equals("squareT")){
  383. String s = squareSizeTextField.getText().replaceAll("[^\\d]", "");
  384. squareSizeTextField.setText(s);
  385. restartSquareSize = Integer.parseInt(s);
  386. ensureConsistency();
  387. return;
  388. }
  389.  
  390.  
  391. if(str.equals("lock")) {
  392. if (lock==true){
  393. lock = false;
  394. return;
  395. } else {
  396. lock = true; }
  397. return;
  398. }
  399.  
  400. if (str.equals("enter")){
  401. String s = textField.getText().replaceAll("[^\\d-]", "");
  402. int sl = s.length();
  403. if (s.length() == 0){seed = rnd.nextLong();restart();return;}
  404.  
  405. if (s.charAt(0)=='-' && sl < 2) {seed = rnd.nextLong();restart();return;}
  406.  
  407. s = s.substring(0,1)+s.substring(1,sl).replace("-", "");
  408. sl = s.length();
  409. BigInteger ba = new BigInteger(s);
  410. BigInteger bb = new BigInteger(Long.toString((long)Math.pow(2,63)));
  411. BigInteger bc = new BigInteger(Long.toString(-(long)Math.pow(2,63)-1));
  412. if ((ba.compareTo(bb))==1) {
  413. textField.setText(Long.toString((long)Math.pow(2,63)));
  414. } else if (ba.compareTo(bc) ==-1) {
  415.  
  416. textField.setText(Long.toString(-(long)(Math.pow(2,63))));
  417. return;
  418. } else {
  419. if (sl >= 20 && (s.charAt(0) != '-')) {
  420. sl = 19;
  421. } else if (sl >= 20 && (s.charAt(0) == '-')){
  422. sl = 20;
  423. }
  424. seed = Long.parseLong(s.substring(0,sl));
  425. textField.setText(Long.toString(seed));
  426. restart();
  427. }
  428. }
  429.  
  430. int m,n;
  431.  
  432. if(str.contains("x")){
  433. int a = Integer.parseInt(str.substring(0,str.length()-1));
  434. if (toBeSwitchedX.contains(a)){
  435. toBeSwitchedX.remove((Integer)a);
  436. jbX[a].unsetBackground();
  437. return;
  438. } else {
  439. toBeSwitchedX.add(a);
  440. jbX[a].setBackground();
  441. if(toBeSwitchedX.size()==2) {
  442. jbX[toBeSwitchedX.get(0)].unsetBackground();
  443. jbX[toBeSwitchedX.get(1)].unsetBackground();
  444. n = toBeSwitchedX.get(0);
  445. m =toBeSwitchedX.get(1);
  446. if (lock == true) {
  447. switchColumns(m,n);
  448. switchRows(m,n);
  449. } else {
  450. switchColumns(m,n);
  451. }
  452.  
  453. }
  454. }
  455. return;
  456. }
  457.  
  458. if(str.contains("y")){
  459. int a = Integer.parseInt(str.substring(0,str.length()-1));
  460. if (toBeSwitchedY.contains(a)){
  461. toBeSwitchedY.remove((Integer)a);
  462. jbY[a].unsetBackground();
  463. return;
  464. } else {
  465. toBeSwitchedY.add(a);
  466. jbY[a].setBackground();
  467. if(toBeSwitchedY.size()==2) {
  468. jbY[toBeSwitchedY.get(0)].unsetBackground();
  469. jbY[toBeSwitchedY.get(1)].unsetBackground();
  470. m = toBeSwitchedY.get(0);
  471. n =toBeSwitchedY.get(1);
  472. if (lock == true) {
  473.  
  474. switchColumns(m,n);
  475. switchRows(m,n);
  476. } else {
  477. switchRows(m,n);
  478. }
  479.  
  480. }
  481. }
  482. return;
  483. }
  484. }
  485.  
  486. public void switchColumns(int a, int b){
  487. for(int i=0; i<numberOfStudents; i++) {
  488. rectangleB = myButton[b][i].getBounds();
  489. rectangleA = myButton[a][i].getBounds();
  490. myButton[a][i].setBounds(rectangleB);
  491. myButton[b][i].setBounds(rectangleA);
  492. }
  493. toBeSwitchedX.clear();
  494. rectangleB = jbX[b].getBounds();
  495. rectangleA = jbX[a].getBounds();
  496. jbX[a].setBounds(rectangleB);
  497. jbX[b].setBounds(rectangleA);
  498. }
  499.  
  500. public void switchRows(int a, int b) {
  501. for(int i=0; i<numberOfStudents; i++) {
  502. rectangleB = myButton[i][b].getBounds();
  503. rectangleA = myButton[i][a].getBounds();
  504. myButton[i][a].setBounds(rectangleB);
  505. myButton[i][b].setBounds(rectangleA);
  506. }
  507. toBeSwitchedY.clear();
  508. rectangleB = jbY[b].getBounds();
  509. rectangleA = jbY[a].getBounds();
  510. jbY[a].setBounds(rectangleB);
  511. jbY[b].setBounds(rectangleA);
  512. }
  513.  
  514.  
  515. class MyGlassPane extends JComponent{
  516. AlphaComposite composite;
  517. Graphics2D g2d;
  518. float alpha;
  519. int type;
  520. int i=1;
  521. int o;
  522.  
  523. BasicStroke stroke;
  524.  
  525. MyGlassPane() {
  526. setVisible(true);
  527. stroke = new BasicStroke(3);
  528. }
  529.  
  530. public void paintComponent(Graphics g){
  531. g2d = (Graphics2D) g.create();
  532. alpha = 0.6f;
  533. type = AlphaComposite.SRC_OVER;
  534. composite = AlphaComposite.getInstance(type, alpha);
  535. g2d.setComposite(composite);
  536. g2d.setStroke(stroke);
  537. g2d.setColor(Color.black);
  538. g2d.drawLine((int)(squareSize-3-tileSize),(int)tileSize,0,(int)(squareSize-3));;
  539. if (i == 1) {
  540. o = counter;
  541. i = 0;
  542. }
  543. if (o!=counter) {
  544. i=1;
  545. this.repaint();
  546. }
  547. if (counter == 1) {
  548. g2d.setColor(Color.white);
  549. g2d.fillRect(highButton.getX(), 0,(int)tileSize,(int)(highButton.getY()));
  550. g2d.fillRect((int)(highButton.getX()+tileSize),(int)(highButton.getY()),(int)(squareSize-tileSize),(int)tileSize);
  551. }
  552. }
  553. }
  554. }
  555.  
  556.  
  557. class Student {
  558.  
  559.  
  560. BigInteger colorOfStudent;
  561. int[] arrayColorOfStudent;
  562. int[] arrayOfConnectedStudents;
  563. ArrayList<Integer> arrayListFromConnections = new ArrayList<Integer>();
  564. String colorString;
  565. }
  566.  
  567.  
  568. class MyButton extends JButton {
  569.  
  570.  
  571. double tileSize;
  572. Color backColor;
  573. Color color;
  574. String string;
  575. int bit;
  576. int posX;
  577. int posY;
  578. int highlight;
  579.  
  580. MyButton(String str) {
  581. str = string;
  582. setText(str);
  583. }
  584.  
  585. public MyButton(Color c, Color b,double size) {
  586. setBorder(null);
  587. setBackground(b);
  588. color = b;
  589. tileSize = size;
  590. }
  591.  
  592.  
  593. public void switchHighlight() {
  594.  
  595. if (highlight == 0) {
  596. highlight = 1;
  597. if (bit==1){
  598. setColor(Color.magenta);
  599. }else {
  600. setColor(Color.cyan);
  601. }
  602. } else {
  603. highlight = 0;
  604. if (bit == 1) {
  605. setColor(Color.red);}
  606. else {
  607. setColor(new Color(144,144,144));
  608. }
  609. }
  610. }
  611.  
  612. public void setColor(Color c){
  613. color = c;
  614. setBackground(c);
  615. setForeground(Color.white);
  616. }
  617.  
  618. public Color getColor(){
  619. return color;
  620. }
  621. }
  622.  
  623.  
  624. class JustButton extends JButton {
  625.  
  626.  
  627. double tileSize;
  628. Color backColor;
  629. Color color = Color.red;
  630. String string;
  631. Color col = new Color(188,188,188);
  632.  
  633. public JustButton(String str) {
  634. setBorder(null);
  635. setBackground(col);
  636. string = str;
  637. setText(string);
  638. }
  639.  
  640. public void setBackground() {
  641. setBackground(Color.red);
  642. }
  643.  
  644. public void unsetBackground() {
  645. setBackground(col);
  646. }
  647. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement