protected void showFirstPage() {
   if (tabbedPanel.getTabCount() <= 0) cardLayout.show(finalPanel, "FirstPanel");
   else {
     cardLayout.show(finalPanel, "TabbedPanel");
     tabbedPanel.setSelectedIndex(0);
   }
 }
 public void actionPerformed(ActionEvent e) {
   if (e.getSource() == ctl) {
     this.menu();
   } else if (e.getSource() == exit) {
     exitPerform();
   } else if (e.getSource() == rank) {
     if (count != 0) {
       card.show(mainPanel, "four");
       rankPanel.setMemory(memory, count - 1);
       buttonPanel.removeAll();
       buttonPanel.setBounds(width - 200, height - 80, 190, 50);
       buttonPanel.add(exit);
       check = 4;
       count--;
     }
   } else if (e.getSource() == back) {
     if (secondPanel.clip != null) {
       secondPanel.clip.stop();
       System.out.printf("test");
     }
     check = 0;
     card.previous(mainPanel);
     buttonPanel.removeAll();
     ctl.setText("- Play -");
     buttonPanel.add(ctl);
     buttonPanel.add(rank);
     buttonPanel.add(exit);
     buttonPanel.setOpaque(false);
     buttonPanel.setBounds(width / 2 - 50, height / 2 - 50, 80, 100);
   }
 }
 @Override
 public void mouseClicked(MouseEvent e) {
   // TODO Auto-generated method stub
   if (e.getSource() == login.b1) { // double click event
     card.show(getContentPane(), "WR");
   } else if (e.getSource() == login.b2) {
     card.show(getContentPane(), "");
   }
 }
Exemple #4
0
 public void setVisible(boolean bShow, String title) {
   if (bShow) {
     String strDir = "";
     String strFreq = "";
     String strTraynum = "";
     m_strHelpFile = getHelpFile(title);
     String strSampleName = getSampleName(title);
     String frameBounds = getFrameBounds(title);
     StringTokenizer tok = new QuotedStringTokenizer(title);
     if (tok.hasMoreTokens()) strDir = tok.nextToken();
     if (tok.hasMoreTokens()) strFreq = tok.nextToken();
     if (tok.hasMoreTokens()) strTraynum = tok.nextToken();
     else {
       try {
         Integer.parseInt(strDir);
         // if strdir is number, then strdir is empty, and the
         // strfreq is the number
         strTraynum = strFreq;
         strFreq = strDir;
         strDir = "";
       } catch (Exception e) {
       }
     }
     try {
       setTitle(gettitle(strFreq));
       m_lblSampleName.setText("3");
       boolean bVast = isVast(strTraynum);
       CardLayout layout = (CardLayout) m_pnlSampleName.getLayout();
       if (!bVast) {
         if (strSampleName == null) {
           strSampleName = getSampleName(strDir, strTraynum);
         }
         m_lblSampleName.setText(strSampleName);
         layout.show(m_pnlSampleName, OTHER);
       } else {
         m_strDir = strDir;
         setTrays();
         layout.show(m_pnlSampleName, VAST);
         m_trayTimer.start();
       }
       boolean bSample = bVast || !strSampleName.trim().equals("");
       m_pnlSampleName.setVisible(bSample);
       m_lblLogin.setForeground(getBackground());
       m_lblLogin.setVisible(false);
       m_passwordField.setText("");
       m_passwordField.setCaretPosition(0);
     } catch (Exception e) {
       Messages.writeStackTrace(e);
     }
     setBounds(frameBounds);
     ExpPanel exp = Util.getActiveView();
     if (exp != null) exp.waitLogin(true);
   }
   writePersistence();
   setVisible(bShow);
 }
  /*
   * Button or JTextField clicked
   */
  public void switchCards(String s) {
    System.out.println("Switching to " + s);

    CardLayout cl = (CardLayout) (mainPanels.getLayout());
    cl.show(mainPanels, s);
    mainPanels.revalidate();

    CardLayout cl2 = (CardLayout) (sidePanels.getLayout());
    cl2.show(sidePanels, s);
    sidePanels.revalidate();
  }
 protected void addPage(String _typeOfPage, String _name, String _code, boolean _enabled) {
   cardLayout.show(finalPanel, "TabbedPanel");
   _name = getUniqueName(_name);
   Editor page = createPage(_typeOfPage, _name, _code);
   page.setFont(myFont);
   page.setColor(myColor);
   int index = tabbedPanel.getSelectedIndex();
   if (index == -1) {
     pageList.addElement(page);
     if (tabbedPanel.getTabCount() == 0) {
       tabbedPanel.addTab(
           page.getName(),
           null,
           page.getComponent(),
           tooltip); // This causes an exception sometimes
     } else {
       tabbedPanel.insertTab(
           page.getName(), null, page.getComponent(), tooltip, tabbedPanel.getTabCount());
     }
     index = 0;
   } else {
     index++;
     pageList.insertElementAt(page, index);
     tabbedPanel.insertTab(page.getName(), null, page.getComponent(), tooltip, index);
   }
   tabbedPanel.setSelectedComponent(page.getComponent());
   page.setActive(_enabled);
   if (!_enabled) tabbedPanel.setTitleAt(index, page.getName() + " (D)");
   updatePageCounterField(pageList.size());
   // tabbedPanel.validate(); This hangs the computer when reading a file at start-up !!!???
   tabbedPanel.repaint();
   changed = true;
 }
 public void changePanel() {
   card.next(mainPanel);
   buttonPanel.removeAll();
   ctl.setText("- Play -");
   buttonPanel.add(ctl);
   buttonPanel.add(rank);
   buttonPanel.add(exit);
   buttonPanel.setOpaque(false);
   buttonPanel.setBounds(width / 2 - 50, height / 2 - 50, 80, 100);
   count++;
   memory[count] = new Memory();
   menuPanel.setMemory(memory[count]);
   secondPanel.setMemory(memory[count]);
   gamePanel.setMemory(memory[count]);
   rankPanel.setMemory(memory, count);
   check = 0;
   System.out.println(
       count
           + " "
           + memory[count - 1].name
           + " "
           + memory[count - 1].song
           + " "
           + memory[count - 1].score);
 }
