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


Java PlainDocument.setDocumentFilter方法代码示例

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


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

示例1: createIntegerOnlyJTextField

import javax.swing.text.PlainDocument; //导入方法依赖的package包/类
public static JTextField createIntegerOnlyJTextField() {
	JTextField textField = new JFormattedTextField();
	
	 PlainDocument doc = (PlainDocument) textField.getDocument();
	 doc.setDocumentFilter(new DocumentIntFilter());
	
	setTextFieldProperties(textField);
	return textField;
}
 
开发者ID:WorldGrower,项目名称:WorldGrower,代码行数:10,代码来源:JTextFieldFactory.java

示例2: createDefaultModel

import javax.swing.text.PlainDocument; //导入方法依赖的package包/类
@Override
protected Document createDefaultModel() {
    PlainDocument doc = (PlainDocument) super.createDefaultModel();
    doc.setDocumentFilter(new SpaceIgnoringDocumentFilter());
    return doc;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:7,代码来源:ClassNameTextField.java

示例3: initComponents

import javax.swing.text.PlainDocument; //导入方法依赖的package包/类
private void initComponents() {
	jrbOneShot = new JRadioButton("One Shot");
	jrbOneShot.setMnemonic(KeyEvent.VK_O);
	jrbOneShot.setActionCommand("One Shot");
	jrbOneShot.setSelected(true);
	jrbOneShot.addActionListener(this);
	
	jrbMonteCarlo = new JRadioButton("Monte-Carlo");
	jrbMonteCarlo.setMnemonic(KeyEvent.VK_M);
	jrbMonteCarlo.setActionCommand("Monte-Carlo");
	jrbMonteCarlo.addActionListener(this);
	
	buttonGroup = new ButtonGroup();
	buttonGroup.add(jrbOneShot); buttonGroup.add(jrbMonteCarlo);
	
	jlTimeUnits = new JLabel("Time units: ");
	jlMaxIterations = new JLabel("Max iterations: ");
	
	jlSelectExtensions = new JLabel("Select your report extension(s)");
	jcbExtensions = new ArrayList<JCheckBox>(6);
	jcbDocx = new JCheckBox("docx"); jcbExtensions.add(jcbDocx);
	jcbHtml = new JCheckBox("html"); jcbExtensions.add(jcbHtml);
	jcbPdf = new JCheckBox("pdf"); jcbExtensions.add(jcbPdf);
	jcbPptx = new JCheckBox("pptx"); jcbExtensions.add(jcbPptx);
	jcbOdt = new JCheckBox("odt"); jcbExtensions.add(jcbOdt);
	jcbXlsx = new JCheckBox("xlsx"); jcbExtensions.add(jcbXlsx);
	
	jcbPdf.setSelected(true);
	
	for(JCheckBox jcb : jcbExtensions) jcb.setEnabled(false);
	
	this.jlSelectModelingProject = new JLabel("Select your modeling project");
	this.jcbModelingProjects = new JComboBox<String>();
	
	// Retrieval of all user workspaces modeling projects
	for(String project : WorkspaceManager.getModelingProjects())
		this.jcbModelingProjects.addItem(project);
	this.jcbModelingProjects.setSelectedIndex(0);
	this.jcbModelingProjects.addActionListener(this);
	this.jcbModelingProjects.setEnabled(false);
	
	this.jlSelectReportTemplate = new JLabel("Select the report template you want to use");
	this.jcbReportTemplates = new JComboBox<String>();
	
	// Retrieval of all report templates of the selected project (the first one by default)
	for(String template : WorkspaceManager.getTemplates(this.jcbModelingProjects.getItemAt(0)))
		this.jcbReportTemplates.addItem(template);
	if(this.jcbReportTemplates.getModel().getSize() == 0)
		this.jcbReportTemplates.addItem("No report templates available !");
	this.jcbReportTemplates.setSelectedIndex(0);
	this.jcbReportTemplates.addActionListener(this);
	this.jcbReportTemplates.setEnabled(false);
	
	jtfTimeUnits = new JTextField("1000");
	PlainDocument docTimeUnits = (PlainDocument) jtfTimeUnits.getDocument();
    docTimeUnits.setDocumentFilter(new IntFilter());
    
    jtfMaxIterations = new JTextField("100");
    PlainDocument docMaxIterations = (PlainDocument) jtfMaxIterations.getDocument();
    docMaxIterations.setDocumentFilter(new IntFilter());
    // "One Shot" simulation selected by default
	jtfMaxIterations.setEnabled(false); 
    
	jtfTimeUnits.setColumns(5);
	jtfMaxIterations.setColumns(5);
	
	jbStart = new JButton("Start");
	jbStart.addActionListener(this);
	jbStop = new JButton("Stop");
	jbStop.addActionListener(this);
	jbStop.setEnabled(false);
	
	jpLoader = new PanelLoader("status bar", 100);
}
 
开发者ID:cetic,项目名称:SimQRI,代码行数:75,代码来源:SimulationManagementWindow.java

示例4: _init

import javax.swing.text.PlainDocument; //导入方法依赖的package包/类
private void _init()
{
	PlainDocument pd = new PlainDocument();
	pd.setDocumentFilter(getFilter());
	setDocument(pd);
}
 
开发者ID:PathVisio,项目名称:pathvisio,代码行数:7,代码来源:CompleterTextArea.java

示例5: getXsd

import javax.swing.text.PlainDocument; //导入方法依赖的package包/类
protected JComponent getXsd(JsonNode type, boolean editable) {
	DocumentFilter filter = null;

	if(type != null && type.getNodeType() == JsonNodeType.STRING) {
		switch (type.asText()) {
		case "xsd:unsignedLong":
			filter = new IntegerRangeDocumentFilter(BigInteger.ZERO, MAX_UNSIGNED_LONG);
			break;
		case "xsd:unsignedInt":
			filter = new IntegerRangeDocumentFilter(BigInteger.ZERO, MAX_UNSIGNED_INT);
			break;
		case "xsd:unsignedShort":
			filter = new IntegerRangeDocumentFilter(BigInteger.ZERO, MAX_UNSIGNED_SHORT);
			break;
		case "xsd:unsignedByte":
			filter = new IntegerRangeDocumentFilter(BigInteger.ZERO, MAX_UNSIGNED_BYTE);
			break;
		case "xsd:long":
			filter = new IntegerRangeDocumentFilter(MIN_LONG, MAX_LONG);
			break;
		case "xsd:int":
			filter = new IntegerRangeDocumentFilter(MIN_INT, MAX_INT);
			break;
		case "xsd:short":
			filter = new IntegerRangeDocumentFilter(MIN_SHORT, MAX_SHORT);
			break;
		case "xsd:byte":
			filter = new IntegerRangeDocumentFilter(MIN_BYTE, MAX_BYTE);
			break;
		case "xsd:boolean":
			filter = new BooleanDocumentFilter();
			break;
		}
	}


	JTextField XsdComponent = new JTextField();

	JTextComponent textComponent = (JTextComponent) XsdComponent;
	textComponent.setEditable(editable);
	if(type != null) {
		BasicTextUI textFieldUI = new HintTextFieldUI(" " + type, editable, Color.GRAY);
		textComponent.setUI(textFieldUI);
		textComponent.setToolTipText(type.toString());
	}


	if (filter == null) {
		log.warn("TextField created without input control for type: " + type);
	} else {
		PlainDocument pd = (PlainDocument) textComponent.getDocument();
		pd.setDocumentFilter(filter);
		log.info("TextField created with input control for type: " + type + ", " + filter);
	}

	return XsdComponent;
}
 
开发者ID:thingweb,项目名称:thingweb-gui,代码行数:58,代码来源:ThingPanelUI.java

示例6: IntegerComponent

import javax.swing.text.PlainDocument; //导入方法依赖的package包/类
public IntegerComponent(boolean allowsNegative){
	DocumentFilter filter = new IntegerDocumentFilter(allowsNegative);
	PlainDocument doc = new PlainDocument();
	doc.setDocumentFilter(filter);
	setDocument(doc);
}
 
开发者ID:clearlyspam23,项目名称:JAnGLE,代码行数:7,代码来源:IntegerComponent.java

示例7: initDialog

import javax.swing.text.PlainDocument; //导入方法依赖的package包/类
private void initDialog() {
    textField = new JTextField(20);
    PlainDocument doc = (PlainDocument) textField.getDocument();
    doc.setDocumentFilter(new NumberFilter());

    Object[] controls = { "Specify poll interval (in seconds):", textField };
    Object[] options = { OK_STRING, CANCEL_STRING };

    optionPane = new JOptionPane(controls, JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION, null, options, options[0]);
    setContentPane(optionPane);

    addComponentListener(new ComponentAdapter() {
        @Override
        public void componentShown(ComponentEvent ce) {
            textField.requestFocusInWindow();
        }
    });

    optionPane.addPropertyChangeListener(new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent e) {

            if (isVisible() && JOptionPane.VALUE_PROPERTY.equals(e.getPropertyName())) {

                Object value = optionPane.getValue();

                if (value == JOptionPane.UNINITIALIZED_VALUE) {
                    return;
                }

                switch (value.toString()) {
                case OK_STRING:
                    String v = textField.getText();
                    if (checkValue(v)) {
                        pollInterval = Integer.parseInt(v, 10);
                        setVisible(false);
                    } else {
                        //to let PropertyChangeEvent fire next time the user presses button
                        optionPane.setValue(JOptionPane.UNINITIALIZED_VALUE);
                    }
                    break;

                case CANCEL_STRING:
                    pollInterval = null;
                    setVisible(false);
                    break;
                }
            }
        }

    });
}
 
开发者ID:scristalli,项目名称:SQL-Developer-4-keepalive,代码行数:53,代码来源:PollIntervalDialog.java

示例8: JIntegerField

import javax.swing.text.PlainDocument; //导入方法依赖的package包/类
/**
 * Creates a new {@link JIntegerField}.
 */
public JIntegerField() {
    PlainDocument doc = new PlainDocument();
    doc.setDocumentFilter(filter);
    setDocument(doc);
}
 
开发者ID:shred,项目名称:jshred,代码行数:9,代码来源:JIntegerField.java


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