Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.awt.BorderLayout;
import java.text.NumberFormat;

import javax.swing.JFormattedTextField;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class Main {
    public static void main(String[] args) {
        NumberFormat numberFormatGuFalse = NumberFormat.getNumberInstance();
        numberFormatGuFalse.setGroupingUsed(false);
        JFormattedTextField jftFieldGuFalse = new JFormattedTextField(numberFormatGuFalse);

        NumberFormat numberFormatGuTrue = NumberFormat.getNumberInstance();
        // numberFormatGuFalse.setGroupingUsed(true); // not necessary as is default
        JFormattedTextField jftFieldGuTrue = new JFormattedTextField(numberFormatGuTrue);

        JPanel panel = new JPanel(new BorderLayout());
        panel.add(jftFieldGuFalse, BorderLayout.NORTH);
        panel.add(jftFieldGuTrue, BorderLayout.SOUTH);

        JFrame frame = new JFrame();
        frame.getContentPane().add(panel);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.pack();
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
    }
}