Examples of JTextComponent


Examples of javax.swing.text.JTextComponent

    String message = this.preferences.getLocalizedString(HomePane.class, "showStoreCameraDialog.message");
    String title = this.preferences.getLocalizedString(HomePane.class, "showStoreCameraDialog.title");
   
    List<Camera> storedCameras = this.home.getStoredCameras();
    JComponent cameraNameChooser;
    JTextComponent cameraNameTextComponent;
    if (storedCameras.isEmpty()) {
      cameraNameChooser = cameraNameTextComponent = new JTextField(cameraName, 20);
    } else {
      // If cameras are already stored in home propose an editable combo box to user
      // to let him choose more easily an existing one if he want to overwrite it
      String [] storedCameraNames = new String [storedCameras.size()];
      for (int i = 0; i < storedCameraNames.length; i++) {
        storedCameraNames [i] = storedCameras.get(i).getName();
      }
      JComboBox cameraNameComboBox = new JComboBox(storedCameraNames);
      cameraNameComboBox.setEditable(true);
      cameraNameComboBox.getEditor().setItem(cameraName);
      Component editorComponent = cameraNameComboBox.getEditor().getEditorComponent();
      if (editorComponent instanceof JTextComponent) {
        cameraNameTextComponent = (JTextComponent)editorComponent;
        cameraNameChooser = cameraNameComboBox;
      } else {
        cameraNameChooser = cameraNameTextComponent = new JTextField(cameraName, 20);
      }
    }
    JPanel cameraNamePanel = new JPanel(new BorderLayout(2, 2));
    cameraNamePanel.add(new JLabel(message), BorderLayout.NORTH);
    cameraNamePanel.add(cameraNameChooser, BorderLayout.SOUTH);
    if (SwingTools.showConfirmDialog(this, cameraNamePanel,
        title, cameraNameTextComponent) == JOptionPane.OK_OPTION) {
      return cameraNameTextComponent.getText();
    } else {
      return null;
    }
  }
View Full Code Here

Examples of javax.swing.text.JTextComponent

    add(_textComponent);
  }

  private JTextComponent getTextComponent(ConfiguredPropertyDescriptor propertyDescriptor,
      StringProperty stringPropertyAnnotation) {
    JTextComponent textComponent;
    if (stringPropertyAnnotation != null && stringPropertyAnnotation.multiline()) {
      textComponent = WidgetFactory.createTextArea(propertyDescriptor.getName());
    } else {
      textComponent = WidgetFactory.createTextField(propertyDescriptor.getName());
    }

    textComponent.getDocument().addDocumentListener(new DCDocumentListener() {
      @Override
      protected void onChange(DocumentEvent e) {
        fireValueChanged();
      }
    });

    if (stringPropertyAnnotation != null) {
      boolean monospace = false;
      String[] mimeTypes = stringPropertyAnnotation.mimeType();
      for (String mt1 : mimeTypes) {
        for (String mt2 : MONOSPACE_MIME_TYPES) {
          if (mt1.equalsIgnoreCase(mt2)) {
            monospace = true;
            break;
          }
        }
      }

      if (monospace) {
        textComponent.setFont(WidgetUtils.FONT_MONOSPACE);
      }
    }

    return textComponent;
  }
View Full Code Here

