public void search() {
    hilit.removeAllHighlights();

    String s = entry.getText();
    if (s.length() <= 0) {
      message("Nothing to search");
      return;
    }

    String content = textArea.getText();
    int index = content.indexOf(s, 0);
    if (index >= 0) {
      try {
        int end = index + s.length();
        hilit.addHighlight(index, end, painter);
        textArea.setCaretPosition(end);
        entry.setBackground(entryBg);
        message("'" + s + "' found. Press ESC to end search");
      } catch (BadLocationException e) {
        e.printStackTrace();
      }
    } else {
      entry.setBackground(ERROR_COLOR);
      message("'" + s + "' found. Press ESC to start a new search");
    }
  }
 @Override
 protected JComponent updateWidget() {
   Long val = getValue();
   if (val == null) widget.setText("");
   else widget.setText(val + "");
   return widget;
 }
  private Component createTabDisabled() {
    JPanel panel = new JPanel(new MigLayout("fill, wrap 1"));

    final JTextField textField = new JTextField();
    final JCheckBox checkBox = new JCheckBox("Enabled");
    checkBox.setSelected(true);
    panel.add(checkBox);
    checkBox.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent actionEvent) {
            textField.setEnabled(checkBox.isSelected());
          }
        });

    panel.add(textField);
    textField.setColumns(15);

    on(new JTextFieldDocumentChangedTrigger(textField)) //
        .read(new JTextFieldTextProvider(textField)) //
        .check(new StringNotEmptyRule()) //
        .handleWith(new IconBooleanFeedback(textField, "Cannot be empty")) //
        .trigger();

    return panel;
  }
Esempio n. 4
0
  private void onCreateNewAuctionClicked() {
    try {
      int startingPrice;
      String description = txtDescription.getText();

      if (txtStartingPrice.getText().equals("")) {
        startingPrice = 0;
      } else {
        startingPrice = Integer.parseInt(txtStartingPrice.getText());
      }

      // Get a reference to an inactive auction from the auction manager.
      String auctionRef = auctionFactoryImpl.getInactiveAuction();

      // resolve the Object Reference in Naming
      Auction auctionImpl = AuctionHelper.narrow(ncRef.resolve_str(auctionRef));

      // Put an item up for sale
      auctionImpl.offerItem(userName, description, startingPrice);

      // Update the auction lists
      updateAuctionLists(false);

      appletDisplay("Started new auction");

    } catch (NumberFormatException e1) {
      appletDisplay("Invalid starting price");
    } catch (AuctionFailure e2) {
      appletDisplay(e2.description);
    } catch (Exception e3) {
      appletDisplay("Unable to create a new auction");
      System.out.println("ERROR : " + e3);
      e3.printStackTrace(System.out);
    }
  }
