문제

I want to use a JFormattedTextField that can input fraction numbers. As Java doc specifies its format should set within the constructor. But I’m using NetBeans IDE, the constructor of the JFormattedTextField is a generated code , so I don’t know how to specify a format.

And if you can please direct me to a helpful tutorial.

도움이 되었습니까?

해결책

To customize the creation code of a Swing element in NetBeans, right-click the element and select Customize code.... In the following pop-up, click the drop-down menu next to the code snippet and select Custom creation. Then you can specify the code yourself as such:

DecimalFormat df = DecimalFormat.getInstance();
// do some manipulation to the DecimalFormat object if desired
jFormattedTextField = new javax.swing.JFormattedTextField(df);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top