Example #1
0
  SMBPanel(ServerConnectDialog dialog, MainFrame mainFrame) {
    super(dialog, mainFrame);

    // Server field
    serverField = new JTextField(lastServer);
    serverField.selectAll();
    addTextFieldListeners(serverField, true);
    addRow(Translator.get("server_connect_dialog.server"), serverField, 5);

    // Share field
    shareField = new JTextField(lastShare);
    shareField.selectAll();
    addTextFieldListeners(shareField, true);
    addRow(Translator.get("server_connect_dialog.share"), shareField, 15);

    // Domain field
    domainField = new JTextField(lastDomain);
    domainField.selectAll();
    addTextFieldListeners(domainField, true);
    addRow(Translator.get("server_connect_dialog.domain"), domainField, 15);

    // Username field
    usernameField = new JTextField(lastUsername);
    usernameField.selectAll();
    addTextFieldListeners(usernameField, false);
    addRow(Translator.get("server_connect_dialog.username"), usernameField, 5);

    // Password field
    passwordField = new JPasswordField();
    addTextFieldListeners(passwordField, false);
    addRow(Translator.get("password"), passwordField, 0);
  }
Example #2
0
  // Invoked when <Enter> is pressed
  public void actionPerformed(ActionEvent e) {
    FCConverter fc = new FCConverter();

    if ((JTextField) e.getSource() == displayF) {
      // Fahrenheit to Celsius
      double degrees = stringToDouble(displayF.getText());
      if (!Double.isNaN(degrees)) {
        fc.setFahrenheit(degrees);
        degrees = fc.getCelsius();
        displayC.setText(String.format("%1.1f", degrees));
      } else {
        displayF.selectAll();
      }
    } else {
      // Celsius to Fahrenheit
      double degrees = stringToDouble(displayC.getText());
      if (!Double.isNaN(degrees)) {
        fc.setCelsius(degrees);
        degrees = fc.getFahrenheit();
        displayF.setText(String.format("%1.1f", degrees));
      } else {
        displayC.selectAll();
      }
    }
  }
Example #3
0
  /* Sjekker om scannet kort finnes og om det er gyldig,
  og skriver ut om scanningen var gyldig/ugyldig */
  private void sjekk() {
    vindu.getSelgerMetoder().setAktivTilKontroll();
    try {
      int nr = Integer.parseInt(kortid.getText());
      Boolean ok = aktivkortreg.sjekkGyldig(nr);
      if (ok) {
        info.setText("\n\n                       Gyldig");
        info.setBackground(Color.GREEN);
        if (scan(ok)) aktivkortreg.fjernKlipp(nr);

        kortid.setText("");
        kortid.selectAll();
        resetFocus();
      } else {
        info.setText("\n\n                    Ikke gyldig");
        info.setBackground(Color.RED);
        scan(ok);
        kortid.setText("");
        kortid.selectAll();
        resetFocus();
      }

      aktivkortreg.oppdater();
      vindu.oppdaterInfoPanel();
    } catch (NumberFormatException e) {
      info.setText("\n\n                    Kun tall...");
      kortid.setText("");
      timer.schedule(new Tick(), timersec * 500);
      return;
    }
  }
 public void setTemplate(FileTemplate template, URL defaultDescription) {
   myDefaultDescriptionUrl = defaultDescription;
   myTemplate = template;
   if (myMainPanel != null) {
     reset();
     myNameField.selectAll();
     myExtensionField.selectAll();
   }
 }
Example #5
0
 @Override
 public void keyPressed(KeyEvent e) {
   if (e.getKeyChar() == KeyEvent.VK_ENTER) {
     if (currentTF.getText().trim().isEmpty()) {
       currentTF.selectAll();
       return;
     } else if (nextTF.getText().trim().isEmpty()) {
       nextTF.requestFocusInWindow();
       nextTF.selectAll();
       return;
     } else {
       OKAction okAction = owner.new OKAction();
       okAction.actionPerformed(null);
     }
   }
 }
 /**
  * Component initialization.
  *
  * @throws java.lang.Exception
  */
 private void initialize() {
   setSize(new Dimension(420, 100));
   this.setContentPane(getJpnlMain());
   setTitle("Login");
   jtxtUserName.grabFocus();
   jtxtUserName.selectAll();
 }