Exemple #8
0
  public void actionPerformed(ActionEvent evt) {

    currentCard++;
    if (currentCard >= ask.length) {
      System.exit(0);
    }
    cards.show(this, "Card " + currentCard);
  }
  public void addColorChooserPanel(final AbstractColorChooserPanel ccp) {
    final String displayName = ccp.getDisplayName();
    if (displayName == null) {
      // Return if we haven't initialized yet
      return;
    }

    if (ccp.getClass()
        .getName()
        .equals("ch.randelshofer.quaqua.colorchooser.Quaqua15ColorPicker")) {
      northPanel.add(ccp, BorderLayout.WEST);
    } else {
      Icon displayIcon = ccp.getLargeDisplayIcon();
      JToggleButton tb = new JToggleButton(null, displayIcon);
      tb.setToolTipText(displayName);
      tb.setFocusable(false);
      tb.setHorizontalTextPosition(SwingConstants.CENTER);
      tb.setVerticalTextPosition(SwingConstants.BOTTOM);
      tb.setFont(UIManager.getFont("ColorChooser.font"));
      tb.putClientProperty("Quaqua.Button.style", "toolBarTab");
      JPanel centerView = new JPanel(new BorderLayout());
      centerView.add(ccp);
      chooserPanelHolder.add(centerView, displayName);
      toolBarButtonGroup.add(tb);
      toolBar.add(tb);

      if (toolBar.getComponentCount() == 1
          || lastSelectedChooserName != null && lastSelectedChooserName.equals(displayName)) {
        tb.setSelected(true);
        CardLayout cl = (CardLayout) chooserPanelHolder.getLayout();
        cl.show(chooserPanelHolder, displayName);
      }

      tb.addItemListener(
          new ItemListener() {
            public void itemStateChanged(ItemEvent evt) {
              if (evt.getStateChange() == ItemEvent.SELECTED) {
                CardLayout cl = (CardLayout) chooserPanelHolder.getLayout();
                cl.show(chooserPanelHolder, displayName);
                lastSelectedChooserName = displayName;
              }
            }
          });
    }
  }
  public void menu() {
    if (check == 0) {
      buttonPanel.removeAll();
      buttonPanel.setBounds(width - 200, height - 80, 200, 50);
      card.next(mainPanel);
      ctl.setText("- Play -");
      buttonPanel.add(back);
      buttonPanel.add(ctl);
      menuPanel.savename();
      check = 1;
      secondPanel.musiclist.clearSelection();
      gamePanel.setSecond(0);
    } else if (check == 1) {
      if (memory[count].getSong() == null) {
        Container con = getContentPane();

        String title = "--Warning--";
        String message = "Please Choice a Music Before Playing!";
        int type = JOptionPane.WARNING_MESSAGE;

        JOptionPane.showMessageDialog(con, message, title, type);
      } else {
        card.next(mainPanel);
        secondPanel.clip.stop();
        buttonPanel.removeAll();
        buttonPanel.setBounds(width - 200, height - 80, 190, 50);
        ctl.setText("- Stop -");
        buttonPanel.add(ctl);
        buttonPanel.add(exit);
        check = 2;
        gamePanel.playmusic();
        gamePanel.setRun(true);
      }
    } else if (check == 2) {
      ctl.setText("- Resume -");
      gamePanel.clip.stop();
      gamePanel.setRun(false);
      check = 3;
    } else if (check == 3) {
      ctl.setText("- Stop -");
      gamePanel.clip.start();
      gamePanel.setRun(true);
      check = 2;
    }
  }
 protected void removeCurrentPage() {
   int index = tabbedPanel.getSelectedIndex();
   if (index < 0) return;
   tabbedPanel.removeTabAt(index);
   pageList.removeElementAt(index);
   updatePageCounterField(pageList.size());
   changed = true;
   if (tabbedPanel.getTabCount() <= 0) cardLayout.show(finalPanel, "FirstPanel");
   ejs.getModelEditor().getVariablesEditor().updateControlValues(false);
 }
Exemple #12
0
 /** Connect the vector of QV's into the main View */
 public void installQVs() {
   Exam thisExam = theTD.curX;
   Vector qv = thisExam.getListData();
   for (int i = 0; i < qv.size(); i++) {
     // Use question number (1-origin) as string name.
     // System.out.println("Add question " +i +" to " + questionsPanel);
     questionsPanel.add(Integer.toString(i + 1), new QView((Q) qv.elementAt(i)));
   }
   myCardLayout.first(questionsPanel);
 }
 public void showPage(Editor anEditor) {
   for (int i = 0, n = tabbedPanel.getComponentCount(); i < n; i++) {
     if (tabbedPanel.getComponent(i) == anEditor.getComponent()) {
       //        System.out.println ("Found editor "+anEditor.getName()+ " at i="+i);
       ejs.showPanel(defaultHeader);
       cardLayout.show(finalPanel, anEditor.getName());
       tabbedPanel.setSelectedComponent(anEditor.getComponent());
       return;
     }
   }
 }
  /**
   * Set the current panel
   *
   * @param panel the panel
   */
  protected void setCurrentPanel(WizardPanel panel) {

    currentPanel = panel;
    currentPanel.prepare();

    cardLayout.show(cardPanel, currentPanel.toString());

    backButton.setEnabled(currentPanel != firstPanel);
    cancelButton.setText("Cancel");
    nextButton.setText("Next");
    cancelButton.setEnabled(true);
  }
