Exemple #1
0
  void jbInit() throws Exception {
    titledBorder1 =
        new TitledBorder(
            BorderFactory.createLineBorder(new Color(153, 153, 153), 2), "Assembler messages");
    this.getContentPane().setLayout(borderLayout1);

    this.setIconifiable(true);
    this.setMaximizable(true);
    this.setResizable(true);

    this.setTitle("EDIT");

    splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
    splitPane.setDividerLocation(470);
    sourceArea.setFont(new java.awt.Font("Monospaced", 0, 12));
    controlPanel.setLayout(gridBagLayout1);
    controlPanel.setBorder(BorderFactory.createLoweredBevelBorder());
    positionPanel.setLayout(gridBagLayout2);
    fileLabel.setText("Source file:");
    fileText.setEditable(false);
    browseButton.setSelected(false);
    browseButton.setText("Browse ...");
    assembleButton.setEnabled(false);
    assembleButton.setText("Assemble file");
    saveButton.setEnabled(false);
    saveButton.setText("Save file");
    lineLabel.setText("Line:");
    lineText.setMinimumSize(new Dimension(50, 20));
    lineText.setPreferredSize(new Dimension(50, 20));
    lineText.setEditable(false);
    columnLabel.setText("Column:");
    columnText.setMinimumSize(new Dimension(41, 20));
    columnText.setPreferredSize(new Dimension(41, 20));
    columnText.setEditable(false);
    columnText.setText("");
    messageScrollPane.setBorder(titledBorder1);
    messageScrollPane.setMinimumSize(new Dimension(33, 61));
    messageScrollPane.setPreferredSize(new Dimension(60, 90));
    optionsButton.setEnabled(false);
    optionsButton.setText("Assembler options ...");
    messageScrollPane.getViewport().add(messageList, null);
    messageList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    this.getContentPane().add(splitPane, BorderLayout.CENTER);
    splitPane.add(textScrollPane, JSplitPane.TOP);
    splitPane.add(controlPanel, JSplitPane.BOTTOM);
    textScrollPane.getViewport().add(sourceArea, null);

    controlPanel.add(
        fileLabel,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 0, 0),
            0,
            0));
    controlPanel.add(
        fileText,
        new GridBagConstraints(
            1,
            0,
            3,
            1,
            1.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(5, 5, 0, 0),
            0,
            0));
    controlPanel.add(
        browseButton,
        new GridBagConstraints(
            4,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(5, 5, 0, 5),
            0,
            0));
    controlPanel.add(
        optionsButton,
        new GridBagConstraints(
            2,
            1,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 0, 0),
            0,
            0));
    controlPanel.add(
        assembleButton,
        new GridBagConstraints(
            3,
            1,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 0, 0),
            0,
            0));
    controlPanel.add(
        saveButton,
        new GridBagConstraints(
            4,
            1,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(5, 5, 0, 5),
            0,
            0));
    controlPanel.add(
        positionPanel,
        new GridBagConstraints(
            0,
            1,
            2,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(5, 5, 0, 0),
            0,
            0));
    positionPanel.add(
        lineLabel,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(0, 0, 0, 0),
            0,
            0));
    positionPanel.add(
        lineText,
        new GridBagConstraints(
            1,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(0, 5, 0, 0),
            0,
            0));
    positionPanel.add(
        columnLabel,
        new GridBagConstraints(
            2,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(0, 10, 0, 0),
            0,
            0));
    positionPanel.add(
        columnText,
        new GridBagConstraints(
            3,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(0, 5, 0, 0),
            0,
            0));
    controlPanel.add(
        messageScrollPane,
        new GridBagConstraints(
            0,
            2,
            5,
            1,
            1.0,
            1.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(5, 5, 5, 5),
            0,
            0));
  }
