简体   繁体   English

在Java中设置JTextField,JLabel和JButton的位置

[英]Set position of JTextField, JLabel and JButton in Java

When i run the program, the label textfield and button and so on are arranged randomly (label and button are in same line). 当我运行程序时, label textfieldbutton等等都是随机排列的(标签和按钮在同一行)。

How do I explicitly set the layout? 如何明确设置布局?

which technology do you use? 您使用哪种技术? Java Swing? Java Swing? Then I can recommend you the following manual: 然后,我可以向您推荐以下手册:

http://download.oracle.com/javase/tutorial/uiswing/layout/using.html#set http://download.oracle.com/javase/tutorial/uiswing/layout/using.html#set

You should work with so called "Layout Managers", which support you in arranging different labels, fields and so on. 您应该使用所谓的“布局管理器”,它可以帮助您安排不同的标签,字段等。

greets 打招呼

Try to use the setBounds(x,y,length,heigth) and setLayout(null) . 尝试使用setBounds(x,y,length,heigth)setLayout(null) So you can set its coordinates. 这样就可以设置它的坐标。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM