相关疑难解决方法(0)

JFormattedTextField问题

在此输入图像描述 在此输入图像描述

1)如何将Cursor设置为0,而不使用Caret或Focus包装到invokeLater()(使用@camickr 格式文本字段提示可以解决),是否有人知道另一种方式

在此输入图像描述 在此输入图像描述

2)How to reset Formatter有时(通过TAB从键盘提高Focus),重置不起作用,并且在focusLost(空字段)格式化程序返回/重新生成的字符或字符串返回(最后在setText("")之前知道;),

注意:知道代码或下面的代码is only this way,关于如何从OTN重置Formatter,但是他们可怕的搜索rulles ....,只有代码(问题或答案由Jeanette ???)

import java.awt.event.*;
import java.beans.*;
import java.text.ParseException;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.text.Document;

public class FormattedNull {

    private JFormattedTextField field;
    private JButton focusButton;

    private JComponent createContent() {
        JComponent content = new JPanel();
        field = new JFormattedTextField(new Integer(55));
        field.setColumns(20);
        field.addPropertyChangeListener(getPropertyChangeListener());
        field.getDocument().addDocumentListener(getDocumentListener());
        content.add(field);
        focusButton = new JButton("just something focusable");
        focusButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                field.setValue(0);
                field.requestFocusInWindow();
            }
        });
        content.add(focusButton);
        return content;
    } …
Run Code Online (Sandbox Code Playgroud)

java swing formatter jformattedtextfield

8
推荐指数
1
解决办法
4645
查看次数

标签 统计

formatter ×1

java ×1

jformattedtextfield ×1

swing ×1