[英]Smaller TextFields in a bigger TextField Java
I want a textfield which looks like this : 我想要一个看起来像这样的文本字段:
textfield . 文本域 。 textfield .
文本域 。 textfield.
文本域。 textfield
文本域
and to enter just numbers in the textfields. 并在文本字段中仅输入数字。 Can you help me, please?
你能帮我吗? :)
:)
You don't need a parent textfield to act as a container for 4 textfields. 您不需要父文本字段即可充当4个文本字段的容器。 Place 4 textfields inside a panel.
在面板内放置4个文本字段。
The steps to achieve this in java swing: 在Java swing中实现此目标的步骤:
1.Create a JPanel
with a white background. 1.创建一个白色背景的
JPanel
。
2.Add 4 JTextField
s seperated by JLabel
with value .
2.添加4个由
JLabel
分隔的JTextField
和value .
(Use the GridLayout to keep them in a single row). (使用GridLayout将它们放在一行中)。
3.Disable the highlighting of JTextField
s and its border or make the textfield transparent 3.禁用
JTextField
的高亮显示及其边框或使文本字段透明
4.Instead add a border to the JPanel
when any of the JTextfield
s accepts input. 4.当任何
JTextfield
接受输入时,请在JPanel
添加边框。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.