當前位置: 首頁>>代碼示例>>Java>>正文


Java DefaultFormatter.setOverwriteMode方法代碼示例

本文整理匯總了Java中javax.swing.text.DefaultFormatter.setOverwriteMode方法的典型用法代碼示例。如果您正苦於以下問題:Java DefaultFormatter.setOverwriteMode方法的具體用法?Java DefaultFormatter.setOverwriteMode怎麽用?Java DefaultFormatter.setOverwriteMode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.text.DefaultFormatter的用法示例。


在下文中一共展示了DefaultFormatter.setOverwriteMode方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: NumberField

import javax.swing.text.DefaultFormatter; //導入方法依賴的package包/類
/** Creates a new instance of NumberField */
public NumberField() {
    
    // define a custom input verifier
    this.setInputVerifier(new NumberVerifier());
    
    // create a formatter for displaying and editing
    DefaultFormatter formatter = new DefaultFormatter();
    
    // allow the user to completely delete all text
    formatter.setAllowsInvalid(true);
    
    // typing should insert new characters and not overwrite old ones
    formatter.setOverwriteMode(false);
    
    // commit on edit, otherwise a property change event is generated
    // when the field loses the focus and the value changed since it gained
    // the focus.
    formatter.setCommitsOnValidEdit(true);
    
    // getValue should return a Double object
    formatter.setValueClass(java.lang.Double.class);
    
    // the kind of formatter getFormatter should return
    this.setFormatterFactory(new DefaultFormatterFactory(formatter));
    
    // default value is 0
    this.setValue(new Double(0));
}
 
開發者ID:berniejenny,項目名稱:MapAnalyst,代碼行數:30,代碼來源:NumberField.java

示例2: createField

import javax.swing.text.DefaultFormatter; //導入方法依賴的package包/類
private EditorField createField(String text, String prototype, String tooltip) {
    DefaultFormatter formatter = new DefaultFormatter();
    formatter.setOverwriteMode(false);
    EditorField field = new EditorField(new DefaultFormatterFactory(formatter), this, SwingConstants.LEFT, text, prototype, tooltip);
    field.setEnabled(mIsEditable);
    add(field);
    return field;
}
 
開發者ID:richardwilkes,項目名稱:gcs,代碼行數:9,代碼來源:AdvantageEditor.java

示例3: createTextField

import javax.swing.text.DefaultFormatter; //導入方法依賴的package包/類
/**
 * Creates a new text field.
 *
 * @param parent The parent.
 * @param title The title of the field.
 * @param value The initial value.
 * @return The newly created field.
 */
protected EditorField createTextField(Container parent, String title, Object value) {
    DefaultFormatter formatter = new DefaultFormatter();
    formatter.setOverwriteMode(false);
    EditorField field = new EditorField(new DefaultFormatterFactory(formatter), this, SwingConstants.LEFT, value, null);
    parent.add(new LinkedLabel(title, field));
    parent.add(field);
    return field;
}
 
開發者ID:richardwilkes,項目名稱:gcs,代碼行數:17,代碼來源:WeaponEditor.java

示例4: addStringCompareField

import javax.swing.text.DefaultFormatter; //導入方法依賴的package包/類
/**
 * @param compare The current string compare object.
 * @return The field that allows a string comparison to be changed.
 */
protected EditorField addStringCompareField(StringCriteria compare) {
    DefaultFormatter formatter = new DefaultFormatter();
    formatter.setOverwriteMode(false);
    EditorField field = new EditorField(new DefaultFormatterFactory(formatter), this, SwingConstants.LEFT, compare.getQualifier(), null);
    field.putClientProperty(StringCriteria.class, compare);
    add(field);
    return field;
}
 
開發者ID:richardwilkes,項目名稱:gcs,代碼行數:13,代碼來源:EditorPanel.java

示例5: customInit