Example #7
0
  /**
   * Clears and focuses the search field if it is not focused. Otherwise, cycles to the next search
   * type.
   */
  public void startSearch() {
    if (increment.isSelected() && incSearch) {
      repeatIncremental();
      return;
    }
    if (!searchField.hasFocus()) {
      // searchField.setText("");
      searchField.selectAll();
      searchField.requestFocus();
    } else {
      if (increment.isSelected()) {
        floatSearch.setSelected(true);
      } else if (floatSearch.isSelected()) {
        hideSearch.setSelected(true);
      } else if (hideSearch.isSelected()) {
        showResultsInDialog.setSelected(true);
      } else if (showResultsInDialog.isSelected()) {
        searchAllBases.setSelected(true);
      } else {
        increment.setSelected(true);
      }
      increment.revalidate();
      increment.repaint();

      searchField.requestFocus();
    }
  }
Example #8
0
 @Override
 public void focusGained(FocusEvent e) {
   if (e.getSource() instanceof JTextField) {
     JTextField tf = (JTextField) e.getSource();
     tf.selectAll();
   }
 }
 @Override
 public void actionPerformed(ActionEvent evt) {
   String text = textField.getText();
   if (text.length() > 0) {
     _bot.rawLine(text);
     textField.selectAll();
   }
 }
Example #10
0
 @Override
 public Component prepareEditor(TableCellEditor tableCellEditor, int row, int column) {
   Component c = super.prepareEditor(tableCellEditor, row, column);
   if (c instanceof JTextComponent) {
     ((JTextField) c).selectAll();
   }
   return c;
 }
Example #11
0
  public void actionPerformed(ActionEvent evt) {
    String text = textField.getText();
    textArea.append(text + newline);
    textField.selectAll();

    // Make sure the new text is visible, even if there
    // was a selection in the text area.
    textArea.setCaretPosition(textArea.getDocument().getLength());
  }
  /** affiche un textfield */
  void modeTextField() {

    remove(label);
    repaint();
    add(textField, BorderLayout.SOUTH);
    textField.selectAll();
    textField.requestFocus();
    repaint();
  }
 public void do_pass(Sales_orders.to_sales_items my_order) {
   jTextArea1.setText(my_order.description);
   jTextField6.setText(FitIn.fmt_wc_0(my_order.selling_price));
   jTextField4.setText(FitIn.fmt_woc(my_order.product_qty));
   jTextField1.setText(my_order.item_discount);
   jTextField2.setText(FitIn.fmt_wc_0(my_order.discount_amount));
   jTextField3.setText(FitIn.fmt_wc_0(my_order.discount));
   jTextField4.grabFocus();
   jTextField4.selectAll();
 }
 /**
  * This will be called when the user clicks the "Send" button or presses return in the text-input
  * box. It posts the contents of the input box to the transcript. If the thread is not running, it
  * creates and starts a new thread.
  */
 public void actionPerformed(ActionEvent evt) {
   postMessage("SENT: " + input.getText());
   input.selectAll();
   input.requestFocus();
   if (running == false) {
     runner = new Thread(this);
     running = true;
     runner.start();
   }
 }
  @Override
  protected JComponent createNorthPanel() {
    String currentName = myLibraryRootsComponent.getLibraryEditor().getName();
    myNameField = new JTextField(currentName);
    myNameField.selectAll();

    FormBuilder formBuilder =
        FormBuilder.createFormBuilder().addLabeledComponent("&Name:", myNameField);
    addNorthComponents(formBuilder);
    return formBuilder.addVerticalGap(10).getPanel();
  }
Example #16
0
  public void actionPerformed(ActionEvent evt) {
    String text = textField.getText();

    try {
      handleInput(text);
    } catch (SqlJetException sqle1) {
      sqle1.printStackTrace();
      MUSGuiImproved.appendLine("SqlException from SQLAdapter print_test();");
    }
    textField.selectAll();
  }
Example #17
0
  public boolean toggle() {
    boolean visible = !isVisible();
    setVisible(visible);

    if (visible) {
      searchField.requestFocus();
      searchField.selectAll();
    } else {
      rTextArea.requestFocus();
    }
    return visible;
  }
Example #18
0
 @Override
 public Component getTableCellEditorComponent(
     JTable table, Object value, boolean isSelected, int row, int column) {
   if (value != null) {
     textField.setText(value.toString());
   } else {
     textField.setText("");
   }
   textField.selectAll();
   textField.setBackground(CellEditor.BG_COLOR);
   return textField;
 }
        @Override
        public void focusGained(FocusEvent e) {
          if (e.getOppositeComponent() != null) {
            JTextField valueTextField = editorComponent.getTextField();
            DataEditorSettings settings = cell.getRow().getModel().getSettings();
            if (settings.getGeneralSettings().getSelectContentOnCellEdit().value()) {
              valueTextField.selectAll();
            }

            Rectangle rectangle = new Rectangle(mainPanel.getLocation(), mainPanel.getSize());
            parentForm.getColumnsPanel().scrollRectToVisible(rectangle);
          }
        }
