java語(yǔ)言程序設(shè)計(jì)基礎(chǔ)篇第八英文學(xué)習(xí)教案_第1頁(yè)
java語(yǔ)言程序設(shè)計(jì)基礎(chǔ)篇第八英文學(xué)習(xí)教案_第2頁(yè)
java語(yǔ)言程序設(shè)計(jì)基礎(chǔ)篇第八英文學(xué)習(xí)教案_第3頁(yè)
java語(yǔ)言程序設(shè)計(jì)基礎(chǔ)篇第八英文學(xué)習(xí)教案_第4頁(yè)
java語(yǔ)言程序設(shè)計(jì)基礎(chǔ)篇第八英文學(xué)習(xí)教案_第5頁(yè)
已閱讀5頁(yè),還剩34頁(yè)未讀 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、會(huì)計(jì)學(xué)1java語(yǔ)言語(yǔ)言(yyn)程序設(shè)計(jì)基礎(chǔ)篇第八英文程序設(shè)計(jì)基礎(chǔ)篇第八英文第一頁(yè),共39頁(yè)。2第1頁(yè)/共39頁(yè)第二頁(yè),共39頁(yè)。3第2頁(yè)/共39頁(yè)第三頁(yè),共39頁(yè)。4ButtonLabelText fieldCheck BoxRadio ButtonCombo Box第3頁(yè)/共39頁(yè)第四頁(yè),共39頁(yè)。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頁(yè)/共39頁(yè)第五頁(yè),共39頁(yè)。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頁(yè)/共39頁(yè)第六頁(yè),共39頁(yè)。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頁(yè)/共39頁(yè)第七頁(yè),共39頁(yè)。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頁(yè)/共39頁(yè)第八頁(yè),共39頁(yè)。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頁(yè)/共39頁(yè)第九頁(yè),共39頁(yè)。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頁(yè)/共39頁(yè)第十頁(yè),共39頁(yè)。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頁(yè)/共39頁(yè)第十一頁(yè),共39頁(yè)。12AWTEventFontFontMetricsComponentGraphicsOb

13、jectColorCanvasButtonTextComponentLabelListCheckBoxGroupCheckBoxChoiceContainerPanelAppletFrameDialogFileDialogWindowTextFieldTextAreaMenuComponentMenuItemMenuBarMenuScrollbarLayoutManager第11頁(yè)/共39頁(yè)第十二頁(yè),共39頁(yè)。13第12頁(yè)/共39頁(yè)第十三頁(yè),共39頁(yè)。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頁(yè)/共39頁(yè)第十四頁(yè),共39頁(yè)。15/ Add a button into the frameframe.getContentPane().add( new JButton(OK);RunMyFrameWithComponentsTitle barContent pan

15、e第14頁(yè)/共39頁(yè)第十五頁(yè),共39頁(yè)。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頁(yè)/共39頁(yè)第十六頁(yè),共39頁(yè)。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頁(yè)/共39頁(yè)第十七頁(yè),共39頁(yè)。18第17頁(yè)/共39頁(yè)第十八頁(yè),共39頁(yè)。19第18頁(yè)/共39頁(yè)第十九頁(yè),共39頁(yè)。20ShowFlowLayoutRun第19頁(yè)/共39頁(yè)第二十頁(yè),共39頁(yè)。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頁(yè)/共39頁(yè)第二十一頁(yè),共39頁(yè)。22ShowGridLayoutRun第21頁(yè)/共39頁(yè)第二十二頁(yè),共39頁(yè)。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頁(yè)/共39頁(yè)第二十三頁(yè),共39頁(yè)。24add(Component, constraint), where constraint is BorderLayout.EAST, BorderLayout.SOUTH, BorderLayout.WEST, BorderLayout.NORTH, or BorderLayout.CENTER. 第23頁(yè)/共39頁(yè)第二十四頁(yè),共39頁(yè)。25ShowBorderLayoutRun第24頁(yè)/共39頁(yè)第二十五頁(yè),共39頁(yè)。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頁(yè)/共39頁(yè)第二十六頁(yè),共39頁(yè)。27第26頁(yè)/共39頁(yè)第二十七頁(yè),共39頁(yè)。28第27頁(yè)/共39頁(yè)第二十八頁(yè),共39頁(yè)。29第28頁(yè)/共39頁(yè)第二十九頁(yè),共39頁(yè)。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頁(yè)/共39頁(yè)第三十頁(yè),共39頁(yè)。31第30頁(yè)/共39頁(yè)第三十一頁(yè),共39頁(yè)。32第31頁(yè)/共39頁(yè)第三十二頁(yè),共39頁(yè)。33第32頁(yè)/共39頁(yè)第三十三頁(yè),共39頁(yè)。34TestPanelsRun A button A textfield 12 buttons frame p2 p1 第33頁(yè)/共39頁(yè)第三十四頁(yè),共39頁(yè)。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. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論