Esempio n. 5
0
  public RFIDGUI() {

    setLayout(new FlowLayout());
    // label = new JTextField(ThreadTwoTestTwo.randomQuestionStatement);
    Question.setFont(new Font("Serif", Font.BOLD, 18));
    // Points.setFont(new Font("Serif", Font.BOLD, 50));
    // Question.setBounds(300, 250, 900, 300);
    // Points.setBounds(1200, 600, 300, 200);

    // Points.setHorizontalAlignment(JTextField.RIGHT);
    // Points.set
    Question.setForeground(Color.blue);
    // Points.setForeground(Color.red);
    add(Question);
    // Question.validate();
    // add(Points, BorderLayout.SOUTH);
    // Points.validate();
    // Question.setLocation(0, 0);
    // Points.setLocation(1600,900);

    /*while(count<70){
    //secondDoneYet = false;
    while (!secondDoneYet) {
    	//label = new JTextField(ThreadTwoTestTwo.randomQuestionStatement);
    	label.repaint();
    	secondDoneYet = true;
    	count++;

    	/*
    	 * while(ThreadTwoTestTwo.amountOfQuestions <=60){
    	 * label.repaint(); }
    	 */
  }
  /**
   * Change internal settings based on what was chosen in the prefs, then send a message to the
   * editor saying that it's time to do the same.
   */
  public void applyFrame() {
    // put each of the settings into the table
    String newSizeText = fontSizeField.getText();
    try {
      int newSize = Integer.parseInt(newSizeText.trim());
      String fontName = Base.preferences.get("editor.font", "Monospaced,plain,12");
      if (fontName != null) {
        String pieces[] = fontName.split(",");
        pieces[2] = String.valueOf(newSize);
        StringBuffer buf = new StringBuffer();
        for (String piece : pieces) {
          if (buf.length() > 0) buf.append(",");
          buf.append(piece);
        }
        Base.preferences.put("editor.font", buf.toString());
      }

    } catch (Exception e) {
      Base.logger.warning("ignoring invalid font size " + newSizeText);
    }
    String origUpdateUrl = Base.preferences.get("replicatorg.updates.url", "");
    if (!origUpdateUrl.equals(firmwareUpdateUrlField.getText())) {
      FirmwareUploader.invalidateFirmware();
      Base.preferences.put("replicatorg.updates.url", firmwareUpdateUrlField.getText());
      FirmwareUploader.checkFirmware(); // Initiate a new firmware check
    }

    String logPath = logPathField.getText();
    Base.preferences.put("replicatorg.logpath", logPath);
    Base.setLogFile(logPath);

    editor.applyPreferences();
  }
 public void setEditable(boolean isEditable) {
   isEditable_ = isEditable;
   if (inputType_.equals("ALPHA") || inputType_.equals("KANJI") || inputType_.equals("NUMERIC")) {
     ((JTextField) component).setEditable(isEditable_);
     ((JTextField) component).setFocusable(isEditable_);
   }
   if (inputType_.equals("DATE")) {
     ((XFDateField) component).setEditable(isEditable_);
     ((XFDateField) component).setFocusable(isEditable_);
     int fieldWidth = XFUtility.getWidthOfDateValue(dialog_.getSession().getDateFormat(), 14);
     if (isEditable_) {
       this.setBounds(
           this.getBounds().x, this.getBounds().y, 150 + fieldWidth, XFUtility.FIELD_UNIT_HEIGHT);
     } else {
       this.setBounds(
           this.getBounds().x, this.getBounds().y, 124 + fieldWidth, XFUtility.FIELD_UNIT_HEIGHT);
     }
   }
   if (inputType_.equals("LISTBOX")) {
     ((JComboBox) component).setEditable(isEditable_);
     ((JComboBox) component).setFocusable(isEditable_);
   }
   if (inputType_.equals("CHECKBOX")) {
     ((JCheckBox) component).setEnabled(isEditable_);
     ((JCheckBox) component).setFocusable(isEditable_);
   }
 }
