?? frame1.java~49~
字號(hào):
package joptionpane;import java.awt.*;import java.awt.event.*;import javax.swing.*;import com.borland.jbcl.layout.*;public class Frame1 extends JFrame { JPanel contentPane; VerticalFlowLayout verticalFlowLayout1 = new VerticalFlowLayout(); JButton jButton1 = new JButton(); JButton jButton2 = new JButton(); JButton jButton3 = new JButton(); JButton jButton4 = new JButton(); JButton jButton5 = new JButton(); /**Construct the frame*/ public Frame1() { enableEvents(AWTEvent.WINDOW_EVENT_MASK); try { jbInit(); } catch(Exception e) { e.printStackTrace(); } } /**Component initialization*/ private void jbInit() throws Exception { //setIconImage(Toolkit.getDefaultToolkit().createImage(Frame1.class.getResource("[Your Icon]"))); contentPane = (JPanel) this.getContentPane(); jButton1.setText("警告"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jButton1_actionPerformed(e); } }); contentPane.setLayout(verticalFlowLayout1); this.setResizable(false); this.setSize(new Dimension(212, 235)); this.setTitle("JOptionPane演示程序"); jButton2.setText("提示"); jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jButton2_actionPerformed(e); } }); jButton3.setText("錯(cuò)誤"); jButton3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jButton3_actionPerformed(e); } }); jButton4.setText("提問"); jButton4.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jButton4_actionPerformed(e); } }); jButton5.setText("無類型"); contentPane.add(jButton1, null); contentPane.add(jButton2, null); contentPane.add(jButton3, null); contentPane.add(jButton4, null); contentPane.add(jButton5, null); } /**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) { JOptionPane.showMessageDialog(this,"這是一條警告信息!", "警告信息", JOptionPane.WARNING_MESSAGE); } void jButton2_actionPerformed(ActionEvent e) { JOptionPane.showConfirmDialog(this,"這是一條提示信息!","提示信息",JOptionPane.OK_CANCEL_OPTION,JOptionPane.INFORMATION_MESSAGE); } void jButton3_actionPerformed(ActionEvent e) { JOptionPane.showConfirmDialog(this,"這是一條錯(cuò)誤信息!","錯(cuò)誤信息",JOptionPane.YES_NO_CANCEL_OPTION,JOptionPane.ERROR_MESSAGE); } void jButton4_actionPerformed(ActionEvent e) { JOptionPane.showConfirmDialog(this,new JTextField("答案"),"請(qǐng)輸入問題的答案",JOptionPane.YES_NO_CANCEL_OPTION,JOptionPane.QUESTION_MESSAGE); }}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -