版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、会计学1java语言语言(yyn)程序设计基础篇第八英文程序设计基础篇第八英文第一页,共39页。2第1页/共39页第二页,共39页。3第2页/共39页第三页,共39页。4ButtonLabelText fieldCheck BoxRadio ButtonCombo Box第3页/共39页第四页,共39页。specific components through their respective agents, known as peers. AWT is fine for developing simple graphical user interfaces, but not for devel
2、oping comprehensive GUI projects. Besides, AWT is prone to platform-specific bugs because its peer-based approach relies heavily on the underlying platform. With the release of Java 2, the AWT user-interface components were replaced by a more robust, versatile, and flexible library known as Swing co
3、mponents. Swing components are painted directly on canvases using Java code, except for components that are subclasses of java.awt.Window or java.awt.Panel, which must be drawn using native GUI on a specific platform. Swing components are less dependent on the target platform and use less of the nat
4、ive GUI resource. For this reason, Swing components that dont rely on native GUI are referred to as lightweight components, and AWT components are referred to as heavyweight components. 5第4页/共39页第五页,共39页。6 Dimension Font FontMetrics Component Graphics Object Color Container Panel Applet Frame Dialog
5、 Window JComponent JApplet JFrame JDialog Swing Components in the javax.swing package Lightweight Heavyweight Classes in the java.awt package 1 LayoutManager * 第5页/共39页第六页,共39页。7 Dimension Font FontMetrics Component Graphics Object Color Container Panel Applet Frame Dialog Window JComponent JApplet
6、JFrame JDialog Swing Components in the javax.swing package Lightweight Heavyweight Classes in the java.awt package 1 LayoutManager * JPanel Container classes can contain other GUI components.第6页/共39页第七页,共39页。8 Dimension Font FontMetrics Component Graphics Object Color Container Panel Applet Frame Di
7、alog Window JComponent JApplet JFrame JDialog Swing Components in the javax.swing package Lightweight Heavyweight Classes in the java.awt package 1 LayoutManager * JPanel The helper classes are not subclasses of Component. They are used to describe the properties of GUI components such as graphics c
8、ontext, colors, fonts, and dimension.第7页/共39页第八页,共39页。9 JMenuItem JCheckBoxMenuItem AbstractButton JComponent JMenu JRadioButtonMenuItem JToggleButton JCheckBox JRadioButton JComboBox JInternalFrame JLayeredPane JList JMenuBar JOptionPane JPopupMenu JProgressBar JFileChooser JScrollBar JScrollPane J
9、Separator JSplitPane JSlider JTabbedPane JTable JTableHeader JTextField JTextComponent JTextArea JToolBar JToolTip JTree JRootPane JPanel JPasswordField JColorChooser JLabel JEditorPane JSpinner JButton 第8页/共39页第九页,共39页。10 JMenuItem JCheckBoxMenuItem AbstractButton JComponent JMenu JRadioButtonMenuI
10、tem JToggleButton JCheckBox JRadioButton JComboBox JInternalFrame JLayeredPane JList JMenuBar JOptionPane JPopupMenu JProgressBar JFileChooser JScrollBar JScrollPane JSeparator JSplitPane JSlider JTabbedPane JTable JTableHeader JTextField JTextComponent JTextArea JToolBar JToolTip JTree JRootPane JP
11、anel JPasswordField JColorChooser JLabel JEditorPane JSpinner JButton 第9页/共39页第十页,共39页。11 JMenuItem JCheckBoxMenuItem AbstractButton JComponent JMenu JRadioButtonMenuItem JToggleButton JCheckBox JRadioButton JComboBox JInternalFrame JLayeredPane JList JMenuBar JOptionPane JPopupMenu JProgressBar JFi
12、leChooser JScrollBar JScrollPane JSeparator JSplitPane JSlider JTabbedPane JTable JTableHeader JTextField JTextComponent JTextArea JToolBar JToolTip JTree JRootPane JPanel JPasswordField JColorChooser JLabel JEditorPane JSpinner JButton 第10页/共39页第十一页,共39页。12AWTEventFontFontMetricsComponentGraphicsOb
13、jectColorCanvasButtonTextComponentLabelListCheckBoxGroupCheckBoxChoiceContainerPanelAppletFrameDialogFileDialogWindowTextFieldTextAreaMenuComponentMenuItemMenuBarMenuScrollbarLayoutManager第11页/共39页第十二页,共39页。13第12页/共39页第十三页,共39页。14Runimport javax.swing.*;public class MyFrame public static void main(S
14、tring args) JFrame frame = new JFrame(Test Frame); frame.setSize(400, 300); frame.setVisible(true); frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE); MyFrame第13页/共39页第十四页,共39页。15/ Add a button into the frameframe.getContentPane().add( new JButton(OK);RunMyFrameWithComponentsTitle barContent pan
15、e第14页/共39页第十五页,共39页。16/ Add a button into the frameframe.getContentPane().add( new JButton(OK);Title barContent pane/ Add a button into the frameframe.add( new JButton(OK);第15页/共39页第十六页,共39页。17 javax.swing.JFrame +JFrame() +JFrame(title: String) +setSize(width: int, height: int): void +setLocation(x
16、: int, y: int): void +setVisible(visible: boolean): void +setDefaultCloseOperation(mode: int): void +setLocationRelativeTo(c: Component): void +pack(): void Creates a default frame with no title. Creates a frame with the specified title. Specifies the size of the frame. Specifies the upper-left corn
17、er location of the frame. Sets true to display the frame. Specifies the operation when the frame is closed. Sets the location of the frame relative to the specified component. If the component is null, the frame is centered on the screen. Automatically sets the frame size to hold the components in t
18、he frame. 第16页/共39页第十七页,共39页。18第17页/共39页第十八页,共39页。19第18页/共39页第十九页,共39页。20ShowFlowLayoutRun第19页/共39页第二十页,共39页。21 java.awt.FlowLayout -alignment: int -hgap: int -vgap: int +FlowLayout() +FlowLayout(alignment: int) +FlowLayout(alignment: int, hgap: int, vgap: int) The alignment of this layout manager (
19、default: CENTER). The horizontal gap of this layout manager (default: 5 pixels). The vertical gap of this layout manager (default: 5 pixels). Creates a default FlowLayout manager. Creates a FlowLayout manager with a specified alignment. Creates a FlowLayout manager with a specified alignment, horizo
20、ntal gap, and vertical gap. The get and set methods for these data fields are provided in the class, but omitted in the UML diagram for brevity. 第20页/共39页第二十一页,共39页。22ShowGridLayoutRun第21页/共39页第二十二页,共39页。23 java.awt.GridLayout -rows: int -columns: int -hgap: int -vgap: int +GridLayout() +GridLayout(
21、rows: int, columns: int) +GridLayout(rows: int, columns: int, hgap: int, vgap: int) The number of rows in this layout manager (default: 1). The number of columns in this layout manager (default: 1). The horizontal gap of this layout manager (default: 0). The vertical gap of this layout manager (defa
22、ult: 0). Creates a default GridLayout manager. Creates a GridLayout with a specified number of rows and columns. Creates a GridLayout manager with a specified number of rows and columns, horizontal gap, and vertical gap. The get and set methods for these data fields are provided in the class, but om
23、itted in the UML diagram for brevity. 第22页/共39页第二十三页,共39页。24add(Component, constraint), where constraint is BorderLayout.EAST, BorderLayout.SOUTH, BorderLayout.WEST, BorderLayout.NORTH, or BorderLayout.CENTER. 第23页/共39页第二十四页,共39页。25ShowBorderLayoutRun第24页/共39页第二十五页,共39页。26 java.awt.BorderLayout -hga
24、p: int -vgap: int +BorderLayout() +BorderLayout(hgap: int, vgap: int) The horizontal gap of this layout manager (default: 0). The vertical gap of this layout manager (default: 0). Creates a default BorderLayout manager. Creates a BorderLayout manager with a specified number of horizontal gap, and ve
25、rtical gap. The get and set methods for these data fields are provided in the class, but omitted in the UML diagram for brevity. 第25页/共39页第二十六页,共39页。27第26页/共39页第二十七页,共39页。28第27页/共39页第二十八页,共39页。29第28页/共39页第二十九页,共39页。30Font NamesStandard font names that are supported in all platforms are: SansSerif, S
26、erif, Monospaced, Dialog, or DialogInput.Font StyleFont.PLAIN (0), Font.BOLD (1), Font.ITALIC (2), and Font.BOLD + Font.ITALIC (3)第29页/共39页第三十页,共39页。31第30页/共39页第三十一页,共39页。32第31页/共39页第三十二页,共39页。33第32页/共39页第三十三页,共39页。34TestPanelsRun A button A textfield 12 buttons frame p2 p1 第33页/共39页第三十四页,共39页。35 ja
27、va.awt.Container +add(comp: Component): Component +add(comp: Component, index: int): Component +remove(comp: Component): void +getLayout(): LayoutManager +setLayout(l: LayoutManager): void +paintComponents(g: Graphics): void Adds a component to the container. Adds a component to the container with t
28、he specified index. Removes the component from the container. Returns the layout manager for this container. Sets the layout manager for this container. Paints each of the components in this container. java.awt.Component -font: java.awt.Font -background: java.awt.Color -foreground: java.awt.Color -preferredSize: Dimension -visible: boolean +getWidth(): int +getHeight(): int +getX(): int +getY(): int The font of this component. The background color of this component. The fo
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 二零二五年度农村个人地基使用权转让与农村生态环境保护合作协议3篇
- 二零二五年度木工次结构构件加工与运输服务合同3篇
- 2025年度精密仪器制造工厂整体转让协议3篇
- 二零二五年度农用房屋抵押农村旅游发展贷款服务协议
- 二零二五年度企业研发成果保密协议2篇
- 二零二五年度公司管理人员员工持股计划聘用合同3篇
- 二零二五年度农村宅基地房屋出售与绿化维护合同2篇
- 二零二五年度老年人紧急救援服务合作协议3篇
- 二零二五年度绿色能源项目合作协议3篇
- 2025年度全新私人合同:私人美容师及美容服务合同3篇
- 圣诞节元旦搞笑小品就剧本:浪子回家
- 2023年海南省天一大联考高一化学第一学期期末达标测试试题含解析
- 银行工会个人总结报告
- 部编版小学语文2-6年级词语表
- 甘肃省平凉市崆峒区2024届九年级英语第一学期期末统考模拟试题含解析
- 测绘法规与工程管理(第2版)完整全套教学课件
- 酒店预订确认函
- 小学课爱国主义教育教案
- 触摸一体机整机检验标准 1.0
- 关于人员的处置方案
- 资源环境与可持续发展PPT完整全套教学课件
评论
0/150
提交评论