本文整理匯總了Java中com.intellij.util.ui.UIUtil.fixFormattedField方法的典型用法代碼示例。如果您正苦於以下問題:Java UIUtil.fixFormattedField方法的具體用法?Java UIUtil.fixFormattedField怎麽用?Java UIUtil.fixFormattedField使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.intellij.util.ui.UIUtil
的用法示例。
在下文中一共展示了UIUtil.fixFormattedField方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: prepareNumberEditor
import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
protected JFormattedTextField prepareNumberEditor(@NonNls final String fieldName) {
final NumberFormat formatter = NumberFormat.getIntegerInstance();
formatter.setParseIntegerOnly(true);
final JFormattedTextField valueField = new JFormattedTextField(formatter);
Object value = ReflectionUtil.getField(getClass(), this, null, fieldName);
valueField.setValue(value);
valueField.setColumns(2);
// hack to work around text field becoming unusably small sometimes when using GridBagLayout
valueField.setMinimumSize(valueField.getPreferredSize());
UIUtil.fixFormattedField(valueField);
final Document document = valueField.getDocument();
document.addDocumentListener(new DocumentAdapter() {
@Override
public void textChanged(DocumentEvent evt) {
try {
valueField.commitEdit();
final Number number = (Number)valueField.getValue();
ReflectionUtil.setField(BaseInspection.this.getClass(), BaseInspection.this, int.class, fieldName, number.intValue());
}
catch (ParseException e) {
// No luck this time. Will update the field when correct value is entered.
}
}
});
return valueField;
}
示例2: createOptionsPanel
import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
/**
* Creates the options panel in the settings for user changeable options.
*
* @return the options panel
*/
@Override
public JComponent createOptionsPanel() {
JPanel panel = new JPanel(new GridBagLayout());
GridBagConstraints constraints = new GridBagConstraints();
constraints.gridx = 0;
constraints.gridy = 0;
constraints.weightx = 0.0;
constraints.anchor = GridBagConstraints.WEST;
constraints.fill = GridBagConstraints.NONE;
panel.add(new JLabel("Exclude classes (reg exp):"), constraints);
final JFormattedTextField excludeClassNamesField = new JFormattedTextField(new RegExFormatter());
excludeClassNamesField.setValue(excludeClassNamesPattern);
excludeClassNamesField.setColumns(25);
excludeClassNamesField.setInputVerifier(new RegExInputVerifier());
excludeClassNamesField.setFocusLostBehavior(JFormattedTextField.COMMIT);
excludeClassNamesField.setMinimumSize(excludeClassNamesField.getPreferredSize());
UIUtil.fixFormattedField(excludeClassNamesField);
Document document = excludeClassNamesField.getDocument();
document.addDocumentListener(new DocumentAdapter() {
@Override
protected void textChanged(DocumentEvent e) {
try {
excludeClassNamesField.commitEdit();
excludeClassNamesPattern = (Pattern)excludeClassNamesField.getValue();
excludeClassNames = excludeClassNamesPattern.pattern();
} catch (final Exception ignore) {}
}
});
constraints.gridx = 1;
constraints.gridy = 0;
constraints.weightx = 1.0;
constraints.anchor = GridBagConstraints.NORTHWEST;
constraints.fill = GridBagConstraints.NONE;
panel.add(excludeClassNamesField, constraints);
final CheckBox excludeExceptionCheckBox = new CheckBox("Ignore exception classes", this, "excludeException");
constraints.gridx = 0;
constraints.gridy = 1;
constraints.gridwidth = 2;
constraints.fill = GridBagConstraints.HORIZONTAL;
panel.add(excludeExceptionCheckBox, constraints);
final CheckBox excludeDeprecatedCheckBox = new CheckBox("Ignore deprecated classes", this, "excludeDeprecated");
constraints.gridy = 2;
panel.add(excludeDeprecatedCheckBox, constraints);
final CheckBox excludeEnumCheckBox = new CheckBox("Ignore enum classes", this, "excludeEnum");
constraints.gridy = 3;
panel.add(excludeEnumCheckBox, constraints);
final CheckBox excludeAbstractCheckBox = new CheckBox("Ignore abstract classes", this, "excludeAbstract");
constraints.gridy = 4;
panel.add(excludeAbstractCheckBox, constraints);
final CheckBox excludeInTestCodeCheckBox = new CheckBox("Ignore test classes", this, "excludeTestCode");
constraints.gridy = 5;
panel.add(excludeInTestCodeCheckBox, constraints);
final CheckBox excludeInnerClasses = new CheckBox("Ignore inner classes", this, "excludeInnerClasses");
constraints.gridy = 6;
constraints.weighty = 1.0;
panel.add(excludeInnerClasses, constraints);
return panel;
}