Esempio n. 8
0
  public static void main(String[] args) {
    final Browser browser = new Browser();
    BrowserView browserView = new BrowserView(browser);

    final JTextField addressBar = new JTextField("http://www.teamdev.com/jxbrowser");
    addressBar.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            browser.loadURL(addressBar.getText());
          }
        });

    JPanel addressPane = new JPanel(new BorderLayout());
    addressPane.add(new JLabel(" URL: "), BorderLayout.WEST);
    addressPane.add(addressBar, BorderLayout.CENTER);

    JFrame frame = new JFrame("JxBrowser - Hello World");
    frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    frame.add(addressPane, BorderLayout.NORTH);
    frame.add(browserView, BorderLayout.CENTER);
    frame.setSize(800, 500);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);

    browser.loadURL(addressBar.getText());
  }
  /** Loads the default settings from Preferences to set up the dialog. */
  public void legacyLoadDefaults() {
    String defaultsString = Preferences.getDialogDefaults(getDialogName());

    if ((defaultsString != null) && (newImage != null)) {

      try {
        StringTokenizer st = new StringTokenizer(defaultsString, ",");

        textSearchWindowSide.setText("" + MipavUtil.getInt(st));
        textSimilarityWindowSide.setText("" + MipavUtil.getInt(st));
        textNoiseStandardDeviation.setText("" + MipavUtil.getFloat(st));
        textDegree.setText("" + MipavUtil.getFloat(st));
        doRician = MipavUtil.getBoolean(st);
        doRicianCheckBox.setSelected(doRician);
        textDegree.setEnabled(doRician);
        labelDegree.setEnabled(doRician);
        image25DCheckBox.setSelected(MipavUtil.getBoolean(st));

        if (MipavUtil.getBoolean(st)) {
          newImage.setSelected(true);
        } else {
          replaceImage.setSelected(true);
        }

      } catch (Exception ex) {

        // since there was a problem parsing the defaults string, start over with the original
        // defaults
        Preferences.debug("Resetting defaults for dialog: " + getDialogName());
        Preferences.removeProperty(getDialogName());
      }
    }
  }
  /**
   * Closes dialog box when the OK button is pressed, sets variables and calls algorithm.
   *
   * @param event Event that triggers function.
   */
  public void actionPerformed(ActionEvent event) {
    String command = event.getActionCommand();
    Object source = event.getSource();

    if (command.equals("OK")) {

      if (setVariables()) {
        callAlgorithm();
      }
    } else if (command.equals("Cancel")) {
      dispose();
    } else if (command.equals("Help")) {
      // MipavUtil.showHelp("");
    } else if (source.equals(doRicianCheckBox)) {
      if (doRicianCheckBox.isSelected()) {
        labelDegree.setEnabled(true);
        textDegree.setEnabled(true);
      } else {
        labelDegree.setEnabled(false);
        textDegree.setEnabled(false);
      }
    } else { // else if (source == thresholdCheckbox)
      super.actionPerformed(event);
    }
  }
  /**
   * Simple test.
   *
   * @author nschuste
   * @version 1.0.0
   * @throws InterruptedException
   * @since Feb 23, 2016
   */
  @Test(timeout = 10000)
  public void test() throws InterruptedException {
    final Map<String, Object> mp = new HashMap<>();
    mp.put("abc", new TextDispatcher());
    Mockito.when(this.context.getBeansWithAnnotation(Matchers.any())).thenReturn(mp);
    final JFrame frame = new JFrame();
    final JTextField b = new JTextField();
    b.setName("xyz");
    final JButton c = new JButton();
    c.setName("cc");
    frame.getContentPane().add(b);
    frame.getContentPane().add(c);
    frame.pack();
    frame.setVisible(true);
    final JTextComponentFixture fix = new JTextComponentFixture(this.r, "xyz");
    final JButtonFixture fix2 = new JButtonFixture(this.r, "cc");
    this.dispatcher.initialize(this.lstr);
    final ArgumentCaptor<TestCaseStep> captor = ArgumentCaptor.forClass(TestCaseStep.class);
    fix.enterText("hello");
    fix2.focus();
    try {
      SwingUtilities.invokeAndWait(() -> {});

    } catch (final InvocationTargetException e) {
      e.printStackTrace();
    }
    Mockito.verify(this.lstr, Mockito.times(1)).event(captor.capture());
    final TestCaseStep capt = captor.getValue();
    Assert.assertEquals(capt.getMethodName(), "text.enter");
    Assert.assertEquals(capt.getArgs().length, 2);
    Assert.assertEquals(capt.getArgs()[0], "xyz");
    Assert.assertEquals(capt.getArgs()[1], "hello");
  }
  public void test_textField_multiple() {
    JTextField field = new JTextField();
    field.setName("myfield");

    list.addEvent(newGuiEvent(GuiEventType.KEY, field, "une v"));
    list.addEvent(newGuiEvent(GuiEventType.KEY, field, "une va"));
    list.addEvent(newGuiEvent(GuiEventType.KEY, field, "une vap"));
    list.addEvent(newGuiEvent(GuiEventType.KEY, field, "une va"));
    list.addEvent(newGuiEvent(GuiEventType.KEY, field, "une val"));
    list.addEvent(newGuiEvent(GuiEventType.KEY, field, "une valeur"));

    setValueGesture.receive(list, result);
    assertEquals("Un event est consommé", 5, list.size());
    assertEquals("<setValue name=\"myfield\" value=\"une v\"/>", result.toXml());

    setValueGesture.receive(list, result);
    assertEquals("Un event est consommé", 4, list.size());
    assertEquals("<setValue name=\"myfield\" value=\"une va\"/>", result.toXml());

    setValueGesture.receive(list, result);
    setValueGesture.receive(list, result);
    setValueGesture.receive(list, result);
    setValueGesture.receive(list, result);
    assertEquals("Les events sont consommés", 0, list.size());
    assertEquals("<setValue name=\"myfield\" value=\"une valeur\"/>", result.toXml());
  }
  void store(WizardDescriptor d) {
    String name = projectNameTextField.getText().trim();
    String folder = createdFolderTextField.getText().trim();

    d.putProperty("projdir", new File(folder));
    d.putProperty("name", name);
  }
