?? modeldialogframe.java
字號(hào):
package modeldialog;import java.awt.*;import java.awt.event.*;import javax.swing.*;/** * <p>Title: Model Dialog Demo</p> * <p>Description: This is a Model Dialog demo</p> * <p>Copyright: Copyright (c) 2002</p> * <p>Company: d6-125</p> * @author Liujun * @version 1.0 */public class ModelDialogFrame extends JFrame { JPanel contentPane; JButton jButton1 = new JButton(); JButton jButton2 = new JButton(); GridBagLayout gridBagLayout1 = new GridBagLayout(); //Construct the frame public ModelDialogFrame() { enableEvents(AWTEvent.WINDOW_EVENT_MASK); try { jbInit(); } catch(Exception e) { e.printStackTrace(); } } //Component initialization private void jbInit() throws Exception { //setIconImage(Toolkit.getDefaultToolkit().createImage(ModelDialogFrame.class.getResource("[Your Icon]"))); contentPane = (JPanel) this.getContentPane(); jButton1.setText("以非模式方式調(diào)用"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jButton1_actionPerformed(e); } }); contentPane.setLayout(gridBagLayout1); this.setSize(new Dimension(400, 91)); this.setTitle("Model Dialog Frame Demo"); jButton2.setText("以模式方式調(diào)用"); jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jButton2_actionPerformed(e); } }); contentPane.add(jButton1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 269, 0)); contentPane.add(jButton2, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 281, -1)); } //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 jButton1_actionPerformed(ActionEvent e) { (new MyDialog(this,"非模態(tài)對(duì)話框",false)).show(); } void jButton2_actionPerformed(ActionEvent e) { (new MyDialog(this,"模態(tài)對(duì)話框",true)).show(); }}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -