Download presentation
Presentation is loading. Please wait.
1
Java @Ch12. Layout Managers 2011.02.25
2
Outline Java GUI API Layout Managers [Sample code] ShowFlowLayout.java 、 ShowGripLayout.java 、 ShowBorderLayout.java TestImageIcon.java
3
Java GUI API GUI: Graphical User Interface GUI classes can be classified into three group: 1. container classes 2. component classes 3. helper classes
4
Container classes: ex: JFrame, Jpanel, Japplet Component classes ex: JButton, JTextFiels, JTextArea, JComboBox, Jlist, JRadioButton Helper classes ex: Graphics, Color, Font, FontMetrics, Dimension
5
程式範例 : MyFrameWithComponents.java
6
Layout Managers FlowLayout: ( 水流 ) 最簡單的 layout 方式, 方向由左到右 GridLayout: ( 格子 ) 以指定行與列的矩陣方式排列 BorderLayout: ( 邊緣 ) 分為五種邊緣, North,West,East,South, 指定其一
7
程式範例 : ShowFlowLayout.java ShowGripLayout.java ShowBorderLayout.java
8
Image Icon Java currently supports three image formats: GIF 、 JPEG 、 PNG ImageIcon icon = new ImageIcon(“image/us.gif”); An image icon can be displayed in a label or a button using: new JLabel(imageIcon) new JButton(imageIcon)
9
程式範例 : TestImageIcon.java
10
程式練習 :
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.