public void actionPerformed(ActionEvent e) {
   if (e.getSource() == jb1) {
     try {
       strategyFrame =
           new StrategyFrame(
               trainingTeaBLService.showFrameStrategy(), trainingTeaBLService, jb1.getText());
       strategyFrame.setTrainingTeaWindow(this.trainingTeaWindow);
     } catch (RemoteException e1) {
       // TODO Auto-generated catch block
       e1.printStackTrace();
     }
   } else if (e.getSource() == jb2) {
     try {
       strategyFrame =
           new StrategyFrame(
               trainingTeaBLService.showFrameStrategy(), trainingTeaBLService, jb2.getText());
       strategyFrame.setTrainingTeaWindow(this.trainingTeaWindow);
     } catch (RemoteException e1) {
       // TODO Auto-generated catch block
       e1.printStackTrace();
     }
   } else if (e.getSource() == refresh) {
     refresh();
   }
 }
Exemplo n.º 2
0
 private void multiConnect() {
   if (jButtonMultiConnect.getText().equals("Multi-Connect")) {
     String res =
         JOptionPane.showInputDialog(this, "Enter number of connections", "Multi-Connect");
     if (res != null) {
       jButtonMultiConnect.setText("Multi-Disconnect");
       jMenuItemTestMulticonnect.setEnabled(false);
       jMenuItemTestMultidisconnect.setEnabled(true);
       int count = Integer.parseInt(res);
       MultiSessions = new Session[count];
       for (int i = 0; i < count; i++) {
         MultiSessions[i] = new Session();
         try {
           MultiSessions[i].connect(
               this.jTextFieldServer.getText(), this.jTextFieldUser.getText() + String.valueOf(i));
         } catch (ConnectionException ex1) {
         }
       }
     }
   } else {
     for (int i = 0; i < MultiSessions.length; i++) {
       try {
         ((Session) MultiSessions[i]).disconnect();
       } catch (Exception ex) {
         System.out.println("Error disconnectiong from session");
       }
     }
     jButtonMultiConnect.setText("Multi-Connect");
     jMenuItemTestMulticonnect.setEnabled(true);
     jMenuItemTestMultidisconnect.setEnabled(false);
   }
 }
Exemplo n.º 3
0
 // Handle button clicks, specifically the next button
 public void actionPerformed(ActionEvent e) {
   if (btnext.getText().equals("Next")) {
     if (quizAnswerID < 9) {
       map.put(quizAnswerID, getSelection());
       quizAnswerID++;
       readQuestionAnswer(quizAnswerID);
     } else {
       map.put(quizAnswerID, getSelection());
       btnext.setText("Show results");
     }
   } else if (btnext.getText().equals("Show results")) {
     blankScreen();
   } else if (btnext.getText().equals("Try again")) {
     reset();
   }
 }
Exemplo n.º 4
0
 public void actionPerformed(ActionEvent ev) {
   if (button.getText().equals("Hello")) {
     button.setText("World");
   } else {
     button.setText("Hello");
   }
 }
Exemplo n.º 5
0
    public void actionPerformed(ActionEvent e) {
      JButton campo = (JButton) e.getSource();
      int temp_col = Integer.parseInt(campo.getText());
      if (temp_col == 0) {
        col1 = true;
      }
      if (temp_col == 1) {
        col2 = true;
      }
      if (temp_col == 2) {
        col3 = true;
      }
      if (temp_col == 3) {
        col4 = true;
      }
      if (temp_col == 4) {
        col5 = true;
      }
      if (temp_col == 5) {
        col6 = true;
      }

      solution[temp_col].setBackground(jButtonColor.getBackground());
      trying[temp_col] = ("" + currentColor);
      if (col1 && col2 && col3 && col4 && col5 && col6) {
        //	verifica();

        col1 = false;
        col2 = false;
        col3 = false;
        col4 = false;
        col5 = false;
        col6 = false;
      }
    }
