禁止改变大小
public class ControlFormSize extends JFrame{
 public ControlFormSize(){//构造方法
setTitle("设置窗体大小");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//设置关闭方式
setSize(400,300);
JPanel contentPane=new JPanel();//创建面板对象
contentPane.setLayout(new BorderLayout(0,0));//设置布局
setContentPane(contentPane);//设置内容面班
JLabel label=new JLabel("宽度:400,高度:300");//标签
contentPane.add(label,BorderLayout.CENTER);
JButton b=new JButton("禁值改变窗体大小");
contentPane.add(b,BorderLayout.NORTH);
b.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
do_button_actionPerformed(e);
}
});
 }
  public void do_button_actionPerformed(ActionEvent e){
setResizable(false);
  }
 
public static void main(String[] args) {
ControlFormSize cf=new ControlFormSize();
cf.setVisible(true);
}


 }图标在窗口显示一个圆形图标
public class DrawIcon implements Icon{
 private int width;
 private int height;
 public int getIconHeight(){
return this.height;
 }
 public int getIconWidth(){
return this.width;
 }
 public DrawIcon(int width,int height){
this.width=width;
this.height=height;
 }
 public void paintIcon(Component arg0,Graphics arg1,int x,int y){
arg1.fillOval(x,y,width,height);//绘制一个圆形
 }


public static void main(String[] args) {
DrawIcon icon=new DrawIcon(15,15);
JLabel j=new JLabel("测试",icon,SwingConstants.CENTER);
JFrame jf=new JFrame();
Container c=jf.getContentPane();
j.setIcon(icon);//为标签设置图标
c.add(j);
jf.setSize(250,200);//窗体大小,通过jframe对象实例化
jf.setVisible(true);//窗体显示

}


 }