第二章—1

來源:互聯網
上載者:User

程式SimpleInternalFrame和LnFListener要點:

1.JLayeredPane 為 JFC/Swing 容器添加了深度,允許組件在需要時互相重疊,JInternalFrame 內容窗格是添加子組件的地方,通常,可將 JInternalFrame 添加到 JDesktopPane 中(JDesktopPane extends JLayeredPane).

注意:internalFrame的使用跟JFrame幾乎一樣,可以最大化、最小化、關閉視窗、加入菜單等功能;
唯一不同的是JinternalFrame是lightweight component ,也就是說JInternalFrame不能單獨出現,必須依附在最上層組件上。
由於這個特色,JInternalFrame能夠利用java提供的Look and Feel功能作出完全不同於原有作業系統所提供的視窗外型,也比JFrame更具有彈性。

2.JPanel預設是FlowLayout.CENTER

    Panel p = new Panel(); //JPanel預設是FlowLayout.CENTER
    //p.setLayout(new FlowLayout(FlowLayout.LEFT));

JFrame中的ContentPane的預設布局是BorderLayout

3.JInternalFrame建構函式:
public JInternalFrame(String title,
                      boolean resizable,  如果為 true,則可以調整內部表單的大小
                      boolean closable,    如果為 true,則可以關閉內部表單
                      boolean maximizable,  如果為 true,則可以最大化內部表單
                      boolean iconifiable)  如果為 true,則可以表徵圖化內部表單

4.UIManager.setLookAndFeel(lnfName);   //建立新的外觀風格,lnfName為字串

SwingUtilities.updateComponentTreeUI(frame);  //更新群組件

//例如:lnfName = "com.apple.mrj.swing.MacLookAndFeel";代表mac風格
     

5.implements ActionListener:

public void actionPerformed(ActionEvent e) {}

e.getActionCommand().equals("Mac")//Mac為JButton的字串.

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.