Esempio n. 14
0
  /** Erzeugt ein neues Objekt dieser Klasse */
  public SimpleJFrame() {

    /* Panel als Contentpane erzeugen. */
    JPanel panel = new JPanel();
    panel.setLayout(null);
    this.setContentPane(panel);

    JTextField textField = new JTextField(20);
    textField.setBounds(200, 400, 100, 30);
    panel.add(textField);

    panel.setFocusable(true);

    panel.requestFocusInWindow();

    panel.addKeyListener(this);

    /* Irgendwo muessen wir die Buttons referenzieren.. */
    JButton[] buttons = new JButton[5];

    for (int i = 0; i < buttons.length; i++) {

      /* Button mit dynamischer Position und fester Groesse erzeugen. */
      buttons[i] = new JButton(i + ". Button");
      buttons[i].setBounds(i * 110, i * 110, 100, 100);

      panel.add(buttons[i]);
    }

    /* Statische Fenster-Groesse. */
    this.setSize(800, 600);
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    this.setVisible(true);
  }
Esempio n. 15
0
  public FloatInput(String var, float _value, String _label) {
    variable = var;
    value = _value;

    setLayout(new BorderLayout(5, 5));

    label = new JLabel(_label);

    add(label, BorderLayout.WEST);

    int defValue = (int) (_value * 100);

    slider = new JSlider(SwingConstants.HORIZONTAL, 0, 100, defValue);
    slider.setMajorTickSpacing(25);
    slider.setMinorTickSpacing(5);
    slider.setPaintTicks(true);
    slider.setPaintLabels(false);

    slider.addChangeListener(this);

    add(slider, BorderLayout.CENTER);

    text = new JTextField();
    text.setEditable(false);
    text.setColumns(4);

    refresh();

    JPanel temp = new JPanel();
    temp.setLayout(new FlowLayout(FlowLayout.CENTER));

    temp.add(text);

    add(temp, BorderLayout.EAST);
  }
Esempio n. 16
0
  private boolean validatePreco(JTextField tfdPreco, String name) {
    String preco = tfdPreco.getText().trim();

    if (preco.equals("")) {
      msg("Por favor, informe um preço de " + name + " para produto.");
      tfdPreco.grabFocus();
      return false;
    }

    if (!isDouble(preco)) {
      msg(
          "O sistema trabalha com o padrão americano para valores,\n"
              + "por isso é necessário substituir a vírgula \",\" por um ponto \".\"\n"
              + "para separar os centavos."
              + "Exemplos: 45.23  58.25  100");
      tfdPreco.grabFocus();
      return false;
    }

    if (Double.parseDouble(preco) <= 0) {
      msg("O preço de " + name + " do produto deve ser igual ou superior a zero.");
      tfdPreco.grabFocus();
      return false;
    }

    return true;
  }
