package com.imooc;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Ex5_3 extends JFrame implements ItemListener,ActionListener
{
JCheckBox box;JTextArea text;JButton button;
MyFrame(String s)
{
super(s);
box=new JCheckBox("设置窗口大小可否调整");
text=new JTextArea(12,12);
button=new JButton("关闭窗口");
button.addActionListener(this);
box.addItemListener(this);
setSize(300,200);
setVisible(true);
add(text,BorderLayout.CENTER);
add(box,BorderLayout.SOUTH);
add(button,BorderLayout.NORTH);
setResizeable(false);
vaildate();
}
public void itemStateChanged(ItemEvent e){
if(box.isSelected()==true)setResizable(true);
else setResizable(false);
}
public void actionPerformed(ActionEvent e)
{
dispose();
}
}
class Ex5_3{
public static void main(String[] args)
{
// TODO Auto-generated method stub
new MyFrame("窗口");
}
}
添加回答
举报
0/150
提交
取消