Exemplo n.º 6
0
 public void actionPerformed(ActionEvent ae) {
   JButton b = (JButton) ae.getSource();
   //      System.out.println("NumberEar: button="+b.getText());
   int i = new Integer(b.getText()).intValue() - 1;
   number[date].setForeground(Color.BLUE);
   date = i;
   number[i].setForeground(Color.CYAN);
 }
Exemplo n.º 7
0
    public void actionPerformed(ActionEvent e) {
      JButton source = (JButton) e.getSource();
      _usrVotes[_index] = source.getText();

      for (JButton b : _candidateButtons) {
        b.setForeground(Color.BLACK);
      }
      source.setForeground(Color.RED);

      System.out.println("Vote for " + _title + " is " + _usrVotes[_index]);
    }
 public void actionPerformed(ActionEvent e) {
   if (e.getSource().equals(pausePlay)) {
     if (pausePlay.getText().equals("Play")) {
       pausePlay.setText("Pause");
       LifeSimulation.timer().start();
     } else {
       pausePlay.setText("Play");
       LifeSimulation.timer().stop();
     }
   }
 }
 public void actionPerformed(ActionEvent e) {
   if (e.getSource() == pauseButton) {
     if (pauseButton.getText().equals("Pause Agents")) {
       pauseButton.setText("Resume Agents");
       Agent.pause = true;
     } else {
       pauseButton.setText("Pause Agents");
       Agent.pause = false;
     }
   }
 }
Exemplo n.º 10
0
 @Override
 public void actionPerformed(ActionEvent e) {
   // TODO Auto-generated method stub
   if (e.getSource() == convert || e.getSource() == input) {
     if (miUnit.isSelected()) {
       double miles = Double.parseDouble(input.getText());
       double km = MetricConverter.milesToKm(miles);
       display.append(miles + " miles equals " + km + " kilometers\n");
       input.setText("");
     } else {
       double km = Double.parseDouble(input.getText());
       double miles = MetricConverter.kmToMile(km);
       display.append(km + " km equals " + miles + " miles\n");
       input.setText("");
     }
   } else {
     JButton b = (JButton) e.getSource();
     if (b.getText().equals("C")) input.setText("");
     else input.setText(input.getText() + b.getText());
   }
 }
Exemplo n.º 11
0
 public void actionPerformed(ActionEvent e) {
   GridDemo.printInMethod();
   JButton source = (JButton) e.getSource();
   System.out.println(source);
   String currentText = source.getText();
   if (currentText.equals("_")) {
     source.setText("X");
   } else if (currentText.equals("X")) {
     source.setText("O");
   } else {
     source.setText("_");
   }
 }
Exemplo n.º 12
0
    public void mouseClicked(MouseEvent e) {
      if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 1) {
        JButton source = (JButton) e.getSource();

        String value = source.getText();
        int day = Integer.parseInt(value);
        calendar.set(Calendar.DAY_OF_MONTH, day);
        Date selectDate = this.getSelectDate();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
        MyDateChooseBtn.this.setText(simpleDateFormat.format(selectDate));
        Jtext.setText(simpleDateFormat.format(selectDate));

        int year = calendar.get(Calendar.YEAR);
        int month = calendar.get(Calendar.MONTH) + 1;
        //        System.out.println(year + "骞�" + month + "鏈�" + day + "鏃�");
        f.dispose();
      }
    }
Exemplo n.º 13
0
  public void actionPerformed(ActionEvent e) {
    if (e.getSource() == startBtn) {
      if (startBtn.getText() == "Start") {
        if (started) {
          //					paramsBtn.setText("change parameters and rerun");
          //					started = false;
        }
        start();
      } else {
        stop();
      }
    } else if (e.getSource() == writeBtn) {
      outputEPS();
    } else if (e.getSource() == paramsBtn) {
      changeParameters();
      start();

    } else if (e.getSource() == wrapBtn) {
      changeWrap();
    }
  }