Esempio n. 17
0
  /**
   * Handles a click event. If the blocked user list is updated as a result the proxy will respond
   * with the new list asynchronously.
   *
   * @param actionCommand the action performed by the user
   */
  private void clickHandler(Object actionCommand) {
    System.out.println(
        "Received command: " + actionCommand + "\tText = " + blockTextField.getText());

    if (actionCommand.equals(CMD_BLOCK)) {
      String blocked = blockTextField.getText();
      if (blocked == null || "".equals(blocked)) {
        JOptionPane.showMessageDialog(
            this, "You must provide the username of the user to be blocked.");
        return;
      } else if (!isAlphaNumeric(blocked)) {
        JOptionPane.showMessageDialog(this, "The username must be alphanumeric");
        return;
      }
      try {
        blockingProcessing.processBlock(blocked);
      } catch (CommunicationsException e) {
        JOptionPane.showMessageDialog(this, "Unable to send the block request. (T__T)");
      }
    } else if (actionCommand.equals(CMD_UNBLOCK)) {
      String unblocked = blockedList.getSelectedValue();
      if (unblocked == null || "".equals(unblocked)) {
        JOptionPane.showMessageDialog(this, "Please select the user to be unblocked.");
        return;
      }
      try {
        blockingProcessing.processUnblock(unblocked);
      } catch (CommunicationsException e) {
        JOptionPane.showMessageDialog(this, "Unable to process block request. (T__T)");
      }
    }
  }
Esempio n. 18
0
    private JTabbedPane createTab() {
      Font mainFont = new Font("Times New Roman", Font.BOLD, 11);
      tabbedPane.setFont(mainFont);
      tabbedPane.setBorder(new BevelBorder(BevelBorder.LOWERED));

      tabbedPane.add("New application", new NewAppPanel());

      JPanel existingApp = new JPanel();
      existingApp.setLayout(new BoxLayout(existingApp, BoxLayout.X_AXIS));
      JLabel pictureLabel = new JLabel("Configuration:");
      JButton pictureChooser = new JButton("Choose");

      pictureFileName.setEditable(false);
      pictureFileName.setMaximumSize(new Dimension(contentPane.getPreferredSize().width, 25));
      existingApp.add(Box.createHorizontalStrut(20));
      existingApp.add(pictureLabel);
      existingApp.add(pictureFileName);
      existingApp.add(Box.createHorizontalStrut(5));
      existingApp.add(pictureChooser);
      existingApp.add(Box.createHorizontalStrut(20));
      pictureChooser.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              loadFromFile();
            }
          });
      tabbedPane.add("Existing application", existingApp);
      tabbedPane.setPreferredSize(contentPane.getPreferredSize());

      return tabbedPane;
    }
  public void saveSettings() {
    datPath = path0.getText();
    dirPath = path1.getText();
    libPath = path2.getText();
    top = (Integer) spin.getValue();
    location = loc.getSelectedIndex();
    every = all.isSelected();
    filesys = choice.getSelectedIndex();
    rec = choice2.getSelectedIndex();

    config.setDatabasePath(datPath);
    config.setMusicLibraryPath(dirPath);
    config.setItunesLibraryPath(libPath);
    config.setTopArtists(top + "");
    config.setTopArtists(location + "");
    config.setScanFile(filesys + "");
    config.setScanRec(rec + "");

    if (every) config.setAllEvents("true");
    else config.setAllEvents("false");

    config.setEmailEnabled(emailNotificationEnabled.isSelected());
    config.setEmailAddress(usernameField.getText());
    config.setEmailPass(passwordField.getText());

    config.writePreferences();
  }
  private void refreshContents(String environment) {
    MDFClientConfigRepository repository =
        MDFClientConfigurator.getInstance().getConfigRepository();

    MDFClientEnvConfigRepository envConfig = repository.getConfig(environment);

    textTcpAddress.setText(envConfig.getTcpInfo().getEndPointInfo().getDisplayable());
    userName.setPreferredSize(fieldSize);
    password.setPreferredSize(fieldSize);
    userName.setText(envConfig.getTcpInfo().getUserName());
    password.setText(envConfig.getTcpInfo().getPassword());

    /*
    String networkInterface=repository.getMDFClientRuntimeParameters().getMulticastNetworkInterface();

    if(networkInterface!=null)
    {
    	textMulticastNetworkInterface.setText(networkInterface);
    }
    else
    {
    	textMulticastNetworkInterface.setText("<default>");
    }

    textSequenceProblemAction.setText(repository.getMDFClientRuntimeParameters().getSequenceProblemAction().getAction());
    textMulticastInactivityThreshold.setText(Integer.toString(repository.getMDFClientRuntimeParameters().getMulticastInactivityThreshold()));
    */

    return;
  }
