2-APL UPC project.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

bbfizp cec421cb 9a582182

+21 -64
+21 -64
code/2apl_platform/environments/cardtable/Table.java
··· 1 - package mabriscola; 2 - 1 + import javax.swing.*; 3 2 import java.awt.*; 4 - import javax.swing.*; 5 3 6 4 7 5 8 - public class Table{ 9 - //-----------CARD GAME STUFF--------------------- 10 - 11 - private Deck cardDeck = new Deck(); 12 - private Hand[] HandArray = new Hand[5]; 13 - private Hand myHand ; 14 - 15 - //----------GUI STUFF---------------------------- 6 + public class Table extends JFrame{ 16 7 17 8 public JLabel[][] PlayerCards = new JLabel[8][5]; 18 9 ··· 23 14 private JSplitPane HorizontalSplitPlane; 24 15 private JTextArea Info; 25 16 26 - public Table() { 17 + ImageIcon CardBack = new ImageIcon("cards/b.gif"); 18 + 19 + 20 + public Table( final Env env ){ 21 + super( "Blockworld" ); 22 + //----------GUI STUFF---------------------------- 23 + 24 + 27 25 28 26 CardDisplayPane = new JPanel(); 29 - 27 + 30 28 31 29 TablePane = new JLayeredPane(); 32 - 30 + 33 31 34 32 35 33 Point origin = new Point(50, 20); ··· 72 70 TablePane,GameInfo); 73 71 74 72 VerticalSplitPane.setPreferredSize(new Dimension(360,600)); 75 - 73 + 76 74 //AddPlayersGUI(); 77 75 addComponentsToPane(CardDisplayPane); 78 76 ··· 83 81 84 82 //Provide a preferred size for the split pane. 85 83 HorizontalSplitPlane.setPreferredSize(new Dimension(800,600)); 86 - } 84 + 85 + getContentPane().add(HorizontalSplitPlane); 87 86 87 + setVisible( true ); 88 + } 88 89 89 90 private JLabel createColoredLabel(String text, 90 91 Color color, ··· 100 101 return label; 101 102 } 102 103 104 + 105 + public JSplitPane getSplitPane() { 106 + return HorizontalSplitPlane; 107 + } 103 108 104 109 105 110 public static void addComponentsToPane(Container pane) { ··· 602 607 603 608 } 604 609 605 - 606 - /* Old add cards method 607 610 608 611 609 - public void AddPlayersGUI(){ 610 - for (int i=0; i<8; i++){ 611 - for (int j=0; j<5; j++){ 612 - PlayerCards[i][j] = new JLabel(); 613 - PlayerCards[i][j].setBackground(java.awt.Color.green); 614 - PlayerCards[i][j].setBounds(100 + i*56,12 + j*110,55,80); 615 - 616 - CardDisplayPane.add(PlayerCards[i][j]); 617 - Card c = cardDeck.dealCard(); 618 - PlayerCards[i][j].setIcon( c.getCardImage() ); 619 612 620 613 621 - } 622 - 623 - } 624 - 625 - 626 - } 627 - */ 628 614 629 - public JSplitPane getSplitPane() { 630 - return HorizontalSplitPlane; 631 - } 632 - 633 - private static void createAndShowGUI() { 634 615 635 - //Create and set up the window. 636 - JFrame frame = new JFrame("Briscola"); 637 - frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 638 - Table GameObject = new Table(); 639 - GameObject.getSplitPane().setBackground(java.awt.Color.green); 640 - frame.getContentPane().add(GameObject.getSplitPane()); 641 - frame.getContentPane().setBackground(java.awt.Color.green); 642 - 643 - //Display the window. 644 - frame.pack(); 645 - frame.setPreferredSize(new Dimension(800,600)); 646 - frame.setVisible(true); 647 - } 648 - 649 - public static void main(String[] args) { 650 - //Schedule a job for the event-dispatching thread: 651 - //creating and showing this application's GUI. 652 - createAndShowGUI(); 653 - 654 - javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() {} }); 655 - } 656 - 657 - 658 - }