Exemplo n.º 14
0
 @Override
 public void actionPerformed(ActionEvent e) {
   Object source = e.getSource();
   JButton but = (JButton) source;
   if (!(but.getText().equals(this.goodAnswer))) {
     this.clean();
     gc.weightx = 2;
     gc.weighty = 2;
     gc.gridx = 0;
     gc.gridy = 0;
     this.add(new WrongAnswer(this.goodAnswer, this.game), gc);
     this.revalidate();
   } else {
     this.clean();
     gc.weightx = 2;
     gc.weighty = 2;
     gc.gridx = 0;
     gc.gridy = 0;
     this.add(new GoodAnswer(this.game, 6), gc);
     this.revalidate();
   }
 }
Exemplo n.º 15
0
 public void actionPerformed(ActionEvent e) {
   JButton tempB = (JButton) e.getSource();
   option = tempB.getText();
   if (option.equals("+")) {
     txt.setText(myCalculat.opAdd(txt.getText()));
     ifOp = true;
   } else if (option.equals("-")) {
     txt.setText(myCalculat.opSubtract(txt.getText()));
     ifOp = true;
   } else if (option.equals("*")) {
     txt.setText(myCalculat.opMultiply(txt.getText()));
     ifOp = true;
   } else if (option.equals("/")) {
     txt.setText(myCalculat.opDivide(txt.getText()));
     ifOp = true;
   } else if (option.equals("=")) {
     txt.setText(myCalculat.opEquals(txt.getText()));
     ifOp = true;
   } else if (option.equals("C")) {
     txt.setText("");
     ifOp = true;
   }
 }
Exemplo n.º 16
0
 public void actionPerformed(ActionEvent e) {
   JButton tempB = (JButton) e.getSource();
   s = tempB.getText();
   setTextFieldText();
 }
Exemplo n.º 17
0
  // This is where all the action happens.  If an action is performed (button press for example), it
  // goes through this method
  // that takes an ActionEvent, which is created at the time of the action.
  public void actionPerformed(ActionEvent e) {
    // Try to cast the ActionEvent source as JToggleButton (if successful, the button is a ballot
    // choice)
    try {
      JToggleButton theButton = (JToggleButton) e.getSource();
      String buttonText = theButton.getText();

      if (theButton.isSelected()) {
        theButton.setForeground(Color.RED);
        switchButton = true;
        switchButtonText = buttonText;
        updateButtons(
            buttonText); // switches this button's respective vote position to 1 (true), meaning it
                         // is selected
      } else if (!theButton.isSelected()) {
        theButton.setForeground(Color.BLACK);
        unvoteButton = true;
        unvoteButtonText = buttonText;
      }
      // If the program can't cast the source to a JToggleButton, cast it as a JButton, which is
      // 100% what the source will be at this point.
      // This button will be one of two things: the login button or the cast vote button.
    } catch (Exception exception) {
      JButton theButton = (JButton) e.getSource();

      String buttonText = theButton.getText();

      // If the user hits the Login button, check if the ID is valid.
      // If the ID is not valid, don't let them vote.  However, if it is valid, disable login and
      // enable everything else.
      if (buttonText.equals("Login")) {
        String voterID =
            JOptionPane.showInputDialog(theButton, "Enter your voter ID: ", "Login", 3);
        FileIO votersFile = new FileIO("voters.txt");
        ArrayList<Voter> voters = votersFile.createVoters();

        if (votersFile.checkValidID(voterID)) {
          Voter theVoter = voters.get(votersFile.getVoterIndex(voterID));
          if (theVoter.getVotedStatus().equals("false")) {
            setVoterID(voterID);
          } else {
            JOptionPane.showMessageDialog(
                theButton, "You already voted " + theVoter.getVoterName() + "!");
          }
        } else {
          JOptionPane.showMessageDialog(theButton, "Invalid ID!", "Error", 0);
        }
        // If the user hits the cast vote button, update the respective ballot files and disable
        // every button except
        // for the login button.
      } else if (buttonText.equals("Cast vote")) {
        int confirm = JOptionPane.showConfirmDialog(theButton, "Are you sure?");
        FileIO votersFile = new FileIO("voters.txt");
        ArrayList<Voter> voters = votersFile.createVoters();
        Voter theVoter = voters.get(votersFile.getVoterIndex(voterID));

        if (confirm == 0) {
          JOptionPane.showMessageDialog(theButton, "Thanks for voting!");
          updateBallots();
          votersFile.updateVoterFile(theVoter.getVoterID());
          setVoterID("-1");
          votersFile.initializeVoters();
        }
      }
    }
  }
