Package javax.swing.text

Examples of javax.swing.text.JTextComponent


        public CancelAction(final String name) {
            super(name);
        }

        public void actionPerformed(final ActionEvent e) {
            JTextComponent source = getTextComponent(e);
            if (source instanceof JFormattedTextField) {
                JFormattedTextField tf = (JFormattedTextField) source;
                tf.revertValue();
            }
        }
View Full Code Here


     */
    private static void showVirtualKeyboard()
    {
        JFrame f = new JFrame();
        JPanel p = new JPanel(new BorderLayout());
        JTextComponent tb = new JTextArea(10, 80);
        tb.setFont(new Font("Lucida", Font.PLAIN, 20));
        tb.setPreferredSize(new Dimension(20, 200));
        f.getContentPane().setLayout(new BorderLayout());
        f.getContentPane().add(p, BorderLayout.CENTER);
        final LanguageMap map = LanguageMap.getInstance();

        KeyboardLayout layout = map.getKeyboardLayoutForLocale("th", "TH");
View Full Code Here

  /* (non-Javadoc)
   * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
   */
  public void actionPerformed(ActionEvent e) {
    JTextComponent text = (textPane != null) ? textPane : getTextComponent(e);
    String currentSearch = JOptionPane.showInputDialog(
        text.getParent(),
        GT._("String to find"),
        (search == null) ? lastSearch : search);
    if ((currentSearch == null) || ("".equals(currentSearch.trim()))) {
      return;
    }
    lastSearch = currentSearch;
    String textPattern = "";
    char firstChar = lastSearch.charAt(0);
    if (Character.isLetter(firstChar)) {
      textPattern =
          "[" + Character.toUpperCase(firstChar) + Character.toLowerCase(firstChar) + "]" +
          Pattern.quote(lastSearch.substring(1));
    } else {
      textPattern = Pattern.quote(lastSearch);
    }
    Pattern pattern = Pattern.compile(textPattern);
    Matcher matcher = pattern.matcher(text.getText());
    if (matcher.find(text.getCaretPosition())) {
      text.setCaretPosition(matcher.start());
      text.moveCaretPosition(matcher.end());
      text.requestFocus();
      return;
    }
    if (matcher.find(0)) {
      text.setCaretPosition(matcher.start());
      text.moveCaretPosition(matcher.end());
      text.requestFocus();
      return;
    }
  }
View Full Code Here

   * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
   */
  public void actionPerformed(ActionEvent e) {
    JTextPane localTextPane = textPane;
    if (localTextPane == null) {
      JTextComponent textComponent = getTextComponent(e);
      if (textComponent instanceof JTextPane) {
        localTextPane = (JTextPane) textComponent;
      }
    }
    Element localElement = element;
View Full Code Here

   * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
   */
  public void actionPerformed(ActionEvent e) {
    JTextPane localTextPane = textPane;
    if (localTextPane == null) {
      JTextComponent textComponent = getTextComponent(e);
      if (textComponent instanceof JTextPane) {
        localTextPane = (JTextPane) textComponent;
      }
    }
    Element localElement = element;
View Full Code Here

   * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
   */
  public void actionPerformed(ActionEvent e) {
    JTextPane localTextPane = textPane;
    if (localTextPane == null) {
      JTextComponent textComponent = getTextComponent(e);
      if (textComponent instanceof JTextPane) {
        localTextPane = (JTextPane) textComponent;
      }
    }
    Element localElement = element;
View Full Code Here

   * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
   */
  public void actionPerformed(ActionEvent e) {
    JTextPane localTextPane = textPane;
    if (localTextPane == null) {
      JTextComponent textComponent = getTextComponent(e);
      if (textComponent instanceof JTextPane) {
        localTextPane = (JTextPane) textComponent;
      }
    }
    Element localElement = element;
View Full Code Here

  }

  public static Color getTextBackgroundFillColor(JComponent comp) {
    Color backgroundFillColor = SubstanceColorUtilities
        .getBackgroundFillColor(comp);
    JTextComponent componentForTransitions = SubstanceCoreUtilities
        .getTextComponentForTransitions(comp);

    if (componentForTransitions != null) {
      ComponentUI ui = componentForTransitions.getUI();
      if (ui instanceof Trackable) {
        Trackable trackable = (Trackable) ui;
        ButtonModel transitionModel = trackable.getTransitionModel();
        ComponentState state = ComponentState.getState(transitionModel,
            componentForTransitions);
View Full Code Here

    return (background instanceof UIResource)
        || (background instanceof SubstanceColorResource);
  }

  public static JTextComponent getTextComponentForTransitions(JComponent c) {
    JTextComponent componentForTransitions = null;
    if (c instanceof JTextComponent) {
      componentForTransitions = (JTextComponent) c;
    }
    if (c instanceof JSpinner) {
      JComponent editor = ((JSpinner) c).getEditor();
View Full Code Here

    /* Called by the KeyboardFocus PropertyChangeListener in ApplicationContext,
     * before any other focus-change related work is done.
     */
    public void updateFocusOwner(JComponent oldOwner, JComponent newOwner) {
        if (oldOwner instanceof JTextComponent) {
            JTextComponent text = (JTextComponent) oldOwner;
            text.removeCaretListener(textComponentCaretListener);
            text.removePropertyChangeListener(textComponentPCL);
        }
        if (newOwner instanceof JTextComponent) {
            JTextComponent text = (JTextComponent) newOwner;
            maybeInstallTextActions(text);
            updateTextActions(text);
            text.addCaretListener(textComponentCaretListener);
            text.addPropertyChangeListener(textComponentPCL);
        } else if (newOwner == null) {
            setBoldEnabled(false);
            setBoldSelected(false);
        }
    }
View Full Code Here

TOP

Related Classes of javax.swing.text.JTextComponent

Copyright © 2018 www.massapicom. 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.