Esempio n. 21
0
 private void updateDisplay() {
   if (scale == null) {
     fileNameField.setText("");
   } else {
     fileNameField.setText(scale.getScaleName());
   }
 }
Esempio n. 22
0
 private Factura getNewFactura() {
   return new Factura(
       fecha,
       txtBono.getText(),
       Integer.parseInt((txtValor.getText().equals("")) ? "0" : txtValor.getText()),
       0);
 }
  private JPanel createBrowsePanel() {
    JPanel browsePanel = new JPanel(new BorderLayout());
    final JTextField directoryText = new JTextField();
    directoryText.setEditable(false);
    browsePanel.add(directoryText, BorderLayout.CENTER);
    JButton browseButton = new JButton("Browse...");
    browsePanel.add(browseButton, BorderLayout.EAST);

    browseButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            JFileChooser chooser = new JFileChooser();
            chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
            int retval = chooser.showSaveDialog(CreateThematicMapDialog.this);
            if (retval == JFileChooser.APPROVE_OPTION) {
              File selectedFile = chooser.getSelectedFile();
              directoryText.setText(selectedFile.getPath());
              evaluateFile = selectedFile;
            }
          }
        });

    Collections.<Component>addAll(evaluateEnablement, directoryText, browseButton);

    return browsePanel;
  }
  public MyGUIProgram() {
    super("Swing app");
    setSize(400, 300);
    setResizable(true);

    fileLocationField.setPreferredSize(new Dimension(150, 20));
    p.add(fileLocationField);
    p.add(fileLocationLabel);

    phoneNumberField.setPreferredSize(new Dimension(150, 20));
    p.add(phoneNumberField);
    p.add(phoneNumberLabel);

    operationField.setPreferredSize(new Dimension(150, 20));
    p.add(operationField);
    p.add(operationLabel);

    b.addActionListener(new MyActionListner(this));
    p.add(b);

    output.setEditable(false);
    p.add(output);

    add(p);

    setVisible(true);
  }
Esempio n. 25
0
  /** Create the frame. */
  public DeleteBlank() {
    setTitle("\u53BB\u6389\u5B57\u7B26\u4E32\u4E2D\u7684\u6240\u6709\u7A7A\u683C");
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setBounds(100, 100, 386, 128);
    contentPane = new JPanel();
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    setContentPane(contentPane);
    contentPane.setLayout(null);

    JLabel label = new JLabel("\u8F93\u5165\u5B57\u7B26\u4E32\uFF1A");
    label.setBounds(21, 10, 75, 15);
    contentPane.add(label);

    JButton button = new JButton("\u53BB\u9664\u7A7A\u683C");
    button.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            do_button_actionPerformed(e);
          }
        });
    button.setBounds(10, 49, 82, 23);
    contentPane.add(button);

    textField = new JTextField();
    textField.setBounds(102, 2, 258, 30);
    contentPane.add(textField);
    textField.setColumns(10);

    resultField = new JTextField();
    resultField.setBounds(102, 45, 258, 30);
    contentPane.add(resultField);
    resultField.setColumns(10);
  }
