栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验

[填空题] 下面ButtonFrame类创建了一个容器,包含有3个按键。 import javax.swing.*; public class ButtonFrame extends JFrame {

面试经验 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

[填空题] 下面ButtonFrame类创建了一个容器,包含有3个按键。 import javax.swing.*; public class ButtonFrame extends JFrame {

[填空题] 下面Buttonframe类创建了一个容器,包含有3个按键。 import javax.swing.*; public class Buttonframe extends Jframe { JButton Button1= new JButton("Button1"); JButton Button2= new JButton("Button2"); JButton Button3= new JButton("Button3"); public Buttonframe() {super("Buttonframe");setSize(100,150);setDefaultCloseOperation(Jframe.EXIT_ON_CLOSE);JPane1 pane = new JPanel();pane.add(Buttonl);pane.add(Button2);pane.add(Button3); 【12】 ; } public static void main(String args[]) { Buttonframe bf= new Buttonframe(); bf.show(); } } 请在程序代码中的画线处添上正确的语句,使程序完整。


参考答案:

setContentPane(pane)

问题解析:

本题考查向swing容器添加组件的基本知识。往容器添加组件,可将容器分解为窗格,这是容器内的容器,再将组件添加到容器的内容窗格中。可以使用下列步骤在容器的内容窗格中添加组件。 ① 创建一个窗格。 ② 使用它的add(Component)方法在窗格中添加组件。 ③ 以窗格为参数调用setContentpane(Container)。
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/257629.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号