Exemple #2
0
 void jbInit() throws Exception {
   border1 = BorderFactory.createEmptyBorder(10, 10, 5, 5);
   panel1.setLayout(borderLayout1);
   jPanel1.setLayout(borderLayout2);
   jScrollPane1.getViewport().setBackground(Color.white);
   jPanel2.setLayout(gridBagLayout1);
   jLabel1.setText("Profile Name : ");
   nameTextField.setMinimumSize(new Dimension(4, 18));
   nameTextField.setPreferredSize(new Dimension(63, 18));
   jLabel2.setText("Profile Type : ");
   openButton.setMaximumSize(new Dimension(73, 24));
   openButton.setMinimumSize(new Dimension(73, 24));
   openButton.setPreferredSize(new Dimension(73, 24));
   openButton.setText("Open");
   openButton.addActionListener(
       new java.awt.event.ActionListener() {
         public void actionPerformed(ActionEvent e) {
           openButton_actionPerformed(e);
         }
       });
   cancelButton.setMaximumSize(new Dimension(73, 24));
   cancelButton.setMinimumSize(new Dimension(73, 24));
   cancelButton.setPreferredSize(new Dimension(73, 24));
   cancelButton.setMargin(new Insets(0, 5, 0, 5));
   cancelButton.setText("Cancel");
   cancelButton.addActionListener(
       new java.awt.event.ActionListener() {
         public void actionPerformed(ActionEvent e) {
           cancelButton_actionPerformed(e);
         }
       });
   profileList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
   profileList.addMouseListener(
       new java.awt.event.MouseAdapter() {
         public void mouseClicked(MouseEvent e) {
           profileList_mouseClicked(e);
         }
       });
   jPanel2.setBorder(border1);
   typeComboBox.setMaximumSize(new Dimension(32767, 18));
   typeComboBox.setMinimumSize(new Dimension(122, 18));
   typeComboBox.setPreferredSize(new Dimension(176, 18));
   getContentPane().add(panel1);
   panel1.add(jPanel1, BorderLayout.CENTER);
   jPanel1.add(jScrollPane1, BorderLayout.CENTER);
   panel1.add(jPanel2, BorderLayout.SOUTH);
   jPanel2.add(
       jLabel1,
       new GridBagConstraints(
           0,
           0,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.HORIZONTAL,
           new Insets(0, 0, 7, 0),
           0,
           0));
   jPanel2.add(
       nameTextField,
       new GridBagConstraints(
           1,
           0,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.HORIZONTAL,
           new Insets(0, 11, 7, 0),
           0,
           0));
   jPanel2.add(
       jLabel2,
       new GridBagConstraints(
           0,
           1,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.HORIZONTAL,
           new Insets(0, 0, 17, 0),
           0,
           0));
   jScrollPane1.getViewport().add(profileList, null);
   jPanel2.add(
       openButton,
       new GridBagConstraints(
           3,
           0,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.NONE,
           new Insets(0, 11, 2, 10),
           0,
           0));
   jPanel2.add(
       cancelButton,
       new GridBagConstraints(
           3,
           1,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.NONE,
           new Insets(0, 11, 9, 10),
           0,
           0));
   jPanel2.add(
       typeComboBox,
       new GridBagConstraints(
           1,
           1,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.HORIZONTAL,
           new Insets(0, 11, 17, 0),
           0,
           0));
 }
  private void jbInit() throws Exception {
    border1 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(165, 163, 151));
    border2 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(165, 163, 151));
    border3 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(178, 178, 178));
    titledBorder1 = new TitledBorder(border3, "Subject");
    border4 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(178, 178, 178));
    titledBorder2 = new TitledBorder(border4, "Message");
    border5 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(178, 178, 178));
    titledBorder3 = new TitledBorder(border5, "Subject");
    border6 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(165, 163, 151));
    titledBorder4 = new TitledBorder(border6, "Message");
    border7 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(165, 163, 151));
    titledBorder5 = new TitledBorder(border7, "Messages");
    border8 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(165, 163, 151));
    titledBorder6 = new TitledBorder(border8, "Online Users");
    border9 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(178, 178, 178));
    titledBorder7 = new TitledBorder(border9, "Send Message");
    this.getContentPane().setLayout(borderLayout1);
    jSplitPane1.setOrientation(JSplitPane.VERTICAL_SPLIT);
    jSplitPane1.setBorder(border1);
    jSplitPane1.setLastDividerLocation(250);
    jSplitPane1.setResizeWeight(1.0);
    jLabelServer.setRequestFocusEnabled(true);
    jLabelServer.setText("Server");
    jLabelUserId.setText("User Id");
    jTextFieldServer.setPreferredSize(new Dimension(75, 20));
    jTextFieldServer.setText("");
    jTextFieldUser.setPreferredSize(new Dimension(75, 20));
    jTextFieldUser.setText("");
    this.setDefaultCloseOperation(EXIT_ON_CLOSE);
    this.setJMenuBar(jMenuBarMain);
    this.setTitle("Message Client");
    jLabeltargetUser.setText("Target");
    jTextFieldTargetUser.setPreferredSize(new Dimension(75, 20));
    jTextFieldTargetUser.setText("");
    jPanelSendMessages.setBorder(border2);
    jPanelSendMessages.setMaximumSize(new Dimension(32767, 32767));
    jPanelSendMessages.setOpaque(false);
    jPanelSendMessages.setPreferredSize(new Dimension(96, 107));
    jPanelSendMessages.setRequestFocusEnabled(true);
    jPanelSendMessages.setToolTipText("");
    jPanelSendMessages.setLayout(verticalFlowLayout1);
    jTextFieldSendSubject.setBorder(titledBorder3);
    jTextFieldSendSubject.setText("");
    jTextFieldSendSubject.addKeyListener(new Client_jTextFieldSendSubject_keyAdapter(this));
    jSplitPane2.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
    jScrollPane1.setBorder(titledBorder5);
    jScrollPane2.setBorder(titledBorder6);
    jToggleButtonRegister.setText("Register");
    jToggleButtonRegister.addActionListener(new Client_jToggleButtonRegister_actionAdapter(this));
    jButtonMultiConnect.setText("Multi-Connect");
    jButtonMultiConnect.addActionListener(new Client_jButtonMultiConnect_actionAdapter(this));
    jListOnlineUsers.addMouseListener(new Client_jListOnlineUsers_mouseAdapter(this));
    jToggleButtonConnect.setText("Connect");
    jToggleButtonConnect.addActionListener(new Client_jToggleButtonConnect_actionAdapter(this));
    jTextPaneDisplayMessages.setEditable(false);
    jTextPaneDisplayMessages.addMouseListener(
        new Client_jTextPaneDisplayMessages_mouseAdapter(this));
    jTextFieldSendMessages.setBorder(titledBorder7);
    jTextFieldSendMessages.setToolTipText("");
    jTextFieldSendMessages.addKeyListener(new Client_jTextFieldSendMessages_keyAdapter(this));
    jButtonMessageStresser.setText("Msg Stresser");
    jButtonMessageStresser.addActionListener(
        new Client_jToggleButtonMessageStresser_actionAdapter(this));
    jMenuItemClearMessages.setText("Clear Messages");
    jMenuItemClearMessages.addActionListener(new Client_jMenuItemClearMessages_actionAdapter(this));
    jMenuServer.setText("Server");
    jMenuItemServerConnect.setText("Connect");
    jMenuItemServerConnect.addActionListener(new Client_jMenuItemServerConnect_actionAdapter(this));
    jMenuItemServerDisconnect.setText("Disconnect");
    jMenuItemServerDisconnect.addActionListener(
        new Client_jMenuItemServerDisconnect_actionAdapter(this));
    jMenuOptions.setText("Options");
    jMenuTest.setText("Test");
    jMenuItemOptionsRegister.setText("Register");
    jMenuItemOptionsRegister.addActionListener(
        new Client_jMenuItemOptionsRegister_actionAdapter(this));
    jMenuItemOptionsDeregister.setText("Deregister");
    jMenuItemOptionsDeregister.addActionListener(
        new Client_jMenuItemOptionsDeregister_actionAdapter(this));
    jMenuItemOptionsEavesdrop.setText("Eavesdrop");
    jMenuItemOptionsEavesdrop.addActionListener(
        new Client_jMenuItemOptionsEavesdrop_actionAdapter(this));
    jMenuItemOptionsUneavesdrop.setText("Uneavesdrop");
    jMenuItemOptionsUneavesdrop.addActionListener(
        new Client_jMenuItemOptionsUneavesdrop_actionAdapter(this));
    jMenuItemTestMulticonnect.setText("Multiconnect");
    jMenuItemTestMulticonnect.addActionListener(
        new Client_jMenuItemTestMulticonnect_actionAdapter(this));
    jMenuItemTestMessageStresser.setText("Message Stresser");
    jMenuItemTestMessageStresser.addActionListener(
        new Client_jMenuItemTestMessageStresser_actionAdapter(this));
    jMenuItemTestMultidisconnect.setText("Multidisconnect");
    jMenuItemTestMultidisconnect.addActionListener(
        new Client_jMenuItemTestMultidisconnect_actionAdapter(this));
    jMenuItemOptionsGlobalEavesdrop.setText("Global Eavesdrop");
    jMenuItemOptionsGlobalEavesdrop.addActionListener(
        new Client_jMenuItemOptionsGlobalEavesdrop_actionAdapter(this));
    jMenuItemOptionsGlobalUneavesdrop.setEnabled(false);
    jMenuItemOptionsGlobalUneavesdrop.setText("Global Uneavesdrop");
    jMenuItemOptionsGlobalUneavesdrop.addActionListener(
        new Client_jMenuItemOptionsGlobalUneavesdrop_actionAdapter(this));
    jLabelPwd.setText("Pwd");
    jPasswordFieldPwd.setMinimumSize(new Dimension(11, 20));
    jPasswordFieldPwd.setPreferredSize(new Dimension(75, 20));
    jPasswordFieldPwd.setText("");
    jMenuItemScheduleCommand.setText("Schedule Command");
    jMenuItemScheduleCommand.addActionListener(
        new Client_jMenuItemScheduleCommand_actionAdapter(this));
    jMenuItemEditScheduledCommands.setText("Edit Scheduled Commands");
    jMenuItemEditScheduledCommands.addActionListener(
        new Client_jMenuItemEditScheduledCommands_actionAdapter(this));
    jPanelSendMessages.add(jTextFieldSendSubject, null);
    jPanelSendMessages.add(jTextFieldSendMessages, null);
    jSplitPane1.add(jSplitPane2, JSplitPane.TOP);
    jSplitPane2.add(jScrollPane1, JSplitPane.TOP);
    jScrollPane1.getViewport().add(jTextPaneDisplayMessages, null);
    jSplitPane2.add(jScrollPane2, JSplitPane.BOTTOM);
    jScrollPane2.getViewport().add(jListOnlineUsers, null);
    this.getContentPane().add(jSplitPane1, BorderLayout.CENTER);
    jSplitPane1.add(jPanelSendMessages, JSplitPane.BOTTOM);
    this.getContentPane().add(jPanel1, BorderLayout.NORTH);
    jPanel1.add(jLabelServer, null);
    jPanel1.add(jTextFieldServer, null);
    jPanel1.add(jLabelUserId, null);
    jPanel1.add(jTextFieldUser, null);
    jPanel1.add(jLabelPwd, null);
    jPanel1.add(jPasswordFieldPwd, null);
    jPanel1.add(jLabeltargetUser, null);
    jPanel1.add(jTextFieldTargetUser, null);
    jPanel1.add(jToggleButtonConnect, null);
    jPanel1.add(jToggleButtonRegister, null);
    jPanel1.add(jButtonMultiConnect, null);
    jPanel1.add(jButtonMessageStresser, null);
    jPopupMenuMessageArea.add(jMenuItemClearMessages);
    jMenuBarMain.add(jMenuServer);
    jMenuBarMain.add(jMenuOptions);
    jMenuBarMain.add(jMenuTest);
    jMenuServer.add(jMenuItemServerConnect);
    jMenuServer.add(jMenuItemServerDisconnect);
    jMenuOptions.add(jMenuItemOptionsRegister);
    jMenuOptions.add(jMenuItemOptionsDeregister);
    jMenuOptions.add(jMenuItemOptionsEavesdrop);
    jMenuOptions.add(jMenuItemOptionsUneavesdrop);
    jMenuOptions.add(jMenuItemOptionsGlobalEavesdrop);
    jMenuOptions.add(jMenuItemOptionsGlobalUneavesdrop);
    jMenuTest.add(jMenuItemTestMulticonnect);
    jMenuTest.add(jMenuItemTestMultidisconnect);
    jMenuTest.add(jMenuItemTestMessageStresser);
    jMenuTest.add(jMenuItemScheduleCommand);
    jMenuTest.add(jMenuItemEditScheduledCommands);
    jSplitPane1.setDividerLocation(200);
    jSplitPane2.setDividerLocation(600);
    jListOnlineUsers.setCellRenderer(new OnlineListCellRenderer());
    jListOnlineUsers.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);

    jMenuItemTestMulticonnect.setEnabled(true);
    jMenuItemTestMultidisconnect.setEnabled(false);
    jMenuItemServerConnect.setEnabled(true);
    jMenuItemServerDisconnect.setEnabled(false);
    jMenuItemOptionsRegister.setEnabled(true);
    jMenuItemOptionsDeregister.setEnabled(false);
  }
  /** Instantiates a new game panel. */
  public GamePanel() {
    super();
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

    CARD_BACK.add(new CardPanel("img/cards/BACK.png"));

    // The code below is just for reference
    //        dealerCards = new ArrayList<>();
    //        for (int i = 0; i < dealerInHand.size(); i++)
    //        {
    //            dealerCards.add(new CardPanel("img/cards/" + dealerInHand.get(i) + ".png"));
    //        }
    //
    //        playerCardsOne = new ArrayList<>();
    //        for (int i = 0; i < playerInHandOne.size(); i++)
    //        {
    //            playerCardsOne.add(new CardPanel("img/cards/" + playerInHandOne.get(i) + ".png"));
    //        }
    //
    //        playerCardsTwo = new ArrayList<>();
    //        for (int i = 0; i < playerInHandTwo.size(); i++)
    //        {
    //            playerCardsTwo.add(new CardPanel("img/cards/" + playerInHandTwo.get(i) + ".png"));
    //        }
    // The code above is just for reference

    dealerDeckContainer = new CardDeckContainer();
    dealerStatContainer = new JPanel(new BorderLayout());
    dealerStatContainer.setOpaque(false);
    JLabel dealerStatTitle = new JLabel("Dealer in Hand");
    dealerStatTitle.setForeground(Color.WHITE);
    dealerStatTitle.setHorizontalAlignment(JLabel.CENTER);
    dealerStatTitle.setFont(new Font("", Font.PLAIN, 12));
    dealerStatPoint.setForeground(Color.WHITE);
    dealerStatPoint.setHorizontalAlignment(JLabel.CENTER);
    dealerStatPoint.setFont(new Font("", Font.PLAIN, 12));
    dealerStatContainer.add(dealerStatTitle, BorderLayout.NORTH);
    dealerStatContainer.add(dealerStatPoint, BorderLayout.CENTER);

    playerDeckOneContainer = new CardDeckContainer();
    playerStatOneContainer = new JPanel(new BorderLayout());
    playerStatOneContainer.setOpaque(false);
    JLabel playerStatOneTitle = new JLabel("Player in Hand");
    playerStatOneTitle.setForeground(Color.WHITE);
    playerStatOneTitle.setHorizontalAlignment(JLabel.CENTER);
    playerStatOneTitle.setFont(new Font("", Font.PLAIN, 12));
    playerStatOnePoint.setForeground(Color.WHITE);
    playerStatOnePoint.setHorizontalAlignment(JLabel.CENTER);
    playerStatOnePoint.setFont(new Font("", Font.PLAIN, 12));
    playerStatOneDescription.setForeground(Color.WHITE);
    playerStatOneDescription.setHorizontalAlignment(JLabel.CENTER);
    playerStatOneDescription.setFont(new Font("", Font.BOLD, 12));
    playerStatOneContainer.add(playerStatOneTitle, BorderLayout.NORTH);
    playerStatOneContainer.add(playerStatOnePoint, BorderLayout.CENTER);
    playerStatOneContainer.add(playerStatOneDescription, BorderLayout.SOUTH);

    playerDeckTwoContainer = new CardDeckContainer(new CardDeckPanel(CARD_BACK));
    playerStatTwoContainer = new JPanel(new BorderLayout());
    playerStatTwoContainer.setOpaque(false);
    JLabel playerStatTwoTitle = new JLabel("Player Hand 2");
    playerStatTwoTitle.setForeground(Color.WHITE);
    playerStatTwoTitle.setHorizontalAlignment(JLabel.CENTER);
    playerStatTwoTitle.setFont(new Font("", Font.PLAIN, 12));
    playerStatTwoPoint.setForeground(Color.WHITE);
    playerStatTwoPoint.setHorizontalAlignment(JLabel.CENTER);
    playerStatTwoPoint.setFont(new Font("", Font.PLAIN, 12));
    playerStatTwoDescription.setForeground(Color.WHITE);
    playerStatTwoDescription.setHorizontalAlignment(JLabel.CENTER);
    playerStatTwoDescription.setFont(new Font("", Font.BOLD, 12));
    playerStatTwoContainer.add(playerStatTwoTitle, BorderLayout.NORTH);
    playerStatTwoContainer.add(playerStatTwoPoint, BorderLayout.CENTER);
    playerStatTwoContainer.add(playerStatTwoDescription, BorderLayout.SOUTH);

    gameStatPanel = new JPanel();
    gameStatPanelPlayerName = new JLabel();
    gameStatPanelCurrentChips = new JLabel();
    gameStatPanelCurrentBet = new JLabel();
    gameStatPanelPlayerName.setFont(new Font("", Font.PLAIN, 14));
    gameStatPanelPlayerName.setForeground(Color.WHITE);
    gameStatPanelPlayerName.setBorder(new EmptyBorder(0, 0, 0, 5));
    gameStatPanelCurrentChips.setFont(new Font("", Font.PLAIN, 14));
    gameStatPanelCurrentChips.setForeground(Color.WHITE);
    gameStatPanelCurrentChips.setBorder(new EmptyBorder(0, 5, 0, 5));
    gameStatPanelCurrentBet.setFont(new Font("", Font.PLAIN, 14));
    gameStatPanelCurrentBet.setForeground(Color.WHITE);
    gameStatPanelCurrentBet.setBorder(new EmptyBorder(0, 5, 0, 0));
    gameStatPanel.add(gameStatPanelPlayerName);
    gameStatPanel.add(gameStatPanelCurrentChips);
    gameStatPanel.add(gameStatPanelCurrentBet);
    gameStatPanel.setOpaque(false);

    gameButtonPanel = new JPanel(cardLayout);
    betButtonPanel = new JPanel();
    playButtonPanel = new JPanel();
    JLabel pleaseBet = new JLabel("Please bet: ");
    pleaseBet.setFont(new Font("", Font.PLAIN, 14));
    pleaseBet.setForeground(Color.WHITE);
    betButtonPanel.add(pleaseBet);
    betField = new JTextField();
    betField.setFont(new Font("", Font.PLAIN, 14));
    betField.setPreferredSize(new Dimension(80, 28));
    betButtonPanel.add(betField);
    JButton betButton = new JButton("Bet");
    JButton backButton = new JButton("Back");
    betButtonPanel.add(betButton);
    betButtonPanel.add(backButton);
    betButtonPanel.setOpaque(false);

    hitButton = new JButton("Hit");
    standButton = new JButton("Stand");
    doubleButton = new JButton("Double");
    // JButton splitButton = new JButton("Split");
    // splitButton.setEnabled(false);
    playButtonPanel.add(hitButton);
    playButtonPanel.add(standButton);
    playButtonPanel.add(doubleButton);
    // playButtonPanel.add(splitButton);
    playButtonPanel.setOpaque(false);
    gameButtonPanel.add("betbutton", betButtonPanel);
    gameButtonPanel.add("playbutton", playButtonPanel);
    gameButtonPanel.setOpaque(false);

    add(gameStatPanel);
    add(dealerDeckContainer);
    add(playerDeckTwoContainer);
    add(playerDeckOneContainer);
    add(gameButtonPanel);

    this.addComponentListener(
        new ComponentAdapter() {
          @Override
          public void componentShown(ComponentEvent e) {
            Game.initGame();
          }
        });

    betButtonPanel.addComponentListener(
        new ComponentAdapter() {
          @Override
          public void componentShown(ComponentEvent e) {
            betField.setText("");
            if (BlackJack.player.getChip() <= 0) {
              JOptionPane.showMessageDialog(
                  null, "You are penniless!", "Information", JOptionPane.INFORMATION_MESSAGE);
              User.deleteUserByName(BlackJack.player.getName());
              BlackJack.player = new Player(true);
              BlackJack.dealer = new Player(false);
              BlackjackFrame.cardLayout.show(getParent(), "welcome");
            }
            hitButton.setEnabled(true);
            standButton.setEnabled(true);
            doubleButton.setEnabled(true);
            BlackJack.player.setBet(0);
            BlackJack.player.getHandOne().clear();
            BlackJack.player.getHandTwo().clear();
            BlackJack.dealer.getHandOne().clear();
            GamePanel.gameStatPanelPlayerName.setText("Player: " + BlackJack.player.getName());
            GamePanel.gameStatPanelCurrentChips.setText("Chips: " + BlackJack.player.getChip());
            GamePanel.gameStatPanelCurrentBet.setText("Bet: 0");
            GamePanel.gameStatPanel.repaint();
          }
        });

    betField.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyTyped(KeyEvent e) {
            int keyChar = e.getKeyChar();
            if (keyChar < KeyEvent.VK_0 || keyChar > KeyEvent.VK_9) {
              e.consume();
            }
          }
        });

    betButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            Game.bet(Integer.parseInt(betField.getText()));
          }
        });

    backButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            int choice =
                JOptionPane.showConfirmDialog(
                    null,
                    "Do you want to go back to main menu?\nYour record will be saved.",
                    "Go Back",
                    JOptionPane.YES_NO_OPTION);
            if (choice == JOptionPane.YES_OPTION) {
              User.updateUser();
              BlackJack.player = new Player(true);
              BlackJack.dealer = new Player(false);
              BlackjackFrame.cardLayout.show(getParent(), "welcome");
            }
          }
        });

    hitButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            doubleButton.setEnabled(false);
            Game.hit();
          }
        });

    standButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            hitButton.setEnabled(false);
            standButton.setEnabled(false);
            doubleButton.setEnabled(false);
            playerStatOneDescription.setText("Stand");
            playerStatOneDescription.repaint();
            Game.dealerGame();
          }
        });

    doubleButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            hitButton.setEnabled(false);
            standButton.setEnabled(false);
            doubleButton.setEnabled(false);
            if (!Game.doubleDown()) {
              hitButton.setEnabled(true);
              standButton.setEnabled(true);
              doubleButton.setEnabled(false);
            }
          }
        });
  }
