当前位置: 首页>>代码示例>>Java>>正文


Java DocumentFilter.FilterBypass方法代码示例

本文整理汇总了Java中javax.swing.text.DocumentFilter.FilterBypass方法的典型用法代码示例。如果您正苦于以下问题:Java DocumentFilter.FilterBypass方法的具体用法?Java DocumentFilter.FilterBypass怎么用?Java DocumentFilter.FilterBypass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.text.DocumentFilter的用法示例。


在下文中一共展示了DocumentFilter.FilterBypass方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: remove

import javax.swing.text.DocumentFilter; //导入方法依赖的package包/类
@Override
public void remove(DocumentFilter.FilterBypass fb, int offset, int length)
        throws BadLocationException {
    if (skipFiltersWhileTrue) {
        super.remove(fb, offset, length);
        return;
    }
    String oldText = fb.getDocument().getText(0, fb.getDocument().getLength());
    StringBuilder newTextBuilder = new StringBuilder(oldText);
    newTextBuilder.delete(offset, (offset + length));
    String newText = newTextBuilder.toString();
    if (newText.trim().isEmpty() || oldText.equals("-1")) {
        setFieldToDefaultValue();
    } else if (allowNegativeNumbers() && newText.trim().equals("-")) {
        setFieldToNegativeOne();
    } else if (isValidInteger(newText)) {
        super.remove(fb, offset, length);
    } else {
        Toolkit.getDefaultToolkit().beep();
    }
}
 
开发者ID:LGoodDatePicker,项目名称:LGoodDatePicker,代码行数:22,代码来源:JIntegerTextField.java

示例2: insertString

import javax.swing.text.DocumentFilter; //导入方法依赖的package包/类
public void insertString(DocumentFilter.FilterBypass fb, int offset,
		String string, AttributeSet attr) throws BadLocationException {

	if (string == null) {
		return;
	} else {
		String newValue;
		Document doc = fb.getDocument();
		int length = doc.getLength();
		if (length == 0) {
			newValue = string;
		} else {
			String currentContent = doc.getText(0, length);
			StringBuilder currentBuffer = new StringBuilder(
					currentContent);
			currentBuffer.insert(offset, string);
			newValue = currentBuffer.toString();
		}
		currentValue = checkInput(newValue, offset);
		fb.insertString(offset, string, attr);
	}
}
 
开发者ID:thingweb,项目名称:thingweb-gui,代码行数:23,代码来源:AbstractDocumentFilter.java

示例3: insertString

import javax.swing.text.DocumentFilter; //导入方法依赖的package包/类
@Override
public void insertString(DocumentFilter.FilterBypass fb, int offset, String text,
	AttributeSet attr) throws BadLocationException {
	StringBuilder sb = new StringBuilder();
	for(int i = 0; i < text.length(); i++){
		char c = text.charAt(i);
		boolean isLegal = true;
		for(char illegal : illegalChars){
			if(c == illegal){
				isLegal = false;
				break;
			}
		}
		if(isLegal){
			sb.append(c);
		}
	}
	text = sb.toString();
	super.insertString(fb, offset, text, attr);
}
 
开发者ID:QuinnFreedman,项目名称:THINK-VPL,代码行数:21,代码来源:SpecialEditorPane.java

示例4: replace

import javax.swing.text.DocumentFilter; //导入方法依赖的package包/类
@Override
public void replace(DocumentFilter.FilterBypass fb, int offset, int length, String text,
	AttributeSet attrs) throws BadLocationException {
	//String curentText = doc.getText(0, Math.min(4, doc.getLength()));
	/*if(doc.getLength() >= 4 && curentText.equals("true")){
		text = "true";
		offset = 0;
		length = doc.getLength();
	}else if(doc.getLength() >= 5){
		text = "false";
		offset = 0;
		length = doc.getLength();
	}*/
	if(doc.getText(0,Math.min(1, doc.getLength())).equals("t") || doc.getText(0,Math.min(1, doc.getLength())).equals("T") || (text.equals("t")) || (text.equals("T")) || (text.equals("true"))){
		text = "true";
		offset = 0;
		length = doc.getLength();
	}else{
		text = "false";
		offset = 0;
		length = doc.getLength();
	}
	super.replace(fb, offset, length, text, attrs);
}
 