Esempio n. 26
0
  private void onOK() {
    if (!isValidInput()) {
      return;
    }
    dispose();
    String firstName = firstNameField.getText().trim();
    String lastName = lastNameField.getText().trim();
    String emailAddress = emailAddressField.getText().trim();
    SexOfPerson sexOfPerson;
    if (femaleRadioButton.isSelected()) {
      sexOfPerson = SexOfPerson.FEMALE;
    } else {
      sexOfPerson = SexOfPerson.MALE;
    }
    String country = (String) countryComboBox.getSelectedObject();
    Integer birthdayYear = (Integer) birthdayYearComboBox.getSelectedItem();
    Month birthdayMonth = (Month) birthdayMonthComboBox.getSelectedItem();
    Integer birthdayDay = (Integer) birthdayDayComboBox.getSelectedItem();
    char[] passwordArr = passwordField.getPassword();
    String password = new String(passwordArr);
    Arrays.fill(passwordArr, (char) 0);
    Image profilePicture = null;
    if (imageFromFileRadioButton.isSelected()) {
      if (fileSelector.getFilePath() != null) {
        profilePicture = new FileImage(fileSelector.getFilePath());
      }
    }
    Request request =
        new CreateUserRequest(
            communicator.getHttpClient(),
            frame,
            firstName,
            lastName,
            emailAddress,
            sexOfPerson,
            country,
            birthdayYear,
            birthdayMonth,
            birthdayDay,
            password,
            profilePicture) {

          @Override
          protected void onCreateUser(String status, Person person) {
            if (status.equals("INVALID_PROFILE_PICTURE")) {
              communicator.promptForCreateAccount("Invalid profile picture");
            } else if (status.equals("ERROR_CREATING_USER")) {
              communicator.promptForCreateAccount("Error creating user");
            } else if (status.equals("CONNECTION_ERROR")) {
              communicator.promptForCreateAccount("Error connecting to Modeling Commons");
            } else if (status.equals("SUCCESS")) {
              communicator.setPerson(person);
              communicator.promptForUpload();
            } else {
              communicator.promptForCreateAccount("Unknown server error");
            }
          }
        };
    request.execute();
  }
Esempio n. 27
0
 @Override
 public void layoutView() {
   textField.setPreferredSize(
       new Dimension(UIConstants.widgetWidth(), UIConstants.maximumTextFieldHeight()));
   textField.setMaximumSize(
       new Dimension(UIConstants.widgetWidth(), UIConstants.maximumTextFieldHeight()));
 }
Esempio n. 28
0
  private void setNumericalValues() throws ParseException {
    perc = new int[PERCENT_MAX];

    // decimalFormat manage the localization.
    DecimalFormat decimalFormat = new DecimalFormat(format);

    if (!generateRandomPopTextRow.getText().equals("")) {
      perc[PERCENT_RANDOM] =
          (int)
              Math.round(
                  PERCENT_DOUBLE
                      * (decimalFormat.parse(generateRandomPopTextRow.getText()).doubleValue()));
    } else {
      perc[PERCENT_RANDOM] = 0;
    }
    if (!generateInitPopTextRow.getText().equals("")) {
      perc[PERCENT_INIT_POP] =
          (int)
              Math.round(
                  PERCENT_DOUBLE
                      * (decimalFormat.parse(generateInitPopTextRow.getText()).doubleValue()));
    } else {
      perc[PERCENT_INIT_POP] = 0;
    }
  }
  private Component createTabSplitPane() {
    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);

    JPanel panel = new JPanel(new MigLayout("fill"));
    splitPane.setTopComponent(panel);
    JTextField textField = new JTextField();
    textField.setColumns(15);
    panel.add(textField);

    on(new JTextFieldDocumentChangedTrigger(textField)) //
        .read(new JTextFieldTextProvider(textField)) //
        .check(new StringNotEmptyRule()) //
        .handleWith(new IconBooleanFeedback(textField)) //
        .trigger();

    panel = new JPanel(new MigLayout("fill"));
    splitPane.setBottomComponent(panel);
    textField = new JTextField();
    textField.setColumns(15);
    panel.add(textField);

    on(new JTextFieldDocumentChangedTrigger(textField)) //
        .read(new JTextFieldTextProvider(textField)) //
        .check(new StringNotEmptyRule()) //
        .handleWith(new IconBooleanFeedback(textField)) //
        .trigger();

    return splitPane;
  }
Esempio n. 30
0
 public void show() {
   draw_font_ =
       new DrawSWFFont(
           text_field_.getFont(), effect_, text_field_.getText(), color_button_.getColor());
   color_button_.addChangeListener(self_);
   super.show();
 }