Exemple #5
0
  public ChatClient() {
    super(APPNAME);

    JPanel topPanel = new JPanel();
    JPanel leftPanel = new JPanel();
    JPanel buttomPanel = new JPanel();

    JPanel roomPanel = new JPanel();
    JPanel userPanel = new JPanel();

    roomList = new JList();
    userList = new JList();
    msgTextArea = new JTextArea();
    msgTextField = new JTextField();
    nameTextField = new JTextField();
    submitButton = new JButton("送信");
    renameButton = new JButton("名前の変更");
    addRoomButton = new JButton("部屋を追加");
    enterRoomButton = new JButton("入室");

    submitButton.addActionListener(this);
    submitButton.setActionCommand("submit");

    renameButton.addActionListener(this);
    renameButton.setActionCommand("rename");

    addRoomButton.addActionListener(this);
    addRoomButton.setActionCommand("addRoom");

    enterRoomButton.addActionListener(this);
    enterRoomButton.setActionCommand("enterRoom");

    roomPanel.setLayout(new BorderLayout());
    roomPanel.add(new JLabel("チャットルーム"), BorderLayout.NORTH);
    roomPanel.add(new JScrollPane(roomList), BorderLayout.CENTER);
    roomPanel.add(enterRoomButton, BorderLayout.SOUTH);

    userPanel.setLayout(new BorderLayout());
    userPanel.add(new JLabel("参加ユーザー"), BorderLayout.NORTH);
    userPanel.add(new JScrollPane(userList), BorderLayout.CENTER);

    topPanel.setLayout(new FlowLayout());
    topPanel.add(new JLabel("名前"));
    topPanel.add(nameTextField);
    topPanel.add(renameButton);
    topPanel.add(addRoomButton);

    nameTextField.setPreferredSize(new Dimension(200, nameTextField.getPreferredSize().height));

    leftPanel.setLayout(new GridLayout(2, 1));
    leftPanel.add(roomPanel);
    leftPanel.add(userPanel);

    buttomPanel.setLayout(new BorderLayout());
    buttomPanel.add(msgTextField, BorderLayout.CENTER);
    buttomPanel.add(submitButton, BorderLayout.EAST);

    // テキストエリアはメッセージを表示するだけなので編集不可に設定
    msgTextArea.setEditable(false);

    // コンポーネントの状態を退室状態で初期化
    exitedRoom();

    this.getContentPane().add(new JScrollPane(msgTextArea), BorderLayout.CENTER);
    this.getContentPane().add(topPanel, BorderLayout.NORTH);
    this.getContentPane().add(leftPanel, BorderLayout.WEST);
    this.getContentPane().add(buttomPanel, BorderLayout.SOUTH);

    this.setDefaultCloseOperation(EXIT_ON_CLOSE);
    this.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            try {
              close();
            } catch (Exception err) {
            }
          }
        });
    connectServer();

    // メッセージ受信監視用のスレッドを生成してスタートさせる
    thread = new Thread(this);
    thread.start();

    // 現在の部屋を取得する
    sendMessage("getRooms");
  }