Example #20
0
  /** This method reacts to state changes in the option pane. */
  public void propertyChange(PropertyChangeEvent e) {
    String prop = e.getPropertyName();

    if (isVisible()
        && (e.getSource() == optionPane)
        && (JOptionPane.VALUE_PROPERTY.equals(prop)
            || JOptionPane.INPUT_VALUE_PROPERTY.equals(prop))) {
      Object value = optionPane.getValue();

      if (value == JOptionPane.UNINITIALIZED_VALUE) {
        // ignore reset
        return;
      }

      // Reset the JOptionPane's value.
      // If you don't do this, then if the user
      // presses the same button next time, no
      // property change event will be fired.
      optionPane.setValue(JOptionPane.UNINITIALIZED_VALUE);

      if (btnString1.equals(value)) {
        typedText = textField1.getText();
        String ucText = typedText.toUpperCase();
        if (magicWord.equals(ucText)) {
          // we're done; clear and dismiss the dialog
          clearAndHide();
        } else {
          // text was invalid
          textField1.selectAll();
          JOptionPane.showMessageDialog(
              iRuleDialog.this,
              "Sorry, \""
                  + typedText
                  + "\" "
                  + "isn't a valid response.\n"
                  + "Please enter "
                  + magicWord
                  + ".",
              "Try again",
              JOptionPane.ERROR_MESSAGE);
          typedText = null;
          textField1.requestFocusInWindow();
        }
      } else { // user closed dialog or clicked cancel
        mainGuiWindow.setLabel("It's OK.");
        typedText = null;
        clearAndHide();
      }
    }
  }
  public AndroidAppPropertiesEditor(String moduleName, ModulesProvider modulesProvider) {
    myModulesProvider = modulesProvider;

    String defaultAppName = moduleName != null ? moduleName : "myapp";
    myApplicationNameField.setText(defaultAppName);
    myApplicationNameField.selectAll();
    myPackageNameField.setText(getDefaultPackageNameByModuleName(defaultAppName));

    myHelloAndroidCheckBox.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            updateActivityPanel();
          }
        });
    myPackageNameField
        .getDocument()
        .addDocumentListener(
            new DocumentAdapter() {
              @Override
              protected void textChanged(DocumentEvent e) {
                myPackageNameFieldChangedByUser = true;
                String message = validatePackageName(!myApp);
                myErrorLabel.setText(message);
              }
            });
    myActivityNameField
        .getDocument()
        .addDocumentListener(
            new DocumentAdapter() {
              @Override
              protected void textChanged(DocumentEvent e) {
                String message = validateActivityName();
                myErrorLabel.setText(message);
              }
            });
    myApplicationNameField
        .getDocument()
        .addDocumentListener(
            new DocumentAdapter() {
              @Override
              protected void textChanged(DocumentEvent e) {
                if (!myPackageNameFieldChangedByUser) {
                  updatePackageNameField();
                  myPackageNameFieldChangedByUser = false;
                }
              }
            });
  }
Example #22
0
  public void actionPerformed(ActionEvent e) {
    System.out.println(e.getActionCommand());
    if (e.getActionCommand().equals("Login")) {
      String serverIp = jfIp.getText();
      if (!CommonUtils.checkIsCorrectIp(serverIp)) {
        JOptionPane.showMessageDialog(null, "Ip Format is incorrect");
        return;
      }

      if (isPasswordCorrect(jfName.getText().trim(), jfPwd.getText().trim())) {
        String oo = Jclass.getSelectedItem().toString();
        jlTips.setText("input Correct");
        System.out.println("Correct");

        // new ChatClient(defaultport);

        // two class plugins. gui and konsole..
        // gui ---TemplateChatClient
        // konsole---ChatConsole
        try {
          if (oo.equals("GUI")) {
            CommonUtils.PrintMe("用户选择了Gui界面");
            new TemplateChatClient(defaultport, serverIp);

          } else if (oo.equals("Konsole")) {
            new TemplateChatConsole(defaultport, serverIp);
          }
        } catch (Exception ex) {
          System.out.println("Initialization failed!!");
          return;
        }
        //

        // cf.setVisible(true);
        fLogin.setVisible(false);
        fLogin.dispose();

      } else {
        jlTips.setText("Username or Password is not correct.");
        System.out.println("False Retry!");
        jfPwd.selectAll();
      }

    } else {
      System.exit(0);
    }
  }
