向面板里加JButton,JLable等等控件时,如何随意放置他们在面板里的位置?前提是不用任何插件,完全的用程序实现

解决方案 »

  1.   

    jTextField1.setBounds(new java.awt.Rectangle(402,219,158,32));
      

  2.   

    //先设置面板的布局管理器为空:
    pane.setLayout(null);
    //再设置组件,调整其大小。由 x 和 y 指定左上角的新位置,由 width 和 height 指定新的大小
    button.setBounds(int x, int y, int width, int height);