Presentation is loading. Please wait.

Presentation is loading. Please wait.

SWING 2018/11/23.

Similar presentations


Presentation on theme: "SWING 2018/11/23."— Presentation transcript:

1 SWING 2018/11/23

2 SWING JAVA2平台提供SWING取代AWT,SWING元件繼承JComponent,名稱都以”J”開頭。 2018/11/23

3 SWING的程式架構 CH10_1_2 JFrame JPanel JLable JButton 2018/11/23

4 Event Adapter 10_1_3 ComponentAdapter : ComponentListener
ContainerAdapter:ContainerListener FocusAdapter:FocusListener KeyAdapter:KeyListener MouseAdapter:MouseListener MouseMotionAdapter:MouseMotionListner WindowAdapter: WindowListener 2018/11/23

5 JFrame JFrame類別物件為一個擁有框線、標題圖示按鈕的WINDOW視窗,各式窗擁有隱藏的功能表(MenuBar)和ContentPane元件。 2018/11/23

6 JFrame JFrame、JFrame(String) setContentPane() getContentPane()
setMenuBar(JMenuBar) getMenuBar() setSzie(int, int) pack() setVisible(boolean) setLocation(int,int) setBounds(int,int,int,int) 10_2_1 2018/11/23

7 JApplet Ch10_2_2 SWING元件需要用JApplet來建立容器類別,而JApplet也有ContentPane物件。
2018/11/23

8 JDialog JDialog() JDialog(JFrame) JDialog(JFrame, Boolean)
JDialog(JFrame, String, Boolean) 2018/11/23

9 showMessageDialog() JoptionPane.ShowMessageDialog(jpane, “這是一個測試的訊息視窗”) 第三個參數無視窗標題 第四個參數為訊息種類 JOptionPane.WARNING_MESSAGE JOptionPane.ERROR_MESSAGE JOptionPane.INFORMATION_MESSAGE JOptionPane.QUESTION_MESSAGE JOptionPane.PLAIN_MESSAGE 2018/11/23

10 showOptionDialog() Ch10_2_3 Object[] options = {"showMessageDialog按鈕",
"showConfirmDialog按鈕"}; int m = JOptionPane.showOptionDialog(jpane, "哪一個按鈕顯示警告訊息?", "操作問題", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); 2018/11/23

11 JPanel JPanel() JPanel(LayoutManager) setLayout(LayoutManager)
getLayout() Ch10_3_1 2018/11/23

12 JScrollPane JScrollPan() JScrollPan(Component) JScrollPan(int,int)
JScrollPane(Component, int, int) Ch10_3_2 2018/11/23

13 SWING版面配置 BorderLayout BorderLayout(), BorderLayout(int,int)
BorderLayout.CENTER BorderLayout.NORTH BorderLayout.SOUTH BorderLayout.EAST BorderLayout.WEST BorderLayout(), BorderLayout(int,int) setHgap(int), setVgap(int) Ch10_4_1 2018/11/23

14 CardLayout() CardLayout(),CardLayout(int,int) first(Container)
next(Container) previous(Container) last(Container) show(Container, String) Ch10_4_3 2018/11/23

15 GridLayout GridLayout(int,int) GridLayout(int,int,int,int)
getColumns(0 getRows() getHgap() getVgap() Ch10_4_4 2018/11/23

16 GridBagLayout GridLayout() GridBagConstraints()
setConstraints(Component, GridBagContraints) C10_4_5 2018/11/23

17 BoxLayout BoxLayout(Container, int) Box(int) createHorizontalBox()
createVerticalBox() createRigidArea() createHorizontalGlue() createVerticalGlue() Ch10_4_6 2018/11/23

18 SWING元件的框線 setBorder(Border) getBorder() Ch10_5 2018/11/23


Download ppt "SWING 2018/11/23."

Similar presentations


Ads by Google