Example #23
0
 public void setText(String text) {
   // Log.print("(LTextField.setText(" + text + ")");
   theImpl.checkChanged(text);
   super.setText(text);
   // Log.print("(LTextField).setText " + text);
   if (text != null) {
     // if the text is longer than the receiving field,
     // set a tool tip to show all of it.
     if (text.length() > getColumns() && getColumns() > 0) {
       setToolTipText(text);
     }
   }
   // Log.print("LTF setText " + text );
   if (super.hasFocus()) {
     super.selectAll();
   }
 }
  public void export(ActionEvent e) {
    String value = fileNameField.getText();
    if (MiscUtils.isNull(value)) {
      GUIUtilities.displayErrorMessage("You must specify a file to export to.");
      return;
    }

    // check if it exists
    if (FileUtils.fileExists(value)) {
      int confirm = GUIUtilities.displayConfirmCancelDialog("Overwrite existing file?");
      if (confirm == JOptionPane.CANCEL_OPTION) {
        return;
      } else if (confirm == JOptionPane.NO_OPTION) {
        fileNameField.selectAll();
        fileNameField.requestFocus();
        return;
      }
    }

    if (getExportFormatType() == ImportExportProcess.DELIMITED
        && delimCombo.getSelectedIndex() == 4) {

      value = customDelimField.getText();
      if (MiscUtils.isNull(value)) {

        GUIUtilities.displayErrorMessage("You must enter a custom delimeter");
        return;
      }
    }

    SwingWorker worker =
        new SwingWorker() {
          public Object construct() {

            return doExport();
          }

          public void finished() {

            GUIUtilities.displayInformationMessage("Result set export complete.");
            dispose();
          }
        };
    worker.start();
  }
    public Component getTableCellEditorComponent(
        JTable table_ref, Object value_ref, boolean isSelected, int row, int column) {
      Component c_ref =
          super.getTableCellEditorComponent(table_ref, value_ref, isSelected, row, column);

      if (c_ref instanceof JTextField) {
        tf_ref = ((JTextField) c_ref);
        tf_ref.selectAll();
        tf_ref.setBorder(BorderFactory.createLineBorder(new Color(99, 130, 191), 2));
        tf_ref.setBackground(Color.WHITE);
        if (isSelected) {
          tf_ref.setBackground(new Color(184, 207, 229));
        } else {
          tf_ref.setBackground(Color.WHITE);
        } // endif
        c_ref = tf_ref;
      } // endif

      return c_ref;
    } // endmethod getTableCellEditor
  void read(WizardDescriptor wd) {
    String projDir = (String) wd.getProperty("projDir");
    if (projDir == null || projDir.isEmpty()) {
      projDir = ProjectChooser.getProjectsFolder().getAbsolutePath();
    }

    String projName = (String) wd.getProperty("projName");
    if (projDir != null) {
      projectLocationTextField.setText(projDir);
    }
    if (projName != null) {
      projectNameTextField.setText(projName);
    }
    projectNameTextField.selectAll();
    if (projDir != null && projName != null) {
      createdFileTextField.setText(projDir + File.separator + projName);
    }
    String projTitle = (String) wd.getProperty("projTitle");
    if (projTitle != null) {
      projectTiteTextField.setText(projTitle);
    }
  }
  /**
   * Constructor.
   *
   * @param tileset A tileset.
   * @param oldPatternId The tile pattern id to change in this tileset.
   */
  public TilePatternIdRefactoringComponent(Tileset tileset, String oldPatternId) {
    super();

    setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
    setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    JPanel patternIdPanel = new JPanel();
    patternIdPanel.setLayout(new BoxLayout(patternIdPanel, BoxLayout.LINE_AXIS));
    patternIdPanel.setAlignmentX(1.0f);
    JLabel patternIdLabel = new JLabel("Tile pattern id:");
    patternIdPanel.add(patternIdLabel);
    patternIdPanel.add(Box.createHorizontalStrut(10));
    patternIdField = new JTextField(oldPatternId, 20);
    patternIdField.selectAll();
    patternIdPanel.add(patternIdField);
    patternIdPanel.setAlignmentX(0.0f);
    add(patternIdPanel);
    add(Box.createVerticalStrut(10));
    updateMapsCheckBox = new JCheckBox("Update references in existing maps");
    updateMapsCheckBox.setSelected(true);
    updateMapsCheckBox.setAlignmentX(0.0f);
    add(updateMapsCheckBox);
  }
