Package javax.swing.text

Examples of javax.swing.text.JTextComponent$KeyBinding


        DefaultWindowWrapper wrapper = new DefaultWindowWrapper(AFrame.FRAME_NAME);

        try {
            AFrame frame = new AFrame();
       
        JTextComponent textField = new JTextField();
        textField.setName("a.textfield");
       
        JTextComponent textArea = new JTextArea();
        textArea.setName("b.textarea");
       
        frame.getContentPane().setLayout(new FlowLayout());
       
        frame.getContentPane().add(textField);
        frame.getContentPane().add(textArea);
        frame.pack();
       
       
        frame.setVisible(true);
        wrapper.enterText("a.textfield", "Text1");
        wrapper.enterText("b.textarea", "Text2");
       
        ensureThat(textField.getText(), eq("Text1"));
        ensureThat(textArea.getText(), eq("Text2"));
        } finally {
            wrapper.closeWindow();
        }
  }
View Full Code Here


  public boolean isRollover() {
    return rollover;
  }
  protected void paintBackground( Graphics g) {
    JTextComponent c = (JTextComponent)getComponent();

    Border bb = c.getBorder();
   
    if ( bb != null && bb instanceof NimRODBorders.NimRODGenBorder ) {
      g.setColor( getComponent().getBackground());
     
      Graphics2D g2d = (Graphics2D)g;
      g2d.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
     
      g.fillRoundRect( 2,2, c.getWidth()-4, c.getHeight()-4, 7,7);
     
      g2d.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_DEFAULT);
     
      if ( c.isEnabled() && c.isEditable() ) {
        if ( focus ) {
          NimRODUtils.paintFocus( g, 1,1, c.getWidth()-2, c.getHeight()-2, 2, 2, NimRODLookAndFeel.getFocusColor());
        }
        else if ( rollover ) {
          NimRODUtils.paintFocus( g, 1,1, c.getWidth()-2, c.getHeight()-2, 2, 2, NimRODUtils.getColorAlfa( NimRODLookAndFeel.getFocusColor(), 150));
        }
      }
    }
    else {
      super.paintBackground( g);
View Full Code Here

                } else {
                    if (updater == null) {
                        updater = new ViewUpdater() {
                            public void updateView() {
                                Rectangle rc;
                                JTextComponent tc =
                                    (JTextComponent)view.getContainer();
                                if (tc != null) {
                                    try {
                                        rc = tc.modelToView(view
                                                            .getStartOffset());
                                    } catch (BadLocationException e) {
                                        return;
                                    }
                                    tc.repaint(rc.x, rc.y,
                                               ((BoxView)view).getWidth(),
                                               ((BoxView)view).getHeight());
                                }
                            }
                        };
View Full Code Here

                    }
                }
            });
        }

        JTextComponent comp = getComponent();
        boolean lineWrap = false;
        boolean wordWrap = false;
        if (comp instanceof JTextArea) {
            JTextArea c = (JTextArea)getComponent();
            lineWrap = c.getLineWrap();
View Full Code Here

            }
        }
    }

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

        combo.setEditable(true);

        textField.requestFocusInWindow();
        String text = translate(initialEditValue);
        if (text == 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

    public void paint(final Graphics g, final Shape shape) {
        Rectangle rc = shape.getBounds();

        // TODO change layered highlight painting code
        JTextComponent tc = (JTextComponent)getContainer();
        Highlighter hl = tc.getHighlighter();
        if (hl instanceof LayeredHighlighter) {
            ((LayeredHighlighter)hl).paintLayeredHighlights(g,
                                                            getStartOffset(),
                                                            getEndOffset(),
                                                            shape, tc, this);
View Full Code Here

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

        public void actionPerformed(final ActionEvent a) {
            final JTextComponent focused = getFocusedComponent();
            if (!(focused instanceof JTextField)) {
                return;
            }

            ((JTextField)focused).postActionEvent();
View Full Code Here

            ((JTextField)focused).postActionEvent();
        }

        public boolean isEnabled() {
            final JTextComponent focused = getFocusedComponent();
            if (!(focused instanceof JTextField)) {
                return false;
            }

            JTextField textField = (JTextField)focused;
View Full Code Here

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

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

            }
            super.actionPerformed(e);
        }

        public boolean isEnabled() {
            final JTextComponent focused = getFocusedComponent();
            return focused instanceof JFormattedTextField;
        }
View Full Code Here

TOP

Related Classes of javax.swing.text.JTextComponent$KeyBinding

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.