Reproduced from: http://blog.csdn.net/taoweiji2008/article/details/8585306
First, the layout of the relevant container is set to setlayout (null);
Then call the component's SetBounds () method
Set the position of the button to (100,100) long width, respectively, 60,25
Jbutton.setbounds (New Rectangle (100, 100, 60, 25));
[Java] View Plain copy import java.awt.container; import java.awt.dimension; Import java.awt.Rectangle; import java.awt.toolkit; import javax.swing.jbutton; import javax.swing.jcheckbox; import javax.swing.jcombobox; import javax.swing.jframe; import javax.swing.jpasswordfield; import javax.swing.jtextfield; public class log extends jframe { public static void main (String[] args) { log log = new log (); } private JButton btLog; private JTextField tfUser; private jpasswordfield tfpwd; private JCheckBox pwdKeep; private JComboBox adminType; public log () { super ("Fixed Asset Management system"); super.setsize (380, 292); super.setvisible (true); super.setdefaultcloseoperation (jframe.exit_on_close); centered (this); btlog = new jbutton ("Login record"); Btlog.setbounds (New rectangle (93, 220, 180, 30))//parameters are coordinates x,y, wide, high &nbSp; this.setlayout (null);/Set layout manager to empty this.add (btlog); tfUser = new JTextField (); tfuser.setbounds (New Rectangle ( 73, 115, 220, 25)); this.add (TfUser) ; tfpwd = new jpasswordfield (); tfpwd.setbounds (New rectangle (73, 150, 220, 25)); this.add (TFPWD); pwdkeep = new jcheckbox ("Remember Password"); pwdkeep.setbounds (New rectangle (68, 185, 110, 25));   this.add (pwdkeep); admintype = new jcombobox (new string[] { "General Staff", "admin", "Senior administrator"  }); admintype.setbounds (new rectangle (183, 185, 100, 25)); this.add (admintype); } //Layout Center method public void centered (Container container) { toolkit toolkit = toolkit.getdefaulttoolkit (); Dimension screenSize = Toolkit.getscreensize (); int w = Container.getwidth (); &nbsP; int h = container.getheight (); container.setbounds ((screensize.width - w) / 2, ( SCREENSIZE.HEIGHT - H) / 2, w, h); } }