contentPane.setLayout(null);
// or
import com.borland.jbcl.layout.*;
contentPane.setLayout( new XYLayout() );

解决方案 »

  1.   

    import javax.swing.*;public class myFrame extends JFrame {
    JPanel contentPanel=(JPanel)this.getContentPane();
    JPanel jp=new JPanel();
    JButton jb=new JButton("1");
    JButton jb1=new JButton("2");
    public myFrame() {
    super("myFrame");
    this.setSize(800,600);
    this.setResizable(true);
    this.setLocation(this.getToolkit().getScreenSize().width/2-400,this.getToolkit().getScreenSize().height/2-300);
    contentPanel.setLayout(new BorderLayout());
    contentPanel.add("Center",jp);
    jp.setLayout(null);
    jp.add(jb);
    jb.setBounds(100,100,100,100);
    jp.add(jb1);
    jb1.setBounds(2100,210,50,50);
    this.setVisible(true);
    }public static void main(String args[]) {
    new myFrame();
    }
    }
      

  2.   

    or
    import javax.swing.*;public class myFrame extends JFrame {
    JPanel contentPanel=(JPanel)this.getContentPane();
    JPanel jp=new JPanel();
    JButton jb=new JButton("1");
    JButton jb1=new JButton("2");
    public myFrame() {
    super("myFrame");
    this.setSize(800,600);
    this.setResizable(true);
    this.setLocation(this.getToolkit().getScreenSize().width/2-400,this.getToolkit().getScreenSize().height/2-300);
    contentPanel.setLayout(new BorderLayout());
    contentPanel.add("Center",jp);
    jp.setLayout(new FlowLayout());
    jp.add(jb);
    jp.add(jb1);
    this.setVisible(true);
    }public static void main(String args[]) {
    new myFrame();
    }
    }
      

  3.   

    getToolkit().getScreenSize()用这个可以取得屏幕尺寸,剩下的自己想把
      

  4.   

    定义组键的尺寸,可以用GridBagConstraints里的,ipadx和ipday确定,
    也可以用setPreferredSize(new Dimension(int x,int y))来设置大小!
      

  5.   

    只要布局用borderlayout就可以实现。
      

  6.   

    可以尝试:
    setLayout(null);
    再用
    setBounds(x,y,width,height);
    定位.
    应该可以,虽然很多书上不推荐用setLayout(null)
      

  7.   

    maybe you need to use multi-layouts to solve that problem. I am not sure of what results you want ultimately.