开发者ID:QuinnFreedman,项目名称:THINK-VPL,代码行数:25,代码来源:VBoolean.java

示例5: replace

import javax.swing.text.DocumentFilter; //导入方法依赖的package包/类
@Override
public void replace(DocumentFilter.FilterBypass fb, int offset, int length, String str, AttributeSet attrs) throws BadLocationException {
    //XXX Attention : par défaut, dans Swing, insertString et remove appellent tous les deux replace, et non l'inverse
    if(str!=null && str.length()!=0) {//y aura-t-il une insertion ?
        if(length>0) {//il y aura aussi un remove
            undo.valider();
            flagRemove=true; remove(fb, offset, length);//remove sans valider le groupe d'edit
            flagInsert=true; insertString(fb, offset, str, attrs);//insert sans valider le groupe d'edit
            flagInsert=false; flagRemove=false;
        } else {//il s'agissait d'un insert déguisé
            insertString(fb, offset, str, attrs);
        }
    } else {//il s'agissait d'un remove déguisé
        remove(fb, offset, length);
    }
}
 
开发者ID:Sharcoux,项目名称:MathEOS,代码行数:17,代码来源:JMathTextPane.java

示例6: insertString

import javax.swing.text.DocumentFilter; //导入方法依赖的package包/类
@Override
public void insertString(DocumentFilter.FilterBypass fb, int offset, String string, AttributeSet attr)
        throws BadLocationException {
    if (useFilters) {
        // determine if we can insert
        if (console.getSelectionStart() >= console.editStart) {
            // can insert
            fb.insertString(offset, string, attr);
        } else {
            // insert at the end of the document
            fb.insertString(console.getText().length(), string, attr);
            // move cursor to the end
            console.getCaret().setDot(console.getText().length());
            // console.setSelectionEnd(console.getText().length());
            // console.setSelectionStart(console.getText().length());
        }
    } else {
        fb.insertString(offset, string, attr);
    }
}
 
开发者ID:opensim-org,项目名称:opensim-gui,代码行数:21,代码来源:JConsole.java

示例7: replace

import javax.swing.text.DocumentFilter; //导入方法依赖的package包/类
@Override
public void replace(DocumentFilter.FilterBypass fb, int offset, int length, String text, AttributeSet attrs)
        throws BadLocationException {
    if (useFilters) {
        // determine if we can replace
        if (console.getSelectionStart() >= console.editStart) {
            // can replace
            fb.replace(offset, length, text, attrs);
        } else {
            // insert at end
            fb.insertString(console.getText().length(), text, attrs);
            // move cursor to the end
            console.getCaret().setDot(console.getText().length());
            // console.setSelectionEnd(console.getText().length());
            // console.setSelectionStart(console.getText().length());
        }
    } else {
        fb.replace(offset, length, text, attrs);
    }
}
 
开发者ID:opensim-org,项目名称:opensim-gui,代码行数:21,代码来源:JConsole.java

示例8: replace

import javax.swing.text.DocumentFilter; //导入方法依赖的package包/类
@Override
public void replace(DocumentFilter.FilterBypass fb, int offset, int length, String string, AttributeSet attrs) throws BadLocationException {
    Document document = fb.getDocument();
    if (length > 0) {
        fb.remove(offset, length);
    }
    for (int i = 0; i < string.length(); i++) {
        char charNow = string.charAt(i);
        if (Character.isDigit(charNow)) {
            fb.replace(offset, 0, String.valueOf(charNow), attrs);
        } else if (charNow == '.' || charNow == ',') {
            if (!document.getText(0, document.getLength()).contains(".")) {
                fb.replace(offset, 0, ".", attrs);

            }
        }
        offset++;
    }
}
 
开发者ID:jmayer13,项目名称:academia_biometria,代码行数:20,代码来源:DecimalNumberDocumentFilter.java

示例9: replace

