Package javax.swing.text

Examples of javax.swing.text.DocumentFilter


    lblUserData2 = new JLabel4j_std(lang.get("lbl_User_Data2"));
    lblUserData2.setHorizontalAlignment(SwingConstants.TRAILING);
    lblUserData2.setBounds(288, 167, 111, 16);
    desktopPane.add(lblUserData2);

    DocumentFilter filter = new UppercaseDocumentFilter();
    textFieldUserData1 = new JTextField4j();
    textFieldUserData1.addKeyListener(new KeyAdapter()
    {

      @Override
View Full Code Here


        area.addKeyListener(this);
       
        // No editing before startPos
        if (area.getDocument() instanceof AbstractDocument) {
            ((AbstractDocument) area.getDocument()).setDocumentFilter(
                new DocumentFilter() {
                    public void insertString(DocumentFilter.FilterBypass fb, int offset, String string, AttributeSet attr) throws BadLocationException {
                        if (offset >= startPos) super.insertString(fb, offset, string, attr);
                    }
                   
                    public void remove(DocumentFilter.FilterBypass fb, int offset, int length) throws BadLocationException {
View Full Code Here

        getRootPane().setDefaultButton(ok);
       
        final Document doc = field.getDocument();
        if (doc instanceof AbstractDocument) {
          AbstractDocument ad = (AbstractDocument) doc;
          ad.setDocumentFilter(new DocumentFilter() {
            @Override
            public void insertString(FilterBypass bypass, int offset,
                String str, AttributeSet attr)
                throws BadLocationException {
              if (doc.getLength() + str.length() < 2 && !str.trim().isEmpty()) {
View Full Code Here

   
    setHorizontalAlignment( JLabel.RIGHT );
    setFont( new Font( "Verdana", 0, 12 ) );
    adicionarListeners();
   
    DocumentFilter filtro = new NumberDocumentFilter();
    ((AbstractDocument) this.getDocument()).setDocumentFilter( filtro );
  }
View Full Code Here

    }

    public void testInstallUninstall_Filters() {
        NavigationFilter navFilter = new NavigationFilter();
        formatter.setNavigationFilter(navFilter);
        DocumentFilter docFilter = new DocumentFilter();
        formatter.setDocumentFilter(docFilter);
        AbstractDocument doc = (AbstractDocument) tf.getDocument();
        assertNull(tf.getNavigationFilter());
        assertNull(doc.getDocumentFilter());
        formatter.install(tf);
View Full Code Here

    super();
    document = doc;
    // use memory friendly way of reader only if given document is an
    // AbstractDocument, else copy document content
    if (doc instanceof AbstractDocument) {
      DocumentFilter filter = ((AbstractDocument) doc).getDocumentFilter();
      if (filter instanceof DocumentReaderDocumentFilter) {
        copyContent();
      } else {
        documentFilter = new DocumentReaderDocumentFilter(filter, this);
        ((AbstractDocument) doc).setDocumentFilter(documentFilter);
View Full Code Here

        this.area = area;
        readline = new Readline();
        inputJoin.send(Channel.EMPTY, null);
        area.addKeyListener(this);
        if (area.getDocument() instanceof AbstractDocument)
            ((AbstractDocument) area.getDocument()).setDocumentFilter(new DocumentFilter() {
                public void insertString(DocumentFilter.FilterBypass fb, int offset, String string, AttributeSet attr)
                        throws BadLocationException {
                    if (offset >= startPos)
                        super.insertString(fb, offset, string, attr);
                }
View Full Code Here

        });

     
      
      
        docFilter = new DocumentFilter() {
         
      public void insertString(DocumentFilter.FilterBypass fb,
                    int offset,
                    String string,
                    AttributeSet attr)
View Full Code Here

    /* Do not override TEXT_NOT_TO_TOUCH */
    @Override
    public DocumentFilter getDocumentFilter() {
      /** @todo: There seem to be some remaining issues regarding input handling */
      return new DocumentFilter() {

        @Override
        public void insertString(DocumentFilter.FilterBypass fb, int offset, String string, AttributeSet attr) throws BadLocationException {
          if (offset < TEXT_NOT_TO_TOUCH.length()) {
            return;
View Full Code Here

                }
            });

            // Only 0-9 allowed in string
            ((AbstractDocument)getDocument())
                    .setDocumentFilter(new DocumentFilter() {

                private boolean digitsOnly(String s) {
                    for(int i = 0; i < s.length(); i++) {
                        char c = s.charAt(i);
                        if(c < '0' || c > '9')
View Full Code Here

TOP

Related Classes of javax.swing.text.DocumentFilter

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.