import javax.swing.text.DefaultFormatter; //導入方法依賴的package包/類
private void customInit() {
    setFocusLostBehavior(COMMIT);
    if (getFormatter() instanceof DefaultFormatter) {
        final DefaultFormatter d = (DefaultFormatter)getFormatter();
        AbstractAction toggleOverwrite = new AbstractAction() {
            public void actionPerformed(ActionEvent e) {
                d.setOverwriteMode(!(d.getOverwriteMode()));
            }
        };
        getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_INSERT, 0), TOGGLE_OVERWRITE_MODE_ACTION);
        getActionMap().put(TOGGLE_OVERWRITE_MODE_ACTION, toggleOverwrite);
    }
}
 
開發者ID:shevek,項目名稱:spring-rich-client,代碼行數:14,代碼來源:PatchedJFormattedTextField.java

示例6: configure

import javax.swing.text.DefaultFormatter; //導入方法依賴的package包/類
public void configure(JFormattedTextField textField, DefaultFormatter formatter) {
	textField.setFocusLostBehavior(JFormattedTextField.PERSIST);
	formatter.setOverwriteMode(false);
	formatter.setAllowsInvalid(true);
	formatter.setCommitsOnValidEdit(true);
}
 
開發者ID:shevek,項目名稱:spring-rich-client,代碼行數:7,代碼來源:ValueCommitPolicy.java

示例7: initGUI

import javax.swing.text.DefaultFormatter; //導入方法依賴的package包/類
/**
 * Initializes the graphical user interface for this search implementation.
 * Consists of a textfield for the search term and a checkbox, that is used
 * to hide all nodes that don't match a search string.
 */
private void initGUI() {
	mSearchInputPanel = new JPanel();
	mSearchInputPanel.setLayout(new BoxLayout(mSearchInputPanel,
			BoxLayout.X_AXIS));

	DefaultFormatter formatter = new DefaultFormatter();
	formatter.setOverwriteMode(false);
	formatter.setCommitsOnValidEdit(true);
	mInputTextfield = new JFormattedTextField(formatter);
	mInputTextfield.setToolTipText("<html>Search terms separator: <b>"
			+ SEARCH_TERM_DELIMITER + "</b><br>"
			+ "Inner search term separator: <b>"
			+ SUB_SEARCH_TERM_DELIMITER + "</b><br>"
			+ "Exact match enclosing character: <b>" + ENCLOSING_CHAR
			+ "</b><br>"
			+ "Example: ip,10.0.0;mac,\"aa:bb:cc:dd:ee:ff\"<br>" 
			+ " detects and highlights all nodes that <b>contain</b> the strings "
			+ "<i>ip</i> and <i>10.0.0</i>,<br>"
			+ "as well as all nodes that <b>contain</b> the string mac and <b>exactly contain</b> "
			+ "the value <i>aa:bb:cc:dd:ee:ff</i>" + "</html>");

	mInputTextfield.addPropertyChangeListener(new PropertyChangeListener() {
		@Override
		public void propertyChange(PropertyChangeEvent evt) {
			mSearchableGraphPanel.search(mInputTextfield.getText());
		}
	});

	mHideSearchMismatchCheckbox = new JCheckBox();
	mHideSearchMismatchCheckbox.addItemListener(new ItemListener() {
		@Override
		public void itemStateChanged(ItemEvent e) {
			mSearchableGraphPanel
					.setHideSearchMismatches(mHideSearchMismatchCheckbox
							.isSelected());
		}
	});

	mSearchInputPanel.add(new JLabel("Search: "));
	mSearchInputPanel.add(mInputTextfield);
	mSearchInputPanel.add(new JLabel("Hide search mismatches: "));
	mSearchInputPanel.add(mHideSearchMismatchCheckbox);
}
 
開發者ID:trustathsh,項目名稱:visitmeta,代碼行數:49,代碼來源:SimpleSearchAndNoFilter.java


注:本文中的javax.swing.text.DefaultFormatter.setOverwriteMode方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。