首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
本题使用下拉菜单来控制字体。窗口中有一个标签和一个下拉菜单,当选中下拉菜单中的任一项字体时,标签h字符串的字体就随之改变。 importjavfl.awt.*; importjava.awt.event.*; importjavax.swing.*; cl
本题使用下拉菜单来控制字体。窗口中有一个标签和一个下拉菜单,当选中下拉菜单中的任一项字体时,标签h字符串的字体就随之改变。 importjavfl.awt.*; importjava.awt.event.*; importjavax.swing.*; cl
admin
2013-12-02
23
问题
本题使用下拉菜单来控制字体。窗口中有一个标签和一个下拉菜单,当选中下拉菜单中的任一项字体时,标签h字符串的字体就随之改变。
importjavfl.awt.*;
importjava.awt.event.*;
importjavax.swing.*;
classComboBoxFrameextendsJFrame{
publicComboBoxFrame( );
setTitle(”java2”);
setSize(300,200);
addWindowListener(newWindowAdapter( ){
publicvoidwindowClosing(WindowEvente){
System.exit(0);
}
1);
style=newJComboBox( );
style.setEditable(true);
style.addhem(“Serif”);
style.addhem(“SansSerif”);
style.addhem(“Monospaced”);
style.addhem(“Dialog”);
style.addhem(“Dialoglnput”);
style.addActionListener(this);
JPanelP=newJPanel( );
P.add(style);
getC0ntentPane( ).add(P,“South”);
panel=newComboBoxTestPanel( );
getC0ntentPane( ).add(panel,“Center”);
}
publicvoidactionPerformed(ActionEventevt){
JComboBoxsource=(JComboBox);
Stringitem=(String)source.getSeleetedhem( );
panel.setStyle(item);
}
privateComboBoxTestPanelpanel;
privateJComboBoxstyle;
}
classComboBoxTestPanelextendsJPanel{
publicComboBoxTestPanel( ){
setStyle(”Serif”);
}
publicvoidsetStyle(Strings){
setFont(newFont(s,Font.PLAIN,12));
repaint( );
}
publicvoidpaintComponent(Graphicsg){
super.paintComponent(g);
g.drawstring(”WelcometoChina!”.0,50);
}
}
publicclassjava2{
publicstaticvoidmain(String[]args){
JFrameframe=newComboBoxFrame( );
frame.show( );
}
选项
答案
第1处:implementsActionListener第2处:evl.getSource()
解析
第1处是实现ActionListener接口,程序中有窗口监听器的注册;第2处返回ActionEvent动作事件的最初发生对象。
转载请注明原文地址:https://kaotiyun.com/show/PQID777K
本试题收录于:
二级Java题库NCRE全国计算机二级分类
0
二级Java
NCRE全国计算机二级
相关试题推荐
某甲向银行取款时,银行工作人员因点钞失误多付给1万元,甲以这1万元作本钱经商,获利5千元,其中2千元为其劳务管理费用成本。一个月后银行发现了多付款的事实,要求甲退回,甲不同意。下列有关该案的哪一表述是正确的?()
行政复议是监督行政的一种制度化、规范化的(),也是国家行政机关系统内部为依法行政而进行自我约束的重要机制。
“两个共同”是新世纪新阶段民族工作的主题,“两个共同”是指()。
法院审理一起受贿案时,被告人甲称因侦查人员刑讯不得已承认犯罪事实,并讲述受到刑讯的具体时间。检察机关为证明侦查讯问程序合法,当庭播放了有关讯问的录音录像,并提交了书面说明。关于该录音录像的证据种类,下列哪一选项是正确的?()
我国佛教艺术驰名中外,云冈石窟、龙门石窟和莫高窟三大石窟举世皆知。以下关于三大石窟地理位置的描述,正确的是()。
《公务员法》规定,对公务员考核的内容包括德、能、勤、绩、廉五个方面,重点考核()。
某单位欲将甲、乙、丙、丁4个大学生分配到3个不同的岗位实习,若每个岗位至少分到1名大学生,且甲、乙两人被分在同一岗位.则不同的分配方法共有()。
发展服务业要注意避免产业空心化,这一提示是必要的,但认为中国经济增长中现代服务业快速发展就一定导致产业空心化这种看法是不对的,也是相当危险的,在实际工作中持这种看法,就会使中国经济失去快速发展现代服务业的重要窗口期。实际上,形成以服务业为主的产业结构,并不
开放经济在运行中的自动平衡机制有哪些?
关于法律关系主体的权利义务与作为法律规则内容的权利义务,表述正确的是()。
随机试题
根据相关要求,卫生技术人员需占医院人员总数的
区别事物阴阳属性的“征兆”是
甲公司2009年获得一项外观设计专利。乙公司未经甲公司许可,以生产经营为目的制造该专利产品。丙公司未经甲公司许可以生产经营为目的的()行为构成对该专利权的侵犯。
房地产经纪机构最新的内部组织结构模式是:()。
工程监理单位授权总监理工程组织完成监理任务而产生的代理属于()。
根据《国境卫生检疫法》的规定,夜间入境时,在船舶的明显处垂直悬挂下列灯号:( )表示本船有染疫或有染疫嫌疑,请即实施检疫。
某制药厂(一般纳税人)生产的各类应税和免税药品,2015年1月份至2月份发生如下经济业务:(1)1月份销售抗生素药品取得含税销售额117000元,由本厂运输部门运输,运费单独核算,收到不含税运费3000元。(2)1月份销售其他应税药品,收到含税货款2
西周关于婚姻制度的“六礼”制度中,男方请媒人向女方送礼品提亲,称为()。
在实时系统中,在给定时间内系统可以处理的事件总数称为___________【67】。实时系统中的另一个指标用于衡量输入数据的有效等待时间,超过了这个时间,处理器即使接收到输入数据,也不能够给出有用的输出数据,这个时间的名称是___________【68】。
ResearchersatUCLAMedicalCenterinLosAngeles,Californiafoundthata12-minutebedsidevisitwithadogcanhelpeaseanxi
最新回复
(
0
)