Exemplo n.º 18
0
 @Override
 public void mouseEntered(MouseEvent e) {
   JButton but = (JButton) e.getSource();
   this.voix.playText(but.getText());
 }
Exemplo n.º 19
0
  public void actionPerformed(ActionEvent ae) {
    // clear display if new number is to be entered
    if (doClear) display.setText(null);

    // if decimal point is entered for the first time in number
    if ((ae.getSource() == point) && decPoint == false) {
      display.append(".");
      // disallow more decimal points
      decPoint = true;
    }

    // if decimal point is the first in a number, display "0."
    if (display.getText().equals(".")) display.setText("0.");

    // check if a digit was clicked
    for (int i = 0; i < 10; i++) {

      // append digits to number while number is less than 15 digits long
      if ((ae.getSource() == jb[i]) && (display.getText().length() < 15)) {

        display.append(((JButton) ae.getSource()).getText());

        // disallow leading zeros
        if (display.getText().equals("0")) display.setText("0.");

        // store as a Double
        secondNum = Double.parseDouble(display.getText());
        System.out.println("SecondNum is: " + secondNum);

        doClear = false;
        // only if you click another digit
        oldOp = false;
      }
    }

    // check if an operator was clicked
    if ((ae.getSource() == plus)
        || (ae.getSource() == minus)
        || (ae.getSource() == div)
        || (ae.getSource() == mult)) {
      decPoint = false;
      if (oldOp == false) {
        // if this is the first time an operator was clicked
        if (operators) {
          // the number last entered becomes the first number
          firstNum = secondNum;
          System.out.println("firstNum is: " + secondNum);
        } else {

          calc();
        }

        // store the operator that was clicked
        JButton temp = (JButton) ae.getSource();
        operator = temp.getText();
        System.out.println("Operator is: " + operator);
        operators = false;
        doClear = true;
        oldOp = true;
      }
      // if an operator was clicked without a digit having been entered between
      else {
        // store the operator that was clicked
        JButton temp = (JButton) ae.getSource();
        operator = temp.getText();
        System.out.println("Operator is: " + operator);
        display.setText(String.valueOf(firstNum));
      }
    }

    if (ae.getSource() == root) {
      squareRoot();
      decPoint = false;
    }

    if (ae.getSource() == clear) {
      clear();
    }

    if (ae.getSource() == equals) {
      calc();
    }
  }
Exemplo n.º 20
0
    public void actionPerformed(ActionEvent e) {
      Object source = e.getSource();
      JButton btn = (JButton) source;
      Window w = SwingUtilities.getWindowAncestor(btn);
      if (btn.getText().equals(usesword)) {
        boolean msword = false;
        for (String item : inventory) {
          String magicsword = "light saber"; // "magic sword";
          if (!used1) {
            if (item.equals(magicsword)) {
              txtTranscript.insert(
                  "An intense battle ensues! " // "\nCONGRATULATIONS! You have slain the dragon "
                      + "The only audible noise is the sound of light sabers waving in the air " // "and reclaimed the Treasure of the Noontide Sol! "
                      + "and crashing together. As the battle grows more intense, suddenly out " // "The light's morale has been restored to the land!\n"
                      + "of nowhere Emporer Palpatine intervenes, forcing you to the ground. "
                      + "You are paralyzed as powerful electrical pulses eminate from the "
                      + "Emporer's fingertips, entering into your entire being. "
                      + "Your father, Darth Vader will not let the Emporer kill you! "
                      + "He picks up the Emporer and throws him over the edge of a bottomless pit of certain doom! "
                      + "He has saved your life!!! "
                      + "With this one act of love your father has returned to the light, "
                      + "showing that the light side of the force is still in him. "
                      + "GAME OVER - YOU HAVE WON!!!",
                  txtTranscript.getText().length());
              msword = true;
              used1 = false;
              w.setVisible(false);
            }
          }
        }
        if (!used1 && !msword) {
          txtTranscript.insert(
              "\nDarth Vader lunges forward to strike you with his light saber!!! " // "The dragon
                  // blows flames
                  // in your
                  // direction!!!
                  // "
                  + "You got lucky! He narrowly missed!!!"
                  + "\nCONGRATULATIONS! You're an idiot! "
                  + "You don't have a light saber! "
                  + "Better retreat for now...",
              txtTranscript.getText().length());
          used1 = true;
        } else if (used1 && !msword) {
          txtTranscript.insert(
              "\nThe Mask doesn't seem to be working. " // ("\nThe dragon blows flames in your
                  // direction "
                  + "You are not so lucky this time. After stupidly trying the Hulk mask "
                  + "again, Vader lunges forward with his saber, decapitating you instantly. " // the dragon engulfs you in flames, almost instantly incinerating you "
                  + "...\nGAME OVER\n",
              txtTranscript.getText().length());
          msword = true;
          used1 = false;
          w.setVisible(false);
        }
      }
      if (btn.getText().equals(usedagger)) {
        boolean dagger = false;
        for (String item : inventory) {
          if (item.equals("glowing hulk mask")) { // dagger")) {
            if (!used) {
              txtTranscript.insert(
                  "\nThe Mask doesn't seem to be working. "
                      + "Darth Vader lunges forward to strike you with his light saber!!! " // "The
                      // dragon blows flames in your direction!!! "
                      + "You got lucky! He narrowly missed!!! "
                      + "Better try something else...",
                  txtTranscript.getText().length());
              dagger = true;
              used = true;
            } else {
              txtTranscript.insert(
                  "\nThe Mask doesn't seem to be working. " // ("\nThe dragon blows flames in your
                      // direction "
                      + "You are not so lucky this time. After stupidly trying the Hulk mask "
                      + "again, Vader lunges forward with his saber, decapitating you instantly. " // the dragon engulfs you in flames, almost instantly incinerating you "
                      + "...\nGAME OVER\n",
                  txtTranscript.getText().length());
              used = false; // reset static used boolean to false in case player comes back
              w.setVisible(false);
            }
          }
        }
        if (!used && !dagger) {
          txtTranscript.insert(
              "\nThe Mask doesn't seem to be working. "
                  + "Darth Vader lunges forward to strike you with his light saber!!! " // "The
                  // dragon
                  // blows
                  // flames in
                  // your
                  // direction!!! "
                  + "You got lucky! He narrowly missed!!! "
                  + "Better try something else...",
              txtTranscript.getText().length());
          /*("\nThe dragon blows flames in your direction!!! "
          + "You got lucky! The flames narrowly missed!!!"
          + "\nCONGRATULATIONS! You're an idiot! "
          + "You don't have a dagger! And if you did would it really help "
          + "against this dragon? Better try something else...", txtTranscript.getText().length());*/
          used = true;
        } else if (used && !dagger) {
          txtTranscript.insert(
              "\nThe Mask doesn't seem to be working. " // ("\nThe dragon blows flames in your
                  // direction "
                  + "You are not so lucky this time. After stupidly trying the Hulk mask "
                  + "again, Vader lunges forward with his saber, decapitating you instantly. " // the dragon engulfs you in flames, almost instantly incinerating you "
                  + "...\nGAME OVER\n",
              txtTranscript.getText().length());

          /*("\nThe dragon blows flames in your direction "
          + "You are not so lucky this time. After stupidly trying the dagger "
          + "again, THAT YOU DON'T HAVE! the dragon engulfs you in flames, almost instantly incinerating you "
          + "into a pile of ashes ...\nGAME OVER\n", txtTranscript.getText().length());*/
          used = false; // reset static used boolean to false in case player comes back
          w.setVisible(false);
        }
      }
      if (btn.getText().equals(runaway)) {
        txtTranscript.insert(
            "\nRUN FOR IT MARTY!!!\nYou barely escape.", txtTranscript.getText().length());
        used = false; // reset static used boolean to false in case player comes back
        w.setVisible(false);
      }
    }
