资源描述:
《图形界面设计程序精选试题》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、图形界面设计(二)选择题1x1=1分填空题1x2=2分程序填空题1x4=4分程序阅读题1x4=4分2008.106.以下关于菜单的叙述中,正确的是( )AA.菜单分三级定义,最高一级的是菜单条,菜单条中放菜单,菜单中放菜单项B.菜单分三级定义,最高一级的是菜单,菜单中放菜单条,菜单条中放菜单项C.菜单分两级定义,最高一级的是菜单,菜单中放菜单项D.菜单分两级定义,最高一级的是菜单条,菜单条中放菜单项16.Java语言为处理鼠标事件提供两个接口:_________接口和MouseMotionListener接口。MouseListener29.以下是生成菜单项对象
2、,以及菜单项选择事件处理方法的部分代码。要求当菜单项singingItem被选中时,在文本框text中输出“唱歌菜单项被选中!”的字样。……singingItem=new________("唱歌");//生成菜单项对象JMenuItem……publicvoidactionPerformed(ActionEvente){if(e.getSource()==singingItem)text.setText(e.________()+"菜单项被选中!");getActionCommand}35.阅读以下程序,请写出该程序的功能。滑动滚动条的滑块,在文本框显示块位置对应的数
3、值importjavax.swing.*;importjava.awt.*;importjava.awt.event.*;classMyScrollBarextendsJscrollBar{publicMyScrollBar(intinit,intlen,intlow,inthigh){第16页共16页super(JScrollBar.HORIZONTAL,init,len,low,high);}}classMyWindowextendsJFrameimplementsAdjustmentListener{privateJTextFieldtext;MyWindow
4、(Strings){super(s);MyScrollBarmyBar=newMyScrollBar(10,10,0,255);Containercon=this.getContentPane();con.setLayout(newGridLayout(2,1));this.setSize(200,100);this.setLocation(100,100);myBar.addAdjustmentListener(this);text=newJTextField("",20);con.add(text);con.add(myBar);this.setVisible(
5、true);}publicvoidadjustmentValueChanged(AdjustmentEvente){MyScrollBarmyBar=(MyScrollBar)e.getAdjustable();text.setText(""+myBar.getValue());}}publicclassClass1{publicstaticvoidmain(String[]args){MyWindowmyWindow=newMyWindow("text5_4");}}第16页共16页2009.16.在以下Swing组件中,能为它指定布局管理器的是()DA.JScr
6、ollBar对象B.JMenuBar对象C.JComboBox对象D.JDialog对象28.以下小应用程序能响应鼠标按动的事件,当鼠标在正文区的某个位置被点击时,就在该位置显示一个记号“×”,程序限制最多保留最新20个位置。importjava.applet.*;importjava.awt.*;importjavax.swing.*;importjava.awt.event.*;classMyPanelextendsJPanel{publicvoidprint(Graphicsg,intx,inty)(g.setColor(Color.red);g.drawLi
7、ne(x-5,y-5,x+5,y+5);g.drawLine(x+5,y-5,x-5,y+5);}}classMyWindowextendsJFrameimplementsMouseListener{finalintMaxMarks=20;intcurrentMarks=0,markCount=0;Pointmarks[]=newPoint[MaxMarks];MyPanelpanel;MyWindow(){this.setLocation(100,100);this.setSize(300,300);Containercon=this.getContentPa