setBound(boolean) - Method in class java.beans.PropertyDescriptor 
Updates to "bound" properties will cause a "PropertyChange" event to get fired when the property is changed. 
setBounds(int, int, int, int) - Method in class java.awt.Rectangle 
Sets the bounding Rectangle of this Rectangle to the specified x, y, width, and height. 
setBounds(int, int, int, int) - Method in class java.awt.Component 
Moves and resizes this component. 
setBounds(Rectangle) - Method in class java.awt.List.AccessibleAWTList.AccessibleAWTListChild 
Sets the bounds of this object in the form of a Rectangle object. 
setBounds(Rectangle) - Method in class java.awt.MenuComponent.AccessibleAWTMenuComponent 
Sets the bounds of this object in the form of a Rectangle object. 
setBounds(Rectangle) - Method in class java.awt.Rectangle 
Sets the bounding Rectangle of this Rectangle to match the specified Rectangle. 
setBounds(Rectangle) - Method in class java.awt.Component 
Moves and resizes this component to conform to the new bounding rectangle r. 
setBounds(Rectangle) - Method in class java.awt.Component.AccessibleAWTComponent 
Sets the bounds of this object in the form of a Rectangle object. 
setBounds(Rectangle) - Method in interface javax.accessibility.AccessibleComponent 
Sets the bounds of this object in the form of a Rectangle object. 
setBounds(Rectangle) - Method in class javax.swing.JList.AccessibleJList.AccessibleJListChild 
  
setBounds(Rectangle) - Method in class javax.swing.JTree.AccessibleJTree.AccessibleJTreeNode 
  
setBounds(Rectangle) - Method in class javax.swing.JTable.AccessibleJTable.AccessibleJTableCell 
  
setBounds(Rectangle) - Method in class javax.swing.table.JTableHeader.AccessibleJTableHeader.AccessibleJTableHeaderEntry setPreferredSize(Dimension) - Method in class javax.swing.JComponent 
Sets the preferred size of this component. Sets the signature provider's name. 
setSize(Dimension) - Method in class java.awt.List.AccessibleAWTList.AccessibleAWTListChild 
Resizes this object so that it has width and height. 
setSize(Dimension) - Method in class java.awt.MenuComponent.AccessibleAWTMenuComponent 
Resizes this object. 
setSize(Dimension) - Method in class java.awt.Rectangle 
Sets the size of this Rectangle to match the specified Dimension. 
setSize(Dimension) - Method in class java.awt.Dimension 
Sets the size of this Dimension object to the specified size. 
setSize(Dimension) - Method in class java.awt.Component 
Resizes this component so that it has width d.width and height d.height. 
setSize(Dimension) - Method in class java.awt.Component.AccessibleAWTComponent 
Resizes this object so that it has width width and height. 
setSize(Dimension) - Method in interface javax.accessibility.AccessibleComponent 
Resizes this object so that it has width and height. 
setSize(Dimension) - Method in class javax.swing.JList.AccessibleJList.AccessibleJListChild 
  
setSize(Dimension) - Method in class javax.swing.JTree.AccessibleJTree.AccessibleJTreeNode 
  
setSize(Dimension) - Method in class javax.swing.JTable.AccessibleJTable.AccessibleJTableCell 
  
setSize(Dimension) - Method in class javax.swing.table.JTableHeader.AccessibleJTableHeader.AccessibleJTableHeaderEntry 
  