Exemple #15
0
  /** Change the view to display a given question number (1-origin) */
  protected void setQNumber(int nn) {
    String userShowNumber = Integer.toString(nn);

    System.out.println("setQNumber(" + userShowNumber + ");");

    // notify the model
    //	TODO -- if necessary!

    // update the view
    numTF.setText(userShowNumber);
    numSlider.setValue(nn);

    // show the right question
    myCardLayout.show(questionsPanel, userShowNumber);
  }
 public void exitPerform() {
   if (check == 4) {
     this.changePanel();
   } else if (check == 0) {
     this.dispose();
   } else {
     card.next(mainPanel);
     rankPanel.updateUI();
     buttonPanel.removeAll();
     buttonPanel.add(exit);
     gamePanel.clip.stop();
     gamePanel.setRun(false);
     check = 4;
   }
 }
  /**
   * Constructor.
   *
   * @param functions the array of functions to plot
   * @param graphPanel the parent graph panel
   */
  HeaderPanel(Plottable functions[], GraphPanel graphPanel) {
    this();
    this.graphPanel = graphPanel;

    fpDimensions = maxFunctionDimensions(functions);

    buttonPanel.setLayout(new FlowLayout());
    buttonPanel.add(headerButton);

    imagePanel.setSize(fpDimensions);

    functionCard.add(buttonPanel, BorderLayout.WEST);
    functionCard.add(imagePanel, BorderLayout.CENTER);

    cardLayout.show(this, FUNCTION);

    // Header button handler.
    headerButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ev) {
            HeaderPanel.this.graphPanel.doHeaderAction(); // callback
          }
        });
  }
  /**
   * Réagit au clique de la souris sur un bouton
   *
   * @param e L'ActionEvent généré
   */
  public void actionPerformed(ActionEvent e) {
    if (e.getSource() instanceof JButton) {
      JButton b = (JButton) e.getSource();
      if (b.getName() == "statTab") { // Si on clique sur l'onglet statistiques
        cartes.show(panneau, "statistiques");
      } else if (b.getName() == "payTab") { // Si on clique sur l'onglet de paiement
        cartes.show(panneau, "paiement");
      } else if (b.getName() == "loginButton") { // Si on clique sur le bonton de login
        char[] input = passTextField.getPassword();
        String pass = new String("root"); // Le mot de passe
        if (pass.equals(new String(input))) {
          cartes.show(panneau, "paiement");
          loginLabel.setText("");
        } else loginLabel.setText("Mot de passe incorrect");

        Arrays.fill(input, '0');
        passTextField.selectAll();
      } else if (b.getName() == "annuler") { // Si clique sur annuler
        // On réserte la sélection et on déselectionne les tables
        ControleurTables.deleteSelection();
        this.tableCounter = 0;
        this.payTextField.setText("");
        this.valider.setEnabled(false);
        this.valider.setBackground(Color.GRAY);
      } else if (b.getName() == "valider") { // Si on clique sur valider

        // On récupère la date
        Calendar cal = Calendar.getInstance();
        cal.add(Calendar.SECOND, (int) this.difTemps);
        // On récupère le mode de paiement sélectionné
        String type = new String("carte bleue");
        if (especes.isSelected()) {
          type = "especes";
        } else if (cheque.isSelected()) {
          type = "cheque";
        }
        try { // On verifie que le prix rentré est correct
          // On met tout dans le meme try pour annuler l'insertion de la commande dans la bdd en cas
          // d'erreur
          float prix = Float.parseFloat(payTextField.getText());
          ModelePaiement mP = new ModelePaiement();
          mP.insert(cal, prix, type);
          // On recupère la selection
          ArrayList<Table> tab = ControleurTables.getSelection();
          // On met toutes les tables à laver
          for (int i = 0; i < tab.size(); i++) {
            tab.get(i).setStatut(Table.ALAVER);
            tab.get(i).setNom(null);
          }
          // On déselectionne les tables
          ControleurTables.deleteSelection();
          this.tableCounter = 0;
          this.payTextField.setText("");
          this.valider.setEnabled(false);
          this.valider.setBackground(Color.GRAY);
          // On insère le paiement dans la bdd
          modeleTable.updateTables(this.tables);
        } catch (NumberFormatException nfe) {
          JOptionPane.showMessageDialog(
              null, "Veuillez entrez un rpix valide.", "Erreur prix", JOptionPane.ERROR_MESSAGE);
        }
      } else if (b.getName() == "trier") { // Si on appuie sur trier
        float ca = -1;
        ModelePaiement mP = new ModelePaiement();
        if (service.isSelected()) { // Si on selection le chiffre d'affaire par service
          ca =
              mP.getCAService(
                  (String)
                      serviceComboBox
                          .getSelectedItem()); // On sélectonne le chiffre d'affaire en focntion du
                                               // service

        } else if (date.isSelected()) { // Si on selection le chiffre d'affaire par date
          try { // On verifie que la date est bien valide
            Calendar cal = Calendar.getInstance();
            SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
            cal.setTime(sdf.parse(dateTextField.getText()));
            ca = mP.getCADate(cal); // On va chercher le chiffre d'affaire en fonction de la date
          } catch (Exception npe) {
            JOptionPane.showMessageDialog(
                null,
                "Veuillez entrez une date de la forme 03/06/2012.",
                "Erreur date",
                JOptionPane.ERROR_MESSAGE);
          }
        }

        if (ca > -1) { // Si on a récupérer un chiffre d'affaire
          chiffreAffaire.setText("Chiffre d'affaire : " + Float.toString(ca));
        }
      } else if (b.getName() == "option") { // Si on clique sur option
        String strDate =
            JOptionPane.showInputDialog(null, "Réglage de temps (ex: 03/06/1996 15:06) ", null);

        try {
          Calendar cal = Calendar.getInstance();
          Calendar now = Calendar.getInstance();

          SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm");
          cal.setTime(sdf.parse(strDate));
          difTemps =
              (int)
                  ((cal.getTimeInMillis() - now.getTimeInMillis())
                      / 1000); // Transformation en secondes
          if ((cal.getTimeInMillis() - now.getTimeInMillis()) % 1000 > 0) {
            difTemps++;
          }
        } catch (Exception exep) {
          JOptionPane.showMessageDialog(
              null,
              "Vous devez entrer une date valide (ex: 03/06/1996 15:06).",
              "Date invalide",
              JOptionPane.ERROR_MESSAGE);
        }
      }
    }
  }
 private void showView(String sView) {
   CardLayout cl = (CardLayout) (m_jPanelContainer.getLayout());
   cl.show(m_jPanelContainer, sView);
 }
    public Editor(JFrame parent, Evaluator evaluator) {
      super(parent, "Structure");
      setModal(true);
      this.evaluator = evaluator;

      getContentPane().setLayout(new BorderLayout());

      // name and type
      JPanel pNameType = new JPanel(new GridLayout(2, 1));
      JPanel pName = new JPanel(new BorderLayout());
      pName.add(new JLabel("Name: "), BorderLayout.WEST);
      tfName = new JTextField(evaluator.getName());
      pName.add(tfName, BorderLayout.CENTER);
      pNameType.add(pName);
      JPanel pType = new JPanel(new BorderLayout());
      pType.add(new JLabel("Type: "), BorderLayout.WEST);
      cbType = new JComboBox(types);
      cbType.setEditable(false);
      cbType.setSelectedIndex(evaluator.type);
      cbType.addItemListener(this);
      pType.add(cbType, BorderLayout.CENTER);
      pNameType.add(pType);
      getContentPane().add(pNameType, BorderLayout.NORTH);

      // options panel
      this.clOptions = new CardLayout();
      this.pOptions = new JPanel(clOptions);

      JPanel pConstraintRoot = new JPanel(new BorderLayout());
      Box pConstraintOpts = new Box(BoxLayout.Y_AXIS);
      JPanel pDiagonals = new JPanel(new BorderLayout());
      cbDiagonals = new JCheckBox("Ignore Diagonals", evaluator.ignoreDiagonals);
      pDiagonals.add(cbDiagonals, BorderLayout.CENTER);
      pConstraintOpts.add(pDiagonals);
      JPanel pInvestment = new JPanel(new BorderLayout());
      pInvestment.add(new Label("Investments "), BorderLayout.WEST);
      cbInvestment = new JComboBox(investments);
      cbInvestment.setEditable(false);
      cbInvestment.setSelectedIndex(evaluator.investments);
      pInvestment.add(cbInvestment, BorderLayout.CENTER);
      pConstraintOpts.add(pInvestment);
      JPanel pOrganization = new JPanel(new GridLayout(2, 1));
      lOrgFileName = new JLabel("File: <none selected>");
      pOrganization.add(lOrgFileName);
      JPanel pFileChoose = new JPanel(new FlowLayout(FlowLayout.CENTER));
      JButton bFileChoose = new JButton("Choose File...");
      bFileChoose.addActionListener(this);
      bFileChoose.setActionCommand(CMD_CHOOSE_FILE);
      pFileChoose.add(bFileChoose);
      pOrganization.add(pFileChoose);
      pConstraintOpts.add(pOrganization);
      pConstraintRoot.add(pConstraintOpts, BorderLayout.NORTH);
      pOptions.add(pConstraintRoot, types[CONSTRAINT]);

      JPanel pSizeRoot = new JPanel(new BorderLayout());
      pOptions.add(pSizeRoot, types[EFFECTIVE_SIZE]);
      clOptions.first(pOptions);

      getContentPane().add(BorderLayout.CENTER, pOptions);

      // ok/cancel panel
      JOkCancelPanel okCancelPanel = new JOkCancelPanel();
      okCancelPanel.addActionListener(this);
      getContentPane().add(BorderLayout.SOUTH, okCancelPanel);

      pack();
    }
  public void actionPerformed(ActionEvent e) {
    if (e.getSource() == ld.st) // 0.로딩화면에서 Enter버튼 클릭
    {
      System.out.println("할리갈리 온라인 안쪽으로 접근중...");
      card.show(getContentPane(), "LOG");
    } else if (e.getSource() == login.bt1) // 1.팝업창으로 회원가입창 띄우기
    {
      mID.setBounds(470, 310, 340, 420);
      mID.setVisible(true);
    } else if (e.getSource() == login.bt2) // 2.로그인버튼 누르기
    {
      ld.clip.stop();
      wr.clip.play();
      id = login.tf.getText().trim(); // ID입력안했을때
      if (id.length() < 1) {
        JOptionPane.showMessageDialog(this, "ID를 입력하세요");
        login.tf.requestFocus();
        return;
      }
      String pass = new String(login.pf.getPassword()); // PWD입력안했을때
      if (pass.length() < 1) {
        JOptionPane.showMessageDialog(this, "Password를 입력하세요");
        login.pf.requestFocus();
        return;
      }

      connection(); // 모두 정확히 처리했으면, connection()메소드로 이동!!

      try {
        out.write(
            (Function.LOGIN
                    + "|"
                    + id
                    + "|" // 로그인버튼 눌러서 server에게 요청
                    + pass
                    + "\n")
                .getBytes());
      } catch (Exception ex) {
      }
    } else if (e.getSource() == wr.tf || e.getSource() == wr.b1) // 3.waitroom에서 채팅입력할 때
    {
      String data = wr.tf.getText(); // 입력한 값 가져오기
      if (data.length() < 1) return;
      try {
        out.write((Function.WAITCHAT1 + "|" + data + "\n").getBytes()); // 채팅전송을 server에게 요청
      } catch (Exception ex) {
      }
      wr.tf.setText("");
    } else if (e.getSource() == gw.tf || e.getSource() == gw.b1) // 4.gameWindow에서 채팅입력할 때
    {
      String data = gw.tf.getText(); // 입력한 값 가져오기
      if (data.length() < 1) return;
      try {
        out.write((Function.ROOMCHAT + "|" + data + "\n").getBytes()); // 채팅전송을 server에게
      } catch (Exception ex) {
      }
      gw.tf.setText("");
    } else if (e.getSource() == wr.b2) // 5.방만들기창
    {
      mr.tf.setText(""); // 방만들기 초기화
      mr.pf.setText("");
      mr.rb1.setSelected(true);
      mr.setBounds(500, 300, 260, 290);
      mr.setVisible(true);
    } else if (e.getSource() == wr.b3) // 6.방들어가기 버튼처리 /////////////////////////////////
    {
      wr.clip.stop();
      gw.clip.play();
      System.out.println("방유저리스트수: " + gw.model1.getRowCount());
      for (int i = 0; i < gw.model1.getRowCount(); i++) {
        System.out.println("방유저리스트삭제");
        gw.model1.removeRow(i); // 추가
      }
      // gw.model1.removeRow(0); //추가
      if (rowNum >= 0) {
        try {
          gw.ta.setText("");
          out.write((Function.JOINROOM + "|" + rowNum + "\n").getBytes());
        } catch (Exception e2) {
        }
      }
    } else if (e.getSource() == mr.b1) // 6.방만들기창에서 확인 눌렀을때//////////////////////////////
    {
      wr.clip.stop();
      gw.clip.play();
      gw.clip.loop();

      String subject = mr.tf.getText().trim(); // 방이름 입력 안했을때
      if (subject.length() < 1) {
        JOptionPane.showMessageDialog(this, "방이름을 입력하세요");
        mr.tf.requestFocus();
        return;
      }

      if (mr.rb2.isSelected()) { // 비공개 버튼 눌렀을 때
        String pw = new String(mr.pf.getPassword());
        if (pw.length() < 1) {
          JOptionPane.showMessageDialog(this, "비밀번호를 입력하세요");
          mr.pf.requestFocus();
          return;
        }
      }

      mr.dispose();
      /*System.out.println("방유저리스트수: "+gw.model1.getRowCount());
          for(int i=0;i<gw.model1.getRowCount();i++)
      {
          	  System.out.println("방유저리스트삭제");
       gw.model1.removeRow(i); //추가
      }*/
      try {
        String roomType = ""; // 1.공개or비공개 저장
        if (mr.rb1.isSelected()) {
          roomType = mr.rb1.getText();
        } // 공개
        else if (mr.rb2.isSelected()) {
          roomType = mr.rb2.getText();
        } // 비공개
        String roomName = mr.tf.getText(); // 2.방이름
        String capaNum = mr.box.getSelectedItem().toString(); // 3.최대인원수
        out.write(
            (Function.MAKEROOM + "|" + roomType + "|" + roomName + "|" + capaNum + "\n")
                .getBytes());
        // 공개여부,방이름,최대인원 넘겨줌

      } catch (Exception ex) {
      }

    } else if (e.getSource() == wr.b8) // 도움말 버튼처리
    {
      help.setVisible(true);
      repaint();
    } else if (e.getSource() == wr.b9) // 게임종료 버튼처리
    {
      /*서버로 종료 메시지 전송후 프로그램 종료*/
      try {
        out.write((Function.CLIENTEXIT + "|\n").getBytes());

      } catch (Exception e2) {
      }

      try {
        s.close(); // 소켓해제
      } catch (IOException e1) {
        e1.printStackTrace();
      }
      System.exit(0);
    } else if (e.getSource() == mID.b1) // 가입완료버튼
    {
      String name = mID.tf1.getText().trim();
      String id = mID.tf2.getText().trim();
      String pass1 = new String(mID.pf1.getPassword());
      String pass2 = new String(mID.pf2.getPassword());
      if (name.length() < 1) {
        JOptionPane.showMessageDialog(this, "이름을 입력하세요");
        mID.tf1.requestFocus();
        return;
      } else if (id.length() < 1) {
        JOptionPane.showMessageDialog(this, "ID를 입력하세요");
        mID.tf2.requestFocus();
        return;
      } else if (mID.ck == false) {
        JOptionPane.showMessageDialog(this, "ID 중복체크 하시오");
        mID.tf2.requestFocus();
        return;
      } else if (pass1.length() < 1) {
        JOptionPane.showMessageDialog(this, "비밀번호를 입력하세요");
        mID.pf1.requestFocus();
        return;
      } else if (pass2.length() < 1) {
        JOptionPane.showMessageDialog(this, "비밀번호 확인을 입력하세요");
        mID.pf2.requestFocus();
        return;
      } else if (!(pass1.equals(pass2))) {
        JOptionPane.showMessageDialog(this, "비밀번호가 동일하지 않습니다");
        mID.pf1.requestFocus();
        return;
      }
      try {
        out.write((Function.SUCCESSJOIN + "|" + name + "|" + id + "|" + pass1 + "\n").getBytes());
      } catch (IOException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
      }
      JOptionPane.showMessageDialog(this, "회원가입완료");
      mID.dispose();
    } else if (e.getSource() == mID.b2) {
      mID.tf1.setText("");
      mID.tf2.setText("");
      mID.pf1.setText("");
      mID.pf2.setText("");
      mID.dispose();
    } else if (e.getSource() == mID.b3) // ID중복체크
    {
      String id = mID.tf2.getText().trim();
      if (id.length() < 1) {
        JOptionPane.showMessageDialog(this, "ID를 입력하세요");
        mID.tf2.requestFocus();
        return;
      }

      if (mID.num == 0) // 한번도 소켓을 연결하지 않았다면
      {
        System.out.println("연결시도");
        connection();
        mID.num++;
      }

      System.out.println("ID중복체크");
      try {
        System.out.println(id);
        out.write((Function.IDCHECK + "|" + id + "\n").getBytes()); // ID중복체크를 server에게 요청
      } catch (Exception ex) {
      }
    } else if (e.getSource() == gw.b4) { // GameWindow에서 준비버튼 눌렀을 때

      gw.clip.stop();
      gw.clip3.play();
      try {
        out.write((Function.ROOMREADY + "|" + "\n").getBytes());
      } catch (IOException e1) {
        e1.printStackTrace();
      }
    } else if (e.getSource() == gw.b5) { // GameWindow에서 시작버튼 눌렀을 때
      try {
        out.write((Function.ROOMSTART + "|" + "\n").getBytes());
        gw.b5.setEnabled(false);
      } catch (IOException e1) {
        e1.printStackTrace();
      }
    } else if (e.getSource() == gw.b6) // GameWindow에서 나가기 눌렀을 때
    {
      gw.clip.stop();
      gw.clip2.play();
      wr.clip.play();
      System.out.println("방나가기 버튼 Click");
      System.out.println("방유저리스트수: " + gw.model1.getRowCount());
      // int tmp=gw.model1.getRowCount();
      /*for(int i=0;i<gw.model1.getRowCount();i++)
      {
      	  gw.model1.removeRow(i); //추가
      }*/
      // gw.model1.
      wr.ta.setText(""); // 수정
      gw.b4.setEnabled(true);
      try {
        out.write((Function.EXITROOM + "|" + "\n").getBytes());
      } catch (Exception ex) {
      }
    } else if (e.getSource() == gw.cardOpen) // 카드뒤집기 눌렀을 때!!!
    {
      gw.clip4.play(); // 카드 넘기는 소리
      gw.cardOpen.setBorderPainted(false);
      gw.cardOpen.setContentAreaFilled(false);
      gw.cardOpen.setEnabled(false);
      try {
        out.write((Function.CARDOPEN + "|" + id + "\n").getBytes());
      } catch (IOException e1) {
        e1.printStackTrace();
      }
    } else if (e.getSource() == gw.bell) // 종치기 버튼
    {
      gw.clip1.play(); // 종치는소리
      try {
        out.write((Function.BELL + "|" + id + "\n").getBytes());
      } catch (IOException e1) {
        e1.printStackTrace();
      }
    }
  }
  @Override
  public void run() { // client와 server간의 통신

    while (true) {
      try {
        String msg = in.readLine();
        System.out.println("Server=>" + msg);
        StringTokenizer st = new StringTokenizer(msg, "|");
        int protocol = Integer.parseInt(st.nextToken());
        switch (protocol) {
          case Function.YOURTURN: // 0.자기차례일 때 카드뒤집기 버튼활성화
            {
              gw.cardOpen.setBorderPainted(false);
              gw.cardOpen.setContentAreaFilled(false);
              gw.cardOpen.setEnabled(true);
            }
            break;
          case Function.DELROW: // 1.게임종료한 client 정보 접속자 List 에서 삭제
            {
              int rowIndex = (Integer.parseInt(st.nextToken())); // rowIndex=delIndex
              System.out.println("삭제 줄: " + rowIndex);
              wr.model2.removeRow(rowIndex); // 접속자리스트에서 삭제
            }
            break;
          case Function.CLIENTEXIT: // 2.waitRoom 채팅방에 00님이 나가셨습니다 전송
            {
              wr.ta.append(st.nextToken() + "\n");
              wr.bar.setValue(wr.bar.getMaximum());
            }
            break;
          case Function.MYLOG: // 1.window타이틀에 사용자이름 업데이트
            {
              String id = st.nextToken();
              setTitle(id);
              card.show(getContentPane(), "WR"); // waitingroom으로 창 전환
            }
            break;

          case Function.LOGIN: // 2.접속자테이블에 사용자 업데이트
            {
              String[] data = {st.nextToken(), st.nextToken()};

              wr.model2.addRow(data);
            }
            break;

          case Function.ROOMUSER: // 2.게임룸 유저테이블에 유저업데이트
            {
              System.out.println("In-ROOMUSER");
              String[] data = {st.nextToken()};
              gw.model1.addRow(data);
            }
            break;
          case Function.OUTUSER:
            {
              int rowIndex = (Integer.parseInt(st.nextToken())); // rowIndex=delIndex
              System.out.println("삭제 줄: " + rowIndex);
              gw.model1.removeRow(rowIndex);
            }

          case Function.WAITCHAT1: // 3.채팅할 때(waitroom)
            {
              wr.ta.append(st.nextToken() + "\n");
              wr.bar.setValue(wr.bar.getMaximum());
            }
            break;

          case Function.ROOMCHAT: // 3.채팅할 때(gameWindow)
            {
              gw.ta.append(st.nextToken() + "\n");
              gw.bar.setValue(gw.bar.getMaximum());
              validate();
            }
            break;

          case Function.NOTOVERLAP: // 4.ID가 중복되지 않을 때
            {
              JOptionPane.showMessageDialog(this, "ID가 중복되지 않습니다");
              mID.ck = true;
              mID.pf1.requestFocus();
            }
            break;

          case Function.OVERLAP: // 4.ID가 중복될 때
            {
              JOptionPane.showMessageDialog(this, "ID가 중복됩니다. 다시 입력하세요.");
              mID.ck = false;
              mID.pf1.requestFocus();
            }
            break;

          case Function.MAKEROOM: // 5.client가 방만들기 확인 버튼을 눌렀을 때(게임창 전환)
            {
              String roomId = st.nextToken(); // 게임룸 만든 사람 	id
              String roomName = st.nextToken(); // 새로 만든 게임룸의 	이름
              String humanNum = st.nextToken(); // 현재인원수	//아직 안쓰임
              String capaNum = st.nextToken(); // 최대인원수	//아직 안쓰임
              setTitle("방장_" + roomId + "    " + "방제_" + roomName);
              gw.b5.setEnabled(false); // 시작버튼 비활성화
              gw.ta.setText("");
              card.show(getContentPane(), "GW"); // 게임창으로 전환
            }
            break;

          case Function.ROOMINFORM: // 5.client가 방만들기 확인 버튼을 눌렀을 때(waitRoom의 리스트에 방 추가)
            {
              String roomType = st.nextToken(); // 공개비공개
              String roomName = st.nextToken(); // 게임룸의 이름
              String nnum = st.nextToken(); // 현재인원
              String num = st.nextToken(); // 최대인원
              String pos = st.nextToken(); // 방상태(게임대기중)
              String[] data = {roomType, roomName, nnum, num, pos};
              wr.model1.addRow(data); // waitRoom의 리스트에 방 추가						
              wr.repaint();
            }
            break;

          case Function.JOINROOM: // 6.방에 들어가기 했을 때(인원 수에따라 입장 가능 여부)
            {
              String result = st.nextToken();
              if (result.equals("TRUE")) {
                String roomMaker = st.nextToken();
                String roomName = st.nextToken();
                setTitle("방장_" + roomMaker + "    " + "방제_" + roomName);
                gw.b5.setEnabled(false); // 시작버튼 비활성화
                gw.tf.setText("");
                card.show(getContentPane(), "GW");
                // 준비버튼 활성화
                gw.b4.setEnabled(true);
                validate();
              } else {
                JOptionPane.showMessageDialog(this, "방이 꽉찼습니다.");
              }
            }
            break;

          case Function.ROOMREADY: // 6.준비버튼 눌렀을 때 버튼 비활성화
            {
              System.out.println("최종적으로 준비전달받음");
              gw.b4.setEnabled(false); // 준비버튼비활성화
            }
            break;

          case Function.ROOMREADYBUTTON: // 7.모두준비했을 때 방장만 시작 활성화
            {
              System.out.println("방장의 권한으로 시작버튼 활성화");
              gw.b5.setEnabled(true); // 준비버튼비활성화
            }
            break;
            //					  case Function.GAMESTART:			//7.모두준비했을 때 방장만 시작 활성화
            //					  {
            //						  System.out.println("방장의 권한으로 시작버튼 활성화");
            //						  gw.cardOpen.setBorderPainted(false);
            //							gw.cardOpen.setContentAreaFilled(false);
            //							gw.cardOpen.setEnabled(false);
            //
            //					  }
            //					  break;
            /*[방인원변경 ] ->*/
          case Function.CHGROOMUSER:
            {
              // 대기실 방 List table 의 특정 Row 의 방인원이 변경됨
              int row = Integer.parseInt(st.nextToken());
              String userNum = st.nextToken();
              wr.model1.setValueAt(userNum, row, 2);
              wr.repaint();
            }
            break;

            /*[유저상태변경] ->*/
          case Function.CHGUSERPOS:
            {
              int row = Integer.parseInt(st.nextToken()); // 방번호
              System.out.println("\\\\\\--->" + row);
              String pos = st.nextToken(); // 현재인원수
              wr.model2.setValueAt(pos, row, 1);
              wr.repaint();
            }
            break;

            /*[방상태변경 ] ->*/
          case Function.CHGROOMSTATE:
            {
              // 대기실 방 List table 의 특정 Row 의 방인원이 변경됨
              int row = Integer.parseInt(st.nextToken()); // 방번호
              String roomState = st.nextToken(); // 방상태
              wr.model1.setValueAt(roomState, row, 4);
              wr.repaint();
            }
            break;

            /*[방나가기] ->*/
          case Function.DELROOM: // 방에 사용자가 없에 방삭제 메시지 받음
            {
              gw.tf.setText("");
              int roomRow = Integer.parseInt(st.nextToken());
              System.out.println(roomRow + "방 삭제");
              wr.model1.removeRow(roomRow);
              wr.repaint();
            }
            break;
          case Function.REPAINT:
            {
              String tmpName = st.nextToken();
              int b = Integer.parseInt(st.nextToken());
              System.out.println("InREPAIT-ID:" + tmpName + "Number:" + b);
              gw.UpdateDraw(tmpName, b);
            }
            break;
          case Function.CARDNUM:
            {
              String tmpName = st.nextToken(); // id
              int b = Integer.parseInt(st.nextToken()); // 카드수
              System.out.println("InCARDNUM-ID:" + tmpName + "Number:" + b);
              gw.UpdateCardNum(tmpName, b);
            }
            break;
          case Function.DEAD:
            {
              gw.ta.append("당신은 죽었습니다.\n");
              gw.bell.setEnabled(false);
              gw.cardOpen.setEnabled(false);
            }
            break;
          case Function.UPDATEDEAD:
            {
              String tmpName = st.nextToken();
              gw.ta.append(tmpName + " 님이 죽었습니다.\n");
              gw.UpdateDead(tmpName);
              validate();
            }
            break;
          case Function.BELLSUCCESS:
            {
              String tmpName = st.nextToken();
              gw.ta.append(tmpName + " 님이 종치기 성공했습니다.\n");
              gw.bell.setEnabled(true);
              gw.CardInit();
            }
            break;

          case Function.BELLFAIL:
            {
              String tmpName = st.nextToken();
              gw.ta.append(tmpName + "님이 종치기 실패하였습니다.\n");
              gw.bell.setEnabled(true);
              validate();
            }
            break;

          case Function.BELL:
            {
              gw.bell.setEnabled(false);
            }
            break;

          case Function.TURNINFO:
            {
              gw.userName[0] = st.nextToken();
              gw.userName[1] = st.nextToken();
              gw.userName[2] = st.nextToken();
              gw.userName[3] = st.nextToken();
            }
            break;
          case Function.EXITFALSE: // 게임시작시 나가기비활성화
            {
              gw.b6.setEnabled(false);
            }
            break;

          case Function.IDLABEL: // 게임시작시 id라벨 입력
            {
              String ID = st.nextToken(); // id
              for (int i = 0; i < 4; i++) {
                if (ID.equals(gw.userName[i])) {
                  gw.laPlayer[i].setText("Player" + (i + 1) + ": " + ID);
                }
              }
            }
            break;
          case Function.GAMEEXIT:
            {
              System.out.println("zzzzz");
              String tmpId = st.nextToken();
              String tmpMsg = st.nextToken();
              gw.ta.append("게임종료=====>" + tmpId + tmpMsg);
              gw.b4.setEnabled(true);
              gw.b6.setEnabled(true);
              gw.CardInit();
            }
            break;
        }
      } catch (Exception ex) {
        validate();
      }
      validate();
    }
  }
 void formatComboBox_actionPerformed(ActionEvent e) {
   cardLayout.show(mainPanel, name(getCurrentChooser().getComponent()));
 }
  /**
   * Constructor.
   *
   * @param headerText the header label text
   */
  HeaderPanel(String headerText) {
    this();

    label.setText(headerText);
    cardLayout.show(this, MESSAGE);
  }
  public SyntaxTab() {
    super(new BorderLayout(), "Syntax highlighting");
    /*
     * upper checkboxes
     */
    JPanel upper = new JPanel(new GridLayout(2, 1, 0, 0));
    upper.setOpaque(false);
    upper.add(MyPanel.wrap(highlightSyntax));
    upper.add(MyPanel.wrap(matchBracket));
    highlightSyntax.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent ev) {
            SyntaxTab.this.updateComponentStatus();
          }
        });
    this.add(upper, BorderLayout.PAGE_START);
    /*
     * upper panel (painters)
     */
    painterComboBox.setSelectedItem(myjava.gui.syntax.Painter.getCurrentInstance());
    painterComboBox.setFont(f13);
    if (isMetal) painterComboBox.setBackground(Color.WHITE);
    painterComboBox.addItemListener(this.painterChangeListener);
    JButton addPainter =
        new MyButton("+") {
          {
            if (isMetal) {
              this.setPreferredSize(new Dimension(28, 28));
            }
          }

          @Override
          public void actionPerformed(ActionEvent ev) {
            String name;
            do {
              name =
                  JOptionPane.showInputDialog(
                      SyntaxTab.this, "Enter a name:", "Name", JOptionPane.QUESTION_MESSAGE);
            } while (!myjava.gui.syntax.Painter.isValidPrompt(name, SyntaxTab.this));
            if ((name != null) && (!name.isEmpty())) {
              // name is valid, neither cancelled nor pressed enter directly
              myjava.gui.syntax.Painter newPainter =
                  ((myjava.gui.syntax.Painter) (painterComboBox.getSelectedItem()))
                      .newInstance(name);
              addPainter(newPainter);
              System.out.println("now set, should call listener");
              painterComboBox.setSelectedItem(newPainter); // auto-call ItemListener(s)
            }
          }
        };
    JButton removePainter =
        new MyButton("-") {
          {
            if (isMetal) {
              this.setPreferredSize(new Dimension(28, 28));
            }
          }

          @Override
          public void actionPerformed(ActionEvent ev) {
            myjava.gui.syntax.Painter painter =
                (myjava.gui.syntax.Painter) (painterComboBox.getSelectedItem());
            if (painter.equals(myjava.gui.syntax.Painter.getDefaultInstance())) {
              JOptionPane.showMessageDialog(
                  SyntaxTab.this,
                  "The default painter cannot be removed.",
                  "Error",
                  JOptionPane.ERROR_MESSAGE);
            } else {
              int option =
                  JOptionPane.showConfirmDialog(
                      SyntaxTab.this,
                      "Remove painter \"" + painter.getName() + "\"?",
                      "Confirm",
                      JOptionPane.YES_NO_OPTION);
              if (option == JOptionPane.YES_OPTION) {
                // remove "painter"
                removedPainters.add(painter);
                painterComboBox.removeItemListener(painterChangeListener);
                painterComboBox.setSelectedItem(myjava.gui.syntax.Painter.getDefaultInstance());
                painterComboBox.removeItem(painter);
                for (Iterator<EntryListPanel> it = listPanelSet.iterator(); it.hasNext(); ) {
                  EntryListPanel panel = it.next();
                  if (panel.getPainter().getName().equals(painter.getName())) {
                    System.out.println("removing, then break");
                    it.remove();
                    centerPanel.remove(panel);
                    break;
                  }
                }
                painterComboBox.addItemListener(painterChangeListener);
                cardLayout.show(
                    centerPanel, myjava.gui.syntax.Painter.getDefaultInstance().getName());
              }
            }
          }
        };
    // lower part
    JPanel center = new JPanel(new BorderLayout());
    JLabel selectLabel = new MyLabel("Selected painter:");
    center.add(
        MyPanel.wrap(MyPanel.CENTER, selectLabel, painterComboBox, addPainter, removePainter),
        BorderLayout.PAGE_START);
    componentSet.addAll(Arrays.asList(selectLabel, addPainter, removePainter));
    center.add(centerPanel, BorderLayout.CENTER);
    this.add(center, BorderLayout.CENTER);
    cardLayout.show(centerPanel, myjava.gui.syntax.Painter.getCurrentInstance().getName());
  }
 /**
  * Display an error message.
  *
  * @param message the error message
  */
 void displayError(String message) {
   cardLayout.show(this, MESSAGE);
   label.setForeground(MAROON);
   label.setText("ERROR:  " + message);
 }
 public void itemStateChanged(ItemEvent evt) {
   // only on 'selection' event
   if (evt.getStateChange() == ItemEvent.SELECTED) {
     clOptions.show(pOptions, types[cbType.getSelectedIndex()]);
   }
 }
 /**
  * Set the header label text in color.
  *
  * @param text the text
  * @param color the color
  */
 void setLabel(String text, Color color) {
   cardLayout.show(this, MESSAGE);
   label.setForeground(color);
   label.setText(text);
 }
Exemple #29
0
 public void itemStateChanged(ItemEvent e) {
   PlayerType ptype = (PlayerType) e.getItem();
   CardLayout cl = (CardLayout) mTabs.getLayout();
   assert (cl.getClass() == CardLayout.class);
   cl.show(mTabs, ptype.toString());
 }
 /**
  * Set a function and repaint the function panel.
  *
  * @param xSelection the selected function index
  */
 void setFunction(Plottable function) {
   this.function = function;
   cardLayout.show(this, FUNCTION);
   imagePanel.repaint();
 }