Please read the following code.
import java.awt.FlowLayout; import java.awt.GridLayout; import javax.swing.*; import javax.swing.text.AbstractDocument; import javax.swing.text.AttributeSet; import javax.swing.text.BadLocationException; import javax.swing.text.DocumentFilter; public class Bean extends JFrame { private JTextField field1, field2, field3, field4; private JLabel text; private JButton ok, cancel; private JPanel centerPanel,southPanel, textPanel; private GridLayout grid; private FlowLayout flow1, flow2; public Bean() {
Here I am trying to limit the number of characters to 5. OK, it stops inserting more characters when it reaches 5, but the fact is that it also does not allow you to delete inserted characters, replace or anything. Please help me fix this problem. Thanks
source share