package boondock.holdem.Gui; import boondock.holdem.Player.OtherPlayer; import boondock.holdem.Network.*; import boondock.holdem.Sound.waveObj; import boondock.holdem.Jars.JarExtractor; import java.io.*; import java.net.*; import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.border.*; import java.util.*; public class howToUse extends JFrame implements ActionListener, WindowListener{ public final String SPACEBUFFER = " "; public JSplitPane splitPane, splitPane2; //the text panes are in splitPane, and then splitPane is put into splitPane2 with the board pane private JTextArea messageArea;//textbox where the text from everyone will be displayed private JTextField inputArea;//textbox where the text from everyone will be displayed private JButton sendButton;//button to send the text from users inputArea static JFrame frame = new JFrame("How To Use Our Game"); static String inputAddress = "localhost"; static Graphics g; int currentPlayer = 0, soundID = 0; static waveObj song = new waveObj(); boolean isMyTurn = false; boolean notifyMe = false; boolean doingBlinds; private JButton rulesButton; private static String userName; // userName to add to outgoing messages // MessageManager for communicating with server private MessageManager messageManager; // MessageListener for receiving incoming messages public MessageListener messageListener; ImageIcon foldDownIM = new ImageIcon("images/jpegS/Fold_Pressed.jpg"); ImageIcon foldOverIM = new ImageIcon("images/jpegS/Fold_Hover.jpg"); ImageIcon foldUpIM = new ImageIcon("images/jpegS/Fold_Normal.jpg"); JLabel foldLabel = new JLabel(foldUpIM,JLabel.CENTER); ImageIcon raiseDownIM = new ImageIcon("images/jpegS/Raise_Pressed.jpg"); ImageIcon raiseOverIM = new ImageIcon("images/jpegS/Raise_Hover.jpg"); ImageIcon raiseUpIM = new ImageIcon("images/jpegS/Raise_Normal.jpg"); JLabel raiseLabel = new JLabel(raiseUpIM,JLabel.CENTER); ImageIcon allinDownIM = new ImageIcon("images/jpegS/AllIn_Pressed.jpg"); ImageIcon allinOverIM = new ImageIcon("images/jpegS/AllIn_Hover.jpg"); ImageIcon allinUpIM = new ImageIcon("images/jpegS/AllIn_Normal.jpg"); JLabel allinLabel = new JLabel(allinUpIM,JLabel.CENTER); ImageIcon callDownIM = new ImageIcon("images/jpegS/Call_Pressed.jpg"); ImageIcon callOverIM = new ImageIcon("images/jpegS/Call_Hover.jpg"); ImageIcon callUpIM = new ImageIcon("images/jpegS/Call_Normal.jpg"); JLabel callLabel = new JLabel(callUpIM,JLabel.CENTER); ImageIcon checkDownIM = new ImageIcon("images/jpegS/Check_Pressed.jpg"); ImageIcon checkOverIM = new ImageIcon("images/jpegS/Check_Hover.jpg"); ImageIcon checkUpIM = new ImageIcon("images/jpegS/Check_Normal.jpg"); JLabel checkLabel = new JLabel(checkUpIM,JLabel.CENTER); private JButton refreshButton, exitButton, startGameButton; private JTextField amountAlreadyBet_Field, potSize_Field, amountNeededToCall_Field, raiseAmount_Field, myChipAmount_Field; private JLabel amountInLabel, potSizeLabel, amountCallLabel, amountRaiseLabel, myChipAmountLabel; private JLabel P1info = new JLabel(SPACEBUFFER + "Player (1)" + SPACEBUFFER), P2info = new JLabel("Player (2)" + SPACEBUFFER), P3info = new JLabel("Player (3)" + SPACEBUFFER), P4info = new JLabel("Player (4)"), P5info = new JLabel("Player (5)" + SPACEBUFFER), P6info = new JLabel("Player (6)" + SPACEBUFFER), P7info = new JLabel(SPACEBUFFER + "Player (7)" + SPACEBUFFER), P8info = new JLabel("Player (8)"); private String amountAlreadyBet = "2000", potSize = "9000", amountNeededToCall = "1000", raiseAmount = "", myChipAmount = "8000"; private static OtherPlayer allPlayers[] = new OtherPlayer[8]; private static boolean showFlop = false, showTurn = false, showRiver = false; private static String communityCards[] = new String[5]; private static int dealerButton = 0; private String soundIDSong[] = {"sounds/UserTurn.wav", "sounds/ButtonClick.wav", "sounds/ChipsBet.wav", "sounds/ChipsBet.wav", "sounds/FoldCards.wav", "sounds/DealCard.wav", "sounds/NewHand.wav", "sounds/Flop.wav"}; public void windowOpened(WindowEvent e){} public void windowIconified(WindowEvent e) {} public void windowDeiconified(WindowEvent e) {} public void windowActivated(WindowEvent e) {} public void windowDeactivated(WindowEvent e) {} public void windowGainedFocus(WindowEvent e) {} public void windowLostFocus(WindowEvent e) {} public void windowStateChanged(WindowEvent e) {} public void windowClosed(WindowEvent e) {} public void windowClosing(WindowEvent e) {} public howToUse() { frame.addWindowListener(this); messageArea = new JTextArea(); messageArea.setEditable(false); messageArea.setWrapStyleWord(true); messageArea.setLineWrap(true); messageArea.append("Click a button to see what it does in the game"); JScrollPane messageAreaScrollPane = new JScrollPane(messageArea); inputArea = new JTextField(); inputArea.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent event ) { } } ); //end of ActionListener setup for sendButton JScrollPane inputAreaScrollPane = new JScrollPane(inputArea); //Provide minimum sizes for the two components in the split pane. messageAreaScrollPane.setMinimumSize(new Dimension(800, 110)); messageAreaScrollPane.setPreferredSize(new Dimension(800, 110)); inputAreaScrollPane.setMinimumSize(new Dimension(700, 40)); //from 800 to 700 inputAreaScrollPane.setPreferredSize(new Dimension(800, 40)); //create a message panel for the sendbox/sendbutton JPanel inputAreaPanel = new JPanel(); inputAreaPanel.setLayout(new BoxLayout(inputAreaPanel, BoxLayout.X_AXIS)); inputAreaPanel.setMinimumSize(new Dimension(800, 40)); inputAreaPanel.setPreferredSize(new Dimension(800, 40)); inputAreaPanel.add(inputAreaScrollPane); inputAreaPanel.setBackground(Color.white); rulesButton = new JButton("Help"); rulesButton.addActionListener( new ActionListener(){ public void actionPerformed(ActionEvent e){ JOptionPane.showMessageDialog(frame,"This button displays the rules of the game."); } } );//end of action listener for rules button //add the 'send' button // create Icon for sendButton Icon sendIcon = new ImageIcon( "images/Send_Icon.jpg" ); sendButton = new JButton("Send", sendIcon); inputAreaPanel.add(sendButton); sendButton.addActionListener( new ActionListener() { // send new message when user activates sendButton public void actionPerformed( ActionEvent event ){ JOptionPane.showMessageDialog(frame,"Click here to send the message you have typed to other players or observers."); } } ); //end of ActionListener setup for sendButton //AutoDisconnect on CloseWindow addWindowListener ( new WindowAdapter () { // disconnect from server and exit application public void windowClosing ( WindowEvent event ) { } } ); //end of AutoDisconnect on CloseWindow code. //add the text components to the splitpane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, messageAreaScrollPane, inputAreaPanel); splitPane.setOneTouchExpandable(true); //Provide a preferred size for the split pane. splitPane.setPreferredSize(new Dimension(800, 150)); //create the panel which holds the stuff in the main game window //JPanel mainGamePanel = new JPanel(); JPanel Center_mainGamePanel = new JPanel(); Center_mainGamePanel.setLayout(new BoxLayout(Center_mainGamePanel, BoxLayout.Y_AXIS)); //Center_mainGamePanel.setBackground(Color.white); ////mainGamePanel.setMinimumSize( new Dimension(800,200) ); //mainGamePanel.setPreferredSize( new Dimension(775,450) ); //setup player panels JPanel upperPlayers = new JPanel(); upperPlayers.setLayout(new BoxLayout(upperPlayers, BoxLayout.X_AXIS)); //upperPlayers.setMinimumSize( new Dimension(600,10) ); upperPlayers.setBackground(Color.white); upperPlayers.add(P1info); upperPlayers.add(P2info); upperPlayers.add(P3info); JPanel rightPlayer = new JPanel(); rightPlayer.setLayout(new BoxLayout(rightPlayer, BoxLayout.Y_AXIS)); rightPlayer.add(P4info); rightPlayer.setBackground(Color.white); JPanel lowerPlayers = new JPanel(); lowerPlayers.setLayout(new BoxLayout(lowerPlayers, BoxLayout.X_AXIS)); //lowerPlayers.setMinimumSize( new Dimension(600,10) ); lowerPlayers.add(P7info); lowerPlayers.add(P6info); lowerPlayers.add(P5info); lowerPlayers.setBackground(Color.white); JPanel leftPlayer = new JPanel(); leftPlayer.setLayout(new BoxLayout(leftPlayer, BoxLayout.Y_AXIS)); leftPlayer.add(P8info); leftPlayer.setBackground(Color.white); //add background JLabel imageBackground = new JLabel(new ImageIcon("images/TablewRealPeople_800x350dpi.jpg")); Container content = getContentPane(); content.setLayout(new FlowLayout() ); content.setBackground(Color.white); content.add(imageBackground); Center_mainGamePanel.add(upperPlayers); Center_mainGamePanel.add(content); Center_mainGamePanel.add(lowerPlayers); Center_mainGamePanel.setBackground(Color.white); JPanel AllPlayers_mainGamePanel = new JPanel(); AllPlayers_mainGamePanel.setLayout(new BoxLayout(AllPlayers_mainGamePanel, BoxLayout.X_AXIS)); AllPlayers_mainGamePanel.add(leftPlayer); AllPlayers_mainGamePanel.add(Center_mainGamePanel); AllPlayers_mainGamePanel.add(rightPlayer); AllPlayers_mainGamePanel.setBackground(Color.white); JPanel mainGamePanel = new JPanel(); mainGamePanel.setLayout(new BoxLayout(mainGamePanel, BoxLayout.Y_AXIS)); mainGamePanel.setMinimumSize( new Dimension(800,200) ); mainGamePanel.add(AllPlayers_mainGamePanel); mainGamePanel.setBackground(Color.white); Icon refresh = new ImageIcon("images/Observe_Icon.jpg"); Icon exit = new ImageIcon("images/Exit_Icon.jpg"); Icon start = new ImageIcon("images/Start_Icon.jpg"); //setup the buttons refreshButton = new JButton("Refresh",refresh); refreshButton.addActionListener(this); exitButton = new JButton("Exit", exit); exitButton.addActionListener(this); startGameButton = new JButton("",start); startGameButton.addActionListener(this); //setup the text fields amountAlreadyBet_Field = new JTextField(10); amountAlreadyBet_Field.setEditable(false); potSize_Field = new JTextField(10); potSize_Field.setEditable(false); amountNeededToCall_Field = new JTextField(10); amountNeededToCall_Field.setEditable(false); raiseAmount_Field = new JTextField(10); raiseAmount_Field.setEditable(true); myChipAmount_Field = new JTextField(10); myChipAmount_Field.setEditable(false); //setup the labels amountInLabel = new JLabel("Bet So Far:"); potSizeLabel = new JLabel("Pot Size:"); amountCallLabel = new JLabel("Call Amount:"); amountRaiseLabel = new JLabel("Raise Amount:"); myChipAmountLabel = new JLabel("Your Chip Amount:"); //create minipanels JPanel foldPanel = new JPanel(); foldPanel.setBackground(Color.white); foldPanel.setLayout(new BoxLayout(foldPanel, BoxLayout.Y_AXIS)); foldPanel.add(amountInLabel); foldPanel.add(amountAlreadyBet_Field); JPanel customFold = new JPanel(); customFold.setBackground(Color.white); customFold.addMouseListener( new MouseAdapter() { public void mousePressed(MouseEvent event) {foldLabel.setIcon(foldDownIM);} public void mouseReleased(MouseEvent event) {foldLabel.setIcon(foldUpIM);} public void mouseExited(MouseEvent event) {foldLabel.setIcon(foldUpIM);} public void mouseEntered(MouseEvent event) {foldLabel.setIcon(foldOverIM);} public void mouseClicked(MouseEvent event) { song.play("sounds/FoldCards.wav"); JOptionPane.showMessageDialog(frame,"During game play, this button allows you to fold this hand."); } } ); customFold.add(foldLabel); foldPanel.add(customFold); JPanel checkPanel = new JPanel(); checkPanel.setBackground(Color.white); checkPanel.setLayout(new BoxLayout(checkPanel, BoxLayout.Y_AXIS)); checkPanel.add(potSizeLabel); checkPanel.add(potSize_Field); JPanel customCheck = new JPanel(); customCheck.setBackground(Color.white); customCheck.addMouseListener( new MouseAdapter() { public void mousePressed(MouseEvent event) {checkLabel.setIcon(checkDownIM);} public void mouseReleased(MouseEvent event) {checkLabel.setIcon(checkUpIM);} public void mouseExited(MouseEvent event) {checkLabel.setIcon(checkUpIM);} public void mouseEntered(MouseEvent event) {checkLabel.setIcon(checkOverIM);} public void mouseClicked(MouseEvent event) { song.play("sounds/ButtonClick.wav"); JOptionPane.showMessageDialog(frame,"During game play, this button allows you to check the bet."); } } ); customCheck.add(checkLabel); checkPanel.add(customCheck); JPanel callPanel = new JPanel(); callPanel.setBackground(Color.white); callPanel.setLayout(new BoxLayout(callPanel, BoxLayout.Y_AXIS)); callPanel.add(amountCallLabel); callPanel.add(amountNeededToCall_Field); JPanel customCall = new JPanel(); customCall.setBackground(Color.white); customCall.addMouseListener( new MouseAdapter() { public void mousePressed(MouseEvent event) {callLabel.setIcon(callDownIM);} public void mouseReleased(MouseEvent event) {callLabel.setIcon(callUpIM);} public void mouseExited(MouseEvent event) {callLabel.setIcon(callUpIM);} public void mouseEntered(MouseEvent event) {callLabel.setIcon(callOverIM);} public void mouseClicked(MouseEvent event) { song.play("sounds/ChipsBet.wav"); JOptionPane.showMessageDialog(frame,"During game play, this button allows you to call the bet."); } } ); customCall.add(callLabel); callPanel.add(customCall); JPanel raisePanel = new JPanel(); raisePanel.setBackground(Color.white); raisePanel.setLayout(new BoxLayout(raisePanel, BoxLayout.Y_AXIS)); raisePanel.add(amountRaiseLabel); raisePanel.add(raiseAmount_Field); JPanel customRaise = new JPanel(); customRaise.setBackground(Color.white); customRaise.addMouseListener( new MouseAdapter() { public void mousePressed(MouseEvent event) {raiseLabel.setIcon(raiseDownIM);} public void mouseReleased(MouseEvent event) {raiseLabel.setIcon(raiseUpIM);} public void mouseExited(MouseEvent event) {raiseLabel.setIcon(raiseUpIM);} public void mouseEntered(MouseEvent event) {raiseLabel.setIcon(raiseOverIM);} public void mouseClicked(MouseEvent event) { song.play("sounds/ChipsBet.wav"); JOptionPane.showMessageDialog(frame,"During game play, this button allows you to raise the bet."); } } ); customRaise.add(raiseLabel); raisePanel.add(customRaise); JPanel allInPanel = new JPanel(); allInPanel.setBackground(Color.white); allInPanel.setLayout(new BoxLayout(allInPanel, BoxLayout.Y_AXIS)); allInPanel.add(myChipAmountLabel); allInPanel.add(myChipAmount_Field); JPanel customAllIn = new JPanel(); customAllIn.setBackground(Color.white); customAllIn.addMouseListener( new MouseAdapter() { public void mousePressed(MouseEvent event) {allinLabel.setIcon(allinDownIM);} public void mouseReleased(MouseEvent event) {allinLabel.setIcon(allinUpIM);} public void mouseExited(MouseEvent event) {allinLabel.setIcon(allinUpIM);} public void mouseEntered(MouseEvent event) {allinLabel.setIcon(allinOverIM);} public void mouseClicked(MouseEvent event) { song.play("sounds/ChipsBet.wav"); JOptionPane.showMessageDialog(frame,"During game play, this button allows you to put all your chips in the pot."); } } ); customAllIn.add(allinLabel); allInPanel.add(customAllIn); JPanel miscPanel1 = new JPanel(); miscPanel1.setBackground(Color.white); miscPanel1.setLayout(new BoxLayout(miscPanel1, BoxLayout.Y_AXIS)); JPanel SGBPanel = new JPanel(); SGBPanel.setBackground(Color.white); SGBPanel.setMinimumSize( new Dimension(120,37) ); SGBPanel.setPreferredSize( new Dimension(120,37) ); SGBPanel.setMaximumSize( new Dimension(120,37) ); SGBPanel.add(startGameButton); JPanel RBPanel = new JPanel(); RBPanel.setBackground(Color.white); RBPanel.setMinimumSize( new Dimension(120,37) ); RBPanel.setPreferredSize( new Dimension(120,37) ); RBPanel.setMaximumSize( new Dimension(120,37) ); RBPanel.add(refreshButton); miscPanel1.add(SGBPanel); miscPanel1.add(RBPanel); miscPanel1.setMinimumSize( new Dimension(120,75) ); miscPanel1.setPreferredSize( new Dimension(120,75) ); miscPanel1.setMaximumSize( new Dimension(120,75) ); JPanel miscPanel2 = new JPanel(); miscPanel2.setBackground(Color.white); miscPanel2.setLayout(new BoxLayout(miscPanel2, BoxLayout.Y_AXIS)); JPanel rulesButtonPanel = new JPanel(); rulesButtonPanel.add(rulesButton); rulesButtonPanel.setBackground(Color.white); rulesButtonPanel.setMinimumSize( new Dimension(120,37) ); rulesButtonPanel.setPreferredSize( new Dimension(120,37) ); rulesButtonPanel.setMaximumSize( new Dimension(120,37) ); JPanel exitButtonPanel = new JPanel(); exitButtonPanel.add(exitButton); exitButtonPanel.setBackground(Color.white); exitButtonPanel.setMinimumSize( new Dimension(120,37) ); exitButtonPanel.setPreferredSize( new Dimension(120,37) ); exitButtonPanel.setMaximumSize( new Dimension(120,37) ); miscPanel2.add(exitButtonPanel); miscPanel2.add(rulesButtonPanel); miscPanel2.setMinimumSize( new Dimension(120,75) ); miscPanel2.setPreferredSize( new Dimension(120,75) ); miscPanel2.setMaximumSize( new Dimension(120,75) ); //setup the buttons panel JPanel buttonsPanel = new JPanel(); buttonsPanel.setBackground(Color.white); buttonsPanel.setLayout(new BoxLayout(buttonsPanel, BoxLayout.X_AXIS)); buttonsPanel.setMinimumSize(new Dimension(600, 75)); buttonsPanel.setPreferredSize(new Dimension(600, 75)); buttonsPanel.setMaximumSize(new Dimension(800, 75)); //add the buttons to the buttons panel buttonsPanel.add(foldPanel); buttonsPanel.add(checkPanel); buttonsPanel.add(callPanel); buttonsPanel.add(raisePanel); buttonsPanel.add(allInPanel); buttonsPanel.add(miscPanel1); buttonsPanel.add(miscPanel2); //add the buttonspanel to the main game panel (this puts all the buttons on the mainGamePanel) mainGamePanel.add(buttonsPanel); //put main panel into scrollPane JScrollPane mainGameScrollPane = new JScrollPane(mainGamePanel); mainGameScrollPane.setMinimumSize( new Dimension(800,450) ); mainGameScrollPane.setPreferredSize( new Dimension(800,450) ); //puts everything into splitPane2 which holds the entire game (this can be put into a panel later or something) splitPane2 = new JSplitPane(JSplitPane.VERTICAL_SPLIT, mainGameScrollPane, splitPane); splitPane2.setOneTouchExpandable(true); splitPane2.setDividerLocation(450); splitPane2.setPreferredSize(new Dimension(900, 625)); frame.getContentPane().add(splitPane2); frame.pack(); frame.setVisible(true); amountAlreadyBet_Field.setText(amountAlreadyBet); potSize_Field.setText(potSize); amountNeededToCall_Field.setText(amountNeededToCall); raiseAmount_Field.setText(raiseAmount); myChipAmount_Field.setText(myChipAmount); } //end of 'gui()' method public void actionPerformed (ActionEvent e) { if(e.getSource() == exitButton) { JOptionPane.showMessageDialog(frame,"If you click this. you will disconnect from the game and your session will end."); //messageManager.sendMessage( userName, "COMMAND:DISCONNECT"); //song.play("sounds/ButtonClick.wav"); } //exit if exit command clicked if(e.getSource() == startGameButton) { JOptionPane.showMessageDialog(frame,"If the game has not started, this button will start the game, else this will do nothing."); //song.play("sounds/ButtonClick.wav"); }//end of startgame event if(e.getSource() == refreshButton) { //song.play("sounds/ButtonClick.wav"); JOptionPane.showMessageDialog(frame,"This button redraws the board."); }//refresh the board } }