本文整理匯總了Java中javax.swing.text.MaskFormatter.setPlaceholderCharacter方法的典型用法代碼示例。如果您正苦於以下問題:Java MaskFormatter.setPlaceholderCharacter方法的具體用法?Java MaskFormatter.setPlaceholderCharacter怎麽用?Java MaskFormatter.setPlaceholderCharacter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.text.MaskFormatter
的用法示例。
在下文中一共展示了MaskFormatter.setPlaceholderCharacter方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: DesktopTimeField
import javax.swing.text.MaskFormatter; //導入方法依賴的package包/類
public DesktopTimeField() {
UserSessionSource uss = AppBeans.get(UserSessionSource.NAME);
digitWidth = getDigitWidth();
timeFormat = Datatypes.getFormatStringsNN(uss.getLocale()).getTimeFormat();
resolution = DateField.Resolution.MIN;
formatter = new MaskFormatter();
formatter.setPlaceholderCharacter('_');
impl = new FlushableFormattedTextField(formatter);
FieldListener listener = new FieldListener();
impl.addFocusListener(listener);
impl.addKeyListener(listener);
setShowSeconds(timeFormat.contains("ss"));
}
示例2: AddIPDialog
import javax.swing.text.MaskFormatter; //導入方法依賴的package包/類
public AddIPDialog(JDependCooper frame) throws ParseException {
super();
this.frame = frame;
setSize(250, 100);
this.setLocationRelativeTo(null);// 窗口在屏幕中間顯示
this.setLayout(new BorderLayout());
MaskFormatter ipmask = new MaskFormatter("###.###.###.###");
ipmask.setPlaceholderCharacter(' ');
field = new JFormattedTextField(ipmask);
field.setFont(new Font("Courier", Font.PLAIN, 18));
field.setColumns(16);
this.add(BorderLayout.CENTER, field);
JPanel buttonPanel = new JPanel();
buttonPanel.add(this.createOkButton());
buttonPanel.add(this.createCloseButton());
this.add(BorderLayout.SOUTH, buttonPanel);
}
示例3: Formatacoes
import javax.swing.text.MaskFormatter; //導入方法依賴的package包/類
/** Inicializa os campos */
protected Formatacoes()
{
try {
cpf = new MaskFormatter("###.###.###-##");
cpf.setPlaceholderCharacter('_');
rg = new MaskFormatter("#########");
rg.setPlaceholderCharacter('_');
telefone = new MaskFormatter("####-####");
telefone.setPlaceholderCharacter('_');
telefone2 = new MaskFormatter("####-####");
telefone2.setPlaceholderCharacter('_');
data = new MaskFormatter("##/##/####");
data.setPlaceholderCharacter('_');
cep = new MaskFormatter("#####-###");
cep.setPlaceholderCharacter('_');
tipo = new MaskFormatter("U");
tipo.setPlaceholder(" ");
tipo.setValidCharacters("CFA");
} catch (ParseException e) {
JOptionPane.showMessageDialog(null,"ERRO: N�o foi poss�vel criar as m�scaras dos campos da janela.");
}
}
示例4: ScheduleDurationField
import javax.swing.text.MaskFormatter; //導入方法依賴的package包/類
/**
* @param value the duration to use for the initial value, may not be null
*/
public ScheduleDurationField(final Duration value) {
setInputVerifier(new TimeVerifier());
try {
final MaskFormatter mf = new MaskFormatter(MASKFORMAT);
mf.setPlaceholderCharacter('_');
mf.setValueClass(String.class);
final DefaultFormatterFactory dff = new DefaultFormatterFactory(mf);
setFormatterFactory(dff);
} catch (final ParseException pe) {
throw new FLLInternalException("Invalid format for MaskFormatter", pe);
}
setDuration(value);
}
示例5: ScheduleTimeField
import javax.swing.text.MaskFormatter; //導入方法依賴的package包/類
/**
* @param value the initial value for the widget
*/
public ScheduleTimeField(final LocalTime value) {
try {
final MaskFormatter mf = new MaskFormatter(MASKFORMAT);
mf.setPlaceholderCharacter('_');
mf.setValueClass(String.class);
final DefaultFormatterFactory dff = new DefaultFormatterFactory(mf);
setFormatterFactory(dff);
} catch (final ParseException pe) {
throw new FLLInternalException("Invalid format for MaskFormatter", pe);
}
setTime(value);
}
示例6: EditText
import javax.swing.text.MaskFormatter; //導入方法依賴的package包/類
public EditText(Value value, RadixOption radix, int width) {
super();
String mask = "";
GridBagConstraints gbc = new GridBagConstraints();
MaskFormatter formatter = new MaskFormatter();
DecimalFormat df = new DecimalFormat();
JLabel label = new JLabel("");
Color back = new Color(0xff, 0xf0, 0x99);
setUndecorated(true);
setModal(true);
setLayout(new GridBagLayout());
this.radix = radix;
bitWidth = width;
oldVal = value;
// System.err.println("Wdth:"+bitWidth);
try {
formatter.setPlaceholderCharacter('_');
if (radix == RadixOption.RADIX_16) {
label.setText("0x");
for (int i = 0; i < Math.ceil(bitWidth / 4.0); i++) {
mask += "H";
}
formatter.setMask(mask);
text = new JFormattedTextField(formatter);
text.setText(value.toHexString());
} else if (radix == RadixOption.RADIX_8) {
label.setText("0");
for (int i = 0; i < Math.ceil(bitWidth / 3.0); i++) {
mask += "#";
}
formatter.setInvalidCharacters("89");
formatter.setMask(mask);
text = new JFormattedTextField(formatter);
text.setText(value.toOctalString());
} else if (radix == RadixOption.RADIX_10_SIGNED) {
mask = "#;-#";
df.setParseIntegerOnly(true);
df.applyPattern(mask);
df.setMaximumIntegerDigits(11);
text = new JFormattedTextField(df);
text.setColumns(11);
// System.err.println("Val:" + value.toDecimalString(true));
text.setText(value.toDecimalString(true));
} else if (radix == RadixOption.RADIX_10_UNSIGNED) {
mask = "#;";
df.setParseIntegerOnly(true);
df.applyPattern(mask);
df.setMaximumIntegerDigits(10);
text = new JFormattedTextField(df);
text.setColumns(10);
// System.err.println("Val:" +
// value.toDecimalString(false));
text.setText(value.toDecimalString(false));
}
} catch (ParseException ex) {
Logger.getLogger(Pin.class.getName()).log(Level.SEVERE, null,
ex);
}
gbc.gridx = gbc.gridy = 0;
add(label, gbc);
gbc.gridx = 1;
gbc.gridwidth = GridBagConstraints.REMAINDER;
gbc.anchor = GridBagConstraints.BASELINE;
text.addKeyListener(this);
text.setBorder(null);
text.setBackground(back);
add(text, gbc);
pack();
}