Examples of javax.swing.text.JTextComponent

  public char[] getValue() {
    Component[] components = _textFieldPanel.getComponents();
    List<Character> list = new ArrayList<Character>();
    for (int i = 0; i < components.length; i++) {
      DCPanel panel = (DCPanel) components[i];
      JTextComponent textComponent = (JTextComponent) panel.getComponent(0);
      String text = textComponent.getText();
      if (text != null && text.length() == 1) {
        list.add(text.charAt(0));
      }
    }
    char[] result = new char[list.size()];
View Full Code Here

Examples of javax.swing.text.JTextComponent

    final String[] previousValues = getValue();
    if (!EqualsBuilder.equals(values, previousValues)) {
      for (int i = 0; i < Math.min(previousValues.length, values.length); i++) {
        // modify text boxes
        if (!EqualsBuilder.equals(previousValues[i], values[i])) {
          JTextComponent component = (JTextComponent) _textFieldPanel.getComponent(i);
          component.setText(values[i]);
        }
      }

      while (_textFieldPanel.getComponentCount() < values.length) {
        // add text boxes if there are too few
View Full Code Here

Examples of javax.swing.text.JTextComponent

    // this is going to suck more.

    if (focusedComponent != null) {
      if (focusedComponent instanceof JTextComponent) {
        JTextComponent fTextComp = (JTextComponent) focusedComponent;
        textActions = fTextComp.getActions();
        Action selectedAction = null;
        for (int i = 0; (selectedAction == null) && i < textActions.length; i++) {
          if (textActions[i].getValue(Action.NAME).equals(name))
            selectedAction = textActions[i];
        }
View Full Code Here

Examples of javax.swing.text.JTextComponent

            }
        }
    }

    private void startEditing() {
        JTextComponent textField = (JTextComponent) combo.getEditor().getEditorComponent();

        combo.setEditable(true);

        textField.requestFocus();

        String text = initialEditValue;
        if (initialEditValue == null) {
            text = ""; // will revert to last valid value if invalid
        }

        combo.setSelectedItem(text);

        int i = text.indexOf("${}");
        if (i != -1) {
            textField.setCaretPosition(i + 2);
        } else {
            textField.selectAll();
        }
    }
View Full Code Here

Examples of javax.swing.text.JTextComponent

    }
  }

  private void startEditing()
  {
    JTextComponent textField=
      (JTextComponent)combo.getEditor().getEditorComponent();

    combo.setEditable(true);

    textField.requestFocus();

    String text= initialEditValue;
    if (initialEditValue == null) text= ""// will revert to last valid value if invalid

    combo.setSelectedItem(text);

    int i= text.indexOf("${}");
    if (i != -1) textField.setCaretPosition(i+2);
    else textField.selectAll();
  }
View Full Code Here

Examples of javax.swing.text.JTextComponent

        notesTable.getSelectionModel().setSelectionInterval(row, row);
        TableUtil.scrollSelectionToVisible(notesTable);

        if (notesTable.editCellAt(row, 1))
        {
          final JTextComponent textEditor = (JTextComponent)
            ((JScrollPane) notesTable.getEditorComponent()).getViewport().getView();
          textEditor.requestFocusInWindow();
          textEditor.selectAll();
        }
      }
    });
  }
View Full Code Here

Examples of javax.swing.text.JTextComponent

        @Override
        public void mouseClicked(MouseEvent e)
        {
          if (notesTable.editCellAt(indexOfNote(currentNote), 1))
          {
            final JTextComponent textEditor = (JTextComponent)
              ((JScrollPane) notesTable.getEditorComponent()).getViewport().getView();
            textEditor.requestFocusInWindow();
          }
        }
      });
      configureUI();
    }
View Full Code Here

Examples of javax.swing.text.JTextComponent

    PpiComboBox() {
        setEditable(true);
        addActionListener(this);

        JTextComponent text = getTextComponent();
        Document doc = text.getDocument();
        doc.addDocumentListener(this);

        Font font = (new JTextField()).getFont();
        setFont(font);
        text.setFont(font);
       
        text.addFocusListener(
            new FocusListener() {
                public void focusGained(FocusEvent e) {
                    JTextComponent text = (JTextComponent) e.getSource();
                    text.selectAll();
                }
                public void focusLost(FocusEvent e) {
                    JTextComponent text = (JTextComponent) e.getSource();
                    text.select(0, 0);
                }
            }
        );
        text.setInputVerifier(
            new InputVerifier() {
                public boolean verify(JComponent comp) {
                    return PpiComboBox.this.verify();
                }
            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.