Example #28
0
 @Nullable
 public Component getTableCellEditorComponent(
     JTable table, Object value, boolean isSelected, int row, int column) {
   myValue = ((MyTableModel) table.getModel()).getRegistryValue(row);
   if (myValue.asColor(null) != null) {
     final Color color =
         ColorChooser.chooseColor(
             table, "Choose color", ((RegistryValue) value).asColor(Color.WHITE));
     if (color != null) {
       myValue.setValue(color.getRed() + "," + color.getGreen() + "," + color.getBlue());
     }
     return null;
   } else if (myValue.isBoolean()) {
     myCheckBox.setSelected(myValue.asBoolean());
     myCheckBox.setBackground(table.getBackground());
     return myCheckBox;
   } else {
     myField.setText(myValue.asString());
     myField.setBorder(null);
     myField.selectAll();
     return myField;
   }
 }
Example #29
0
 @Deprecated
 public boolean editOrderCellAt(int row, int col) {
   if (row == -1 || col == -1) {
     return false;
   }
   boolean editCell = editCellAt(row, col, null);
   columnModel.getSelectionModel().setAnchorSelectionIndex(col);
   final TableCellEditor tableCellEditor = getCellEditor(row, col);
   if (tableCellEditor instanceof ComboCellEditor) {
     JComponent component = ((ComboCellEditor) tableCellEditor).getFocusComponent();
     if (component instanceof JComboBox) {
       component.requestFocus();
     }
   } else if (tableCellEditor instanceof DefaultCellEditor) {
     JTextField tf = (JTextField) ((DefaultCellEditor) tableCellEditor).getComponent();
     tf.requestFocus();
     tf.selectAll();
   } else if (tableCellEditor instanceof CheckBoxCellEditor) {
     ((CheckBoxCellEditor) tableCellEditor).getComponent().requestFocus();
   }
   getSelectionModel().setSelectionInterval(row, row);
   return editCell;
 }
  /**
   * Use the GUI results to set up the variables needed to run the algorithm.
   *
   * @return <code>true</code> if parameters set successfully, <code>false</code> otherwise.
   */
  private boolean setVariables() {
    String tmpStr;

    System.gc();

    if (replaceImage.isSelected()) {
      displayLoc = REPLACE;
    } else if (newImage.isSelected()) {
      displayLoc = NEW;
    }

    tmpStr = textSearchWindowSide.getText();

    if (testParameter(tmpStr, 5, 101)) {
      searchWindowSide = Integer.valueOf(tmpStr).intValue();
    } else {
      MipavUtil.displayError("Search window side must be between 5 and 101");
      textSearchWindowSide.requestFocus();
      textSearchWindowSide.selectAll();

      return false;
    }

    if ((searchWindowSide % 2) == 0) {
      MipavUtil.displayError("Search window side must be an odd number");
      textSearchWindowSide.requestFocus();
      textSearchWindowSide.selectAll();
      return false;
    }

    tmpStr = textSimilarityWindowSide.getText();

    if (testParameter(tmpStr, 3, 99)) {
      similarityWindowSide = Integer.valueOf(tmpStr).intValue();
    } else {
      MipavUtil.displayError("Similarity window side must be between 3 and 99");
      textSimilarityWindowSide.requestFocus();
      textSimilarityWindowSide.selectAll();

      return false;
    }

    if ((similarityWindowSide % 2) == 0) {
      MipavUtil.displayError("Similarity window side must be an odd number");
      textSimilarityWindowSide.requestFocus();
      textSimilarityWindowSide.selectAll();
      return false;
    }

    if (similarityWindowSide >= searchWindowSide) {
      MipavUtil.displayError("Similarity window side must be less than search window side");
      textSimilarityWindowSide.requestFocus();
      textSimilarityWindowSide.selectAll();
      return false;
    }

    tmpStr = textNoiseStandardDeviation.getText();

    if (testParameter(tmpStr, 0.001, 1000.0)) {
      noiseStandardDeviation = Float.valueOf(tmpStr).floatValue();
    } else {
      MipavUtil.displayError("Radius must be between 0.001 and 1000.0");
      textNoiseStandardDeviation.requestFocus();
      textNoiseStandardDeviation.selectAll();

      return false;
    }

    doRician = doRicianCheckBox.isSelected();

    if (doRician) {
      tmpStr = textDegree.getText();
      if (testParameter(tmpStr, 1.0, 10.0)) {
        degreeOfFiltering = Float.valueOf(tmpStr).floatValue();
      } else {
        MipavUtil.displayError("Degree of filtering must be between 1.0 and 10.0");
        textDegree.requestFocus();
        textDegree.selectAll();
      }
    }

    if (image.getNDims() > 2) {
      image25D = image25DCheckBox.isSelected();
    }

    return true;
  }