import javax.swing.text.DocumentFilter; //导入方法依赖的package包/类
public void replace(DocumentFilter.FilterBypass fb, int offset, int length,
                String text, AttributeSet attr) throws BadLocationException
{
    final String currentText = fb.getDocument().getText(0, fb.getDocument().getLength());
    final StringBuilder sb = new StringBuilder(currentText);
    sb.replace(offset, offset + length, text);
    final Matcher positiveMatcher = positiveCurrencyPattern.matcher(sb.toString());
    if (positiveMatcher.matches()) {
        fb.replace(offset, length, text, attr);
    } else if (allowNegative) {
        final Matcher negativeMatcher = negativeCurrencyPattern.matcher(sb.toString());
        if (negativeMatcher.matches() || sb.toString().matches(startNegativeDecimal)) {
            fb.replace(offset, length, text, attr);
        }
    }
}
 
开发者ID:jefflward,项目名称:First-Fruits,代码行数:17,代码来源:SimpleCurrencyFilter.java

示例10: replace

import javax.swing.text.DocumentFilter; //导入方法依赖的package包/类
@Override
public void replace(DocumentFilter.FilterBypass fb, int offset, int length,
		String text, AttributeSet attrs, DocumentFilterChain chain)
		throws BadLocationException {
	
	if(text.equals("\"")) {
		fb.replace(offset, length, text, attrs);
		boolean open = shouldOpenQuote(doc, offset);
		String curvedQuote = open? "“": "”";
		if(open) {
			attrs = doc.getCharacterElement(offset + 1).getAttributes();
		}
		chain.replace(fb, offset, 1, curvedQuote, attrs);
		return;
	}
	
	chain.replace(fb, offset, length, text, attrs);
}
 
开发者ID:lexml,项目名称:lexml-swing-editorhtml,代码行数:19,代码来源:AutoCurvedQuotesBehavior.java

示例11: insertString

import javax.swing.text.DocumentFilter; //导入方法依赖的package包/类
@Override
public void insertString(DocumentFilter.FilterBypass fb,
                         int offset,
                         String string,
                         AttributeSet attr) throws BadLocationException {
    String strToAdd = removeSpaces(string);
    if (strToAdd != null) {
        super.insertString(fb, offset, strToAdd, null);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:ClassNameTextField.java

示例12: replace

import javax.swing.text.DocumentFilter; //导入方法依赖的package包/类
@Override
public void replace(DocumentFilter.FilterBypass bypass,
                    int offset,
                    int length,
                    String text,
                    AttributeSet attrs) throws BadLocationException {
    if (!programmaticChange && srcGroupNameDisplayed) {
        removeSrcGroupName(bypass);
    }
    super.replace(bypass, offset, length, text, attrs);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:SimpleTestStepLocation.java

示例13: insertString

import javax.swing.text.DocumentFilter; //导入方法依赖的package包/类
@Override
public void insertString(
                    DocumentFilter.FilterBypass bypass,
                    int offset,
                    String string,
                    AttributeSet attr) throws BadLocationException {
    if (!programmaticChange && srcGroupNameDisplayed) {
        removeSrcGroupName(bypass);
    }
    super.insertString(bypass, offset, string, attr);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:SimpleTestStepLocation.java

示例14: remove

import javax.swing.text.DocumentFilter; //导入方法依赖的package包/类
@Override
public void remove(DocumentFilter.FilterBypass bypass,
                   int offset,
                   int length) throws BadLocationException {
    if (!programmaticChange && srcGroupNameDisplayed) {
        removeSrcGroupName(bypass);
    }
    super.remove(bypass, offset, length);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:SimpleTestStepLocation.java

示例15: removeSrcGroupName

import javax.swing.text.DocumentFilter; //导入方法依赖的package包/类
private void removeSrcGroupName(DocumentFilter.FilterBypass bypass)
                                        throws BadLocationException {
    bypass.remove(classNameLength,
                  tfClassToTest.getText().length() - classNameLength);
    srcGroupNameDisplayed = false;
    setNavigationFilterEnabled(false);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:SimpleTestStepLocation.java


注:本文中的javax.swing.text.DocumentFilter.FilterBypass方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。