图像界面组件

图像界面组件

ID:44387812

大小:1.05 MB

页数:62页

时间:2019-10-21

图像界面组件_第1页
图像界面组件_第2页
图像界面组件_第3页
图像界面组件_第4页
图像界面组件_第5页
资源描述:

《图像界面组件》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库

1、第15讲.图像界面组件常用用户界面组件JButton按钮jbtJCheckBox复选框jchkJRadioButton单选框jrbJLabel标签jlblJTextField文本域jtfJTextArea文本区域jtaJComboBox组合框jcboJList列表jlstGUIClassHierarchy(Swing) GUI类的继承关系常用用户界面组件Java事件对象的层次结构用户行为、源对象和事件对应关系SourceEventType UserActionObjectGeneratedClickabutton点击按钮JButtonActio

2、nEventClickacheckbox点击复选框JCheckBoxItemEvent,ActionEventClickaradiobutton单击单选框JRadioButtonItemEvent,ActionEventPressreturnonatextfield文本回车JTextFieldActionEventSelectanewitem选一个新项JComboBoxItemEvent,ActionEventSelectalistnewitem选多项JListJSelectionListEventWindowopened,closed,etc

3、.WindowWindowEventMousepressed,released,etc.ComponentMouseEventKeyreleased,pressed,etc.ComponentKeyEventAbstractButton1JButtonJButtonConstructors构造方法ThefollowingareJButtonconstructors:JButton()JButton(Stringtext)JButton(Stringtext,Iconicon)JButton(Iconicon)JButtonProperties常

4、用属性texticonmnemonichorizontalAlignmentverticalAlignmenthorizontalTextPositionverticalTextPositionDefaultIcons,PressedIcon,andRolloverIcon默认图标、按下图标和翻转图标Aregularbuttonhasadefaulticon,pressedicon,androllovericon.Normally,youusethedefaulticon.Allothericonsareforspecialeffects.Ap

5、ressediconisdisplayedwhenabuttonispressedandarollovericonisdisplayedwhenthemouseisoverthebuttonbutnotpressed.(A)Defaulticon(B)Pressedicon(C)RollovericonDemoTestButtonIcons.javaimportjavax.swing.*;publicclassTestButtonIconsextendsJFrame{publicstaticvoidmain(String[]args){//Cr

6、eateaframeandsetitspropertiesJFrameframe=newTestButtonIcons();frame.setTitle("ButtonIcons");frame.setSize(165,80);frame.setLocationRelativeTo(null);//Centertheframeframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);frame.setVisible(true);}publicTestButtonIcons(){ImageIconu

7、sIcon=newImageIcon("image/usIcon.gif");ImageIconcaIcon=newImageIcon("image/caIcon.gif");ImageIconukIcon=newImageIcon("image/ukIcon.gif");JButtonjbt=newJButton("Clickit",usIcon);jbt.setPressedIcon(caIcon);jbt.setRolloverIcon(ukIcon);add(jbt);}}HorizontalAlignments水平对齐Horizont

8、alalignmentspecifieshowtheiconandtextareplacedhorizontallyonabutton.Youcans

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。