setSize(Dimension2D) - Method in class java.awt.geom.Dimension2D 
Sets the size of this Dimension2D object to match the specified size. 
setSize(double, double) - Method in class java.awt.Dimension 
Sets the size of this Dimension object to the specified width and height in double precision. 
setSize(double, double) - Method in class java.awt.geom.Dimension2D 
Sets the size of this Dimension object to the specified width and height. 
setSize(double, double) - Method in class java.awt.print.Paper 
Sets the width and height of this Paper object, which represents the properties of the page onto which printing occurs. 
setSize(float, float) - Method in class javax.swing.text.PlainView 
Sets the size of the view. 
setSize(float, float) - Method in class javax.swing.text.AsyncBoxView 
Sets the size of the view. 
setSize(float, float) - Method in class javax.swing.text.WrappedPlainView 
Sets the size of the view. 
setSize(float, float) - Method in class javax.swing.text.BoxView 
Sets the size of the view. 
setSize(float, float) - Method in class javax.swing.text.View 
Sets the size of the view. 
setSize(float, float) - Method in class javax.swing.text.html.ImageView 
Sets the size of the view. 
setSize(int) - Method in class java.util.Vector 
Sets the size of this vector. 
setSize(int) - Method in class javax.swing.DefaultListModel 
Sets the size of this list. 
setSize(int, int) - Method in class java.awt.Rectangle 
Sets the size of this Rectangle to the specified width and height. 
setSize(int, int) - Method in class java.awt.Dimension 
Sets the size of this Dimension object to the specified width and height. 
setSize(int, int) - Method in class java.awt.Component 
Resizes this component so that it has width width and height height. 
setSize(int, int) - Method in class javax.swing.SizeSequence 
Sets the size of the specified entry. 
setSize(long) - Method in class java.util.zip.ZipEntry 
Sets the uncompressed size of the entry data. 
setSizes(int[]) - Method in class javax.swing.SizeSequence 
Resets this SizeSequence object, using the data in the sizes argument. 
setSizes(int[]) - Method in class javax.swing.plaf.basic.BasicSplitPaneUI.BasicHorizontalLayoutManager 
Sets the sizes to newSizes.

解决方案 »

  1.   

    setSize():可以设置一个控件的大小(即宽度和高度,跟坐标没有关系);
    setBounds():可以设置一个控件的坐标及大小(即左上角坐标和宽度及高度).
      

  2.   

    setPreferred()是指定面板大小的,但要配合ScrollPane()使用
    SizesetSize()指定控件的大小(宽,高);
    setBounds指定控件的坐标及大小(左上角坐标和宽度及高度).
      

  3.   


    setSize(),            设置宽度及高度setPreferredSize(),   得到组件的最佳Size。比如有一个JTextField, 它的大小就取决于它的text的长度、字体。setBounds()           设置左上角坐标和宽度及高度-------------------------
    没有最好,只有更好
    没有更细,只有更简
      

  4.   

    从使用的角度来说,有时会有点问题:1\setSize ()
    setSize()的参数是以象素为单位的
    setSize设置的width和height把标题栏和边框都算进去
    2\setPreferredSize()
    只是向布局管理器建议,但布局管理器接受不接受还很难说,有时你需要把布局管理器设为空3\setBounds有时要在上面加一句:this.getContentPane.setLayout(null);把布局器取消掉
      

  5.   

    请看
    public class Testgui extends JFrame {
     JComboBox sizeCombo = new JComboBox(new Object[]{"null","100*100","200*200"});
     JList list = new JList(new Object[]{"item 1","item 2","item 3","item 4","item 5",});public void init(){
    final Container contentPane = getContentPane();
    list.setBorder(BorderFactory.createLineBorder(Color.black));
    sizeCombo.setSelectedIndex(0);
    contentPane.setLayout(new FlowLayout());
    contentPane.add(list);
    contentPane.add(new JLabel("preferred size for list:"));
    contentPane.add(sizeCombo);
    sizeCombo.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e){  int index = sizeCombo.getSelectedIndex();
      if(index==0)
        list.setPreferredSize(null);
      else if(index==1)
        list.setPreferredSize(new Dimension(100,100));
      else
        list.setPreferredSize(new Dimension(400,400));
      list.revalidate();
    }
    });
    System.out.println(list.getMaximumSize());}
    public static void main(String args[]){
      Testgui g = new Testgui();
      g.init();
      g.setVisible(true);
    }
    }这里改成list.setBounds(100,200);
           list.setSize(new Dimension(100,100));
    为何就不行呢?
      

  6.   

    高手呢,,CSDN不是说高说如云吗?