C
C
cot0322016-01-30 12:00:24
Java
cot032, 2016-01-30 12:00:24

How to set the format of a Java text field?

How to set Java Swing textbox format?

jft1 = new JFormattedTextField(nb1);
          jft1.setBounds(300, 60, 200, 30);
          add(jft1);

So that only the type int or double is entered into it?
What to use?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
C
cot032, 2016-01-31
@cot032

Вот решение

private JFormattedTextField amountField;
         private NumberFormat amountFormat;
  
        amountField = new JFormattedTextField(amountFormat);
        amountField.setValue(new Double(amount));
        amountField.setColumns(10);

        JPanel fieldPane = new JPanel(new GridLayout(0,1));
        fieldPane.add(amountField);
        amountFormat = NumberFormat.getNumberInstance()

K
Konstantin Malyarov, 2016-01-30
@Konstantin18ko

stackoverflow.com/questions/11093326/restricting-j...
Или так:
stackoverflow.com/questions/18084104/accept-only-n...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question