程式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的字串.