Exemplo n.º 21
0
 public void actionPerformed(ActionEvent e) {
   JButton source = (JButton) e.getSource();
   String choice = source.getText();
   changeDemonstration(choice);
 }
Exemplo n.º 22
0
    public void actionPerformed(ActionEvent e) {
      JButton o = (JButton) e.getSource();

      String label = o.getText();
      System.out.println("Button " + label + " pressed");

      //            boolean oppExists = false;
      //            for(Opportunity opp : createdOpportunities) {
      //                if (opp.getName() == nameText.getText()) oppExists = true;
      //            }
      //

      switch (label) {
        case "Clean Form":
          ownerId.setSelectedIndex(-1);
          accountId.setSelectedIndex(-1);
          leadSource.setSelectedIndex(-1);
          eventTsText.setText("2011-07-11 11:00:00.000 +0:00");
          ECDText.setText("2011-07-11");
          nameText.setText("");
          amountText.setText("1000");
          descriptionText.setText("");
          stageNameText.setText("");
          stageDescrText.setText("");
          statusText.setText("");
          resultText.setText("");
          isClosed.setSelected(false);
          isWon.setSelected(false);
          break;
        case "Create":
          createdOpportunities.add(
              new Opportunity(
                  ownerId.getSelectedItem().toString(),
                  accountId.getSelectedItem().toString(),
                  leadSource.getSelectedItem().toString(),
                  eventTsText.getText(),
                  ECDText.getText(),
                  amountText.getText(),
                  nameText.getText(),
                  descriptionText.getText(),
                  stageNameText.getText(),
                  stageDescrText.getText(),
                  isClosed.isSelected(),
                  isWon.isSelected()));
          oppsCounter++;
          ownerId.setSelectedIndex(-1);
          accountId.setSelectedIndex(-1);
          leadSource.setSelectedIndex(-1);
          eventTsText.setText("2011-07-11 11:00:00.000 +0:00");
          ECDText.setText("2011-07-11");
          nameText.setText("");
          amountText.setText("1000");
          descriptionText.setText("");
          stageNameText.setText("");
          stageDescrText.setText("");
          statusText.setText("");
          resultText.setText("");
          isClosed.setSelected(false);
          isWon.setSelected(false);
          System.out.println("Total opportunities created: " + createdOpportunities.size());
          break;
        case "Generate SQL":
          tools.generateOpportunitiesSQL(createdOpportunities);
      }
    }
Exemplo n.º 23
0
  /** Handle action events. */
  public void actionPerformed(ActionEvent event) {
    JButton jbn;
    String somestr = null;
    //	    System.out.println("Debug:IconToolBox:actionPerformed: "+event.getSource().toString());

    if (parentFrame.currModule == null) {
      warningPopup4.display("IconToolBox: Must use File Menu to create Icon first.");
      return;
    }

    if (event.getSource() instanceof JButton) {
      jbn = (JButton) event.getSource();
      String somestr2 = event.getActionCommand();
      somestr = jbn.getText();
      //	    System.out.println("Debug:IconToolBox: JButton: somestr:" + somestr);
      //	    System.out.println("Debug:IconToolBox: JButton: somestr2:" + somestr2);
      // -----------------------------------
      if (somestr.equals("Move")) {
        status = "move";
        parentFrame.myIconPanel.newstatus();
        return;
      }
      // -----------------------------------
      if (somestr.equals("Clear")) {
        String qstring = "IconToolBox:Are you sure you want to clear the screen?";
        boolean okPressed = okCancelPopup4.display(qstring);
        if (okPressed) {
          status = "clear";
        } else {
          status = "nothing";
        }
        parentFrame.myIconPanel.newstatus();
        return;
      }
      // --------------------------------------
      if (somestr.equals("InPort")) {
        doPort("InputPort");
        parentFrame.myIconPanel.newstatus();
        return;
      }
      // -----------------------------------
      if (somestr.equals("OutPort")) {
        doPort("OutputPort");
        parentFrame.myIconPanel.newstatus();
        return;
      }
      // -----------------------------------
      if (somestr.equals("Text")) {
        parentFrame.myIconPanel.setCursor(new Cursor(Cursor.TEXT_CURSOR));
        // show the option panel  *nitgupta*
        //  System.out.print("text selected ");

        GetNamePopup ie = new GetNamePopup((Frame) parentFrame, SCSUtility.maxCharsFreeText);
        ie.setSize(300, 100);
        ie.show();
        if (ie.status.equals("ok") == true) {
          status = "insert_text";
          IconPanel.text_string = ie.NameTF.getText();
        } else {
          IconPanel.text_string = "";
          status = "nothing";
        }
        parentFrame.myIconPanel.newstatus();
        return;
      }
      // --------------------
      if (somestr.equals("Line")) {
        status = "insert_line";
        parentFrame.myIconPanel.setCursor(new Cursor(Cursor.HAND_CURSOR));
        parentFrame.myIconPanel.newstatus();
        return;
      }
      // --------------------
      if (somestr.equals("Oval")) {
        status = "insert_oval";
        parentFrame.myIconPanel.setCursor(new Cursor(Cursor.HAND_CURSOR));
        parentFrame.myIconPanel.newstatus();
        return;
      }
      // --------------------
      if (somestr.equals("Rectangle")) {
        status = "insert_rect";

        parentFrame.myIconPanel.setCursor(new Cursor(Cursor.HAND_CURSOR));
        parentFrame.myIconPanel.newstatus();
        return;
      }
      // --------------------
      if (somestr.equals("Polygon")) {
        status = "insert_poly";
        parentFrame.myIconPanel.setCursor(new Cursor(Cursor.HAND_CURSOR));
        parentFrame.myIconPanel.newstatus();
        return;
      }
      // --------------------
      warningPopup4.display("IconToolBox:JButton but no one claimed it.");
      return;
    } // end if JButton
    warningPopup4.display("IconToolBox:Event but no button or menu item claimed it.");
  }
Exemplo n.º 24
0
 public void mouseClicked(MouseEvent e) {
   if (e.getSource() == userList && e.getClickCount() == 2) {
     int index = userList.locationToIndex(e.getPoint());
     if (index > -1) {
       String userInfo = (String) ((DefaultListModel) userList.getModel()).get(index);
       link.running = false;
       userInfo = userInfo.substring(userInfo.indexOf("@") - 1);
       link =
           new LeetClient(
               userInfo.substring(userInfo.indexOf("@") + 1, userInfo.indexOf(":")),
               Integer.parseInt(userInfo.substring(userInfo.indexOf(":") + 1)),
               address,
               directory);
       link.setPasv(portItem.getState());
       link.command = "LIST";
       link.start();
     }
   }
   if (e.getSource() == fileList && e.getClickCount() == 2) {
     int index = fileList.locationToIndex(e.getPoint());
     if (index > -1) {
       String fileName = (String) ((DefaultListModel) fileList.getModel()).get(index);
       if (fileName.indexOf(" ") > -1) {
         fileName = fileName.substring(0, fileName.indexOf(" "));
       }
       link.command = "RETR " + fileName;
       System.out.println(link.command);
     }
   }
   if (e.getSource() == connectButton) {
     if (connectButton.getText().equals("Disconnect")) {
       active.running = false;
       connectButton.setText("Connect");
     } else {
       active =
           new LeetActive(
               serverTextField.getText(),
               Integer.parseInt(portTextField.getText()),
               SERVER_PORT);
       active.setUserName(nameTextField.getText());
       active.start();
       connectButton.setText("Disconnect");
     }
   }
   if (e.getSource() == searchInit) {
     search = new SearchUsers();
     search.start();
   }
   if (e.getSource() == searchList && e.getClickCount() == 2) {
     int index = searchList.locationToIndex(e.getPoint());
     if (index > -1) {
       String fileInfo = (String) ((DefaultListModel) searchList.getModel()).get(index);
       link.running = false;
       String userInfo = fileInfo.substring(fileInfo.indexOf("@") + 1);
       userInfo = userInfo.substring(userInfo.indexOf("@") - 1);
       fileInfo = fileInfo.substring(0, fileInfo.indexOf("@"));
       link =
           new LeetClient(
               userInfo.substring(userInfo.indexOf("@") + 1, userInfo.indexOf(":")),
               Integer.parseInt(userInfo.substring(userInfo.indexOf(":") + 1)),
               address,
               directory);
       link.setPasv(portItem.getState());
       link.command = "RETR " + fileInfo;
       link.start();
     }
   }
 }
Exemplo n.º 25
0
  public void actionPerformed(ActionEvent e) {
    JButton b = (JButton) e.getSource();
    if (b.getText() == "PLAY") {
      if (scoreP != null) scoreP.playScale(sp.getScale(), tempoP.getValue());
    } else if (b.getText() == "New") {
      try {
        saveUnsaved();
      } catch (SaveAbortedException ex) {
        return;
      }

      sp.notes.removeAllElements();
      sp.repaint();
      nameTF.setText("");
      loadedFile = null;
    } else if (b.getText() == "Save") {
      if (nameTF.getText().equals("")) {
        JOptionPane.showMessageDialog(
            this,
            new JLabel("Please type in the Scale Name"),
            "Warning",
            JOptionPane.WARNING_MESSAGE);
        return;
      }
      fileChooser.setFileFilter(filter);
      int option = fileChooser.showSaveDialog(this);
      if (option == JFileChooser.APPROVE_OPTION) {
        File target = fileChooser.getSelectedFile();
        if (target.getName().indexOf(".scl") == -1) target = new File(target.getPath() + ".scl");
        try {
          PrintStream stream = new PrintStream(new FileOutputStream(target), true);
          save(stream);
          stream.close();
        } catch (Exception ex) {
          JOptionPane.showMessageDialog(
              this, new JLabel("Error: " + ex.getMessage()), "Error", JOptionPane.ERROR_MESSAGE);
        }
      }
    } else if (b.getText() == "Load") {
      try {
        saveUnsaved();
      } catch (SaveAbortedException ex) {
        return;
      }

      fileChooser.setFileFilter(filter);
      int option = fileChooser.showOpenDialog(this);
      if (option == JFileChooser.APPROVE_OPTION) {
        loadedFile = fileChooser.getSelectedFile();
        SAXParserFactory factory = SAXParserFactory.newInstance();
        ScaleParser handler = new ScaleParser(false);
        try {
          SAXParser parser = factory.newSAXParser();
          parser.parse(loadedFile, handler);
          // System.out.println("success");
        } catch (Exception ex) {
          // System.out.println("no!!!!!! exception: "+e);
          // System.out.println(ex.getMessage());
          ex.printStackTrace();
        }
        // -----now :P:P---------------
        System.out.println("name: " + handler.getName());
        nameTF.setText(handler.getName());
        sp.notes.removeAllElements();
        int[] scale = handler.getScale();
        for (int i = 0; i < scale.length; i++) {
          sp.addNote(scale[i]);
        }
        sp.repaint();
      } else loadedFile = null;
    }
  }