?? mainframe.java
字號:
package jinternalframedemo;import java.awt.*;import java.awt.event.*;import javax.swing.*;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2002</p> * <p>Company: </p> * @author unascribed * @version 1.0 */public class MainFrame extends JFrame {// private JPanel contentPane; private JDesktopPane desktop = new JDesktopPane();// private BorderLayout borderLayout1 = new BorderLayout(); private JMenuBar jMenuBar1 = new JMenuBar(); private JMenu jMenu1 = new JMenu(); private JMenuItem jMenuItem1 = new JMenuItem(); //Construct the frame public MainFrame() { enableEvents(AWTEvent.WINDOW_EVENT_MASK); try { jbInit(); } catch(Exception e) { e.printStackTrace(); } } //Component initialization private void jbInit() throws Exception { //setIconImage(Toolkit.getDefaultToolkit().createImage(MainFrame.class.getResource("[Your Icon]")));// contentPane.setLayout(borderLayout1); desktop.putClientProperty("JDesktopPane.dragMode", "outline"); this.setContentPane(desktop); this.setJMenuBar(jMenuBar1); this.setSize(new Dimension(400, 300)); this.setTitle("JInternalFrameDemo"); jMenu1.setFont(new java.awt.Font("Dialog", 0, 12)); jMenu1.setText("Option"); jMenuItem1.setFont(new java.awt.Font("Dialog", 0, 12)); jMenuItem1.setText("Add Frame"); jMenuItem1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jMenuItem1_actionPerformed(e); } }); jMenuBar1.add(jMenu1); jMenu1.add(jMenuItem1); } //Overridden so we can exit when window is closed protected void processWindowEvent(WindowEvent e) { super.processWindowEvent(e); if (e.getID() == WindowEvent.WINDOW_CLOSING) { System.exit(0); } } void jMenuItem1_actionPerformed(ActionEvent e) { OwnInternalFrame frame = new OwnInternalFrame(); frame.setVisible(true); //necessary as of kestrel desktop.add(frame); try { frame.setSelected(true); } catch (java.beans.PropertyVetoException err) { err.printStackTrace(); } }}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -