题目内容
本题程序的功能是主窗口有一个按钮、一个文本域和一个复选框,初始时窗口的大小是不能调整的,勾选复选框后,窗口大小就可以进行调整,如果取消勾选复选框,则窗口的大小又不能调整,单击按钮可以关闭程序。请将下述程序补充完整(注意:不得改动程序的结构,不得增行或删行)。 import java.awt.*; import java.awt.event.*; class MyFrame extends Frame______ Checkbox box; TextArea text; Button button; MyFrame(String s) super (s); box = new Checkbox("设置窗口是否可调整大小"); text = new TextArea(12,12); button = new Button("关闭窗口"); button.addActionListener(this); box.addItemListener(this); setBounds(100,100,200,300); setVisible(true); add(text,BorderLayout.CENTER); add(box,BorderLayout.SOUTH); add(button,BorderLayout.NORTH); ______; validate (); public void itemStateChanged(ItemEvent e) if (box.getState() == true) setResizable(true); else setResizable(false); public void actionPerformed(ActionEvent e) dispose(); class simple public static void main(String args[]) new MyFrame("simple");
查看答案
搜索结果不匹配?点我反馈
更多问题