⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 joptionpaneexample1.java

📁 java 图像用户界面开发中的一个简单的JOptionPane 例子
💻 JAVA
字号:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class JOptionPaneExample1 extends JFrame implements ActionListener {

	static JButton b1,b2,b3,b4;
	public JOptionPaneExample1()
	{
		 super("hello,JOptionPane Dialog");
			// setSize(200,200);
			 setVisible(true);
			  b1=new JButton("message_dialog");
			  b2=new JButton("confirm_dialog");
			  b3=new JButton("input_dialog");
			  b4=new JButton("unKnown");
			  Container container=getContentPane();
			  container.setLayout(new GridLayout(5,0));
			  b1.addActionListener(this);
			  b2.addActionListener(this);
			  b3.addActionListener(this);
			  b4.addActionListener(this);
			 
			  container.add(b1);
			  container.add(b2);
			  container.add(b3);
			  container.add(b4);
			  pack();
			  container.setBackground(Color.blue);
			 
	}
	public static void main(String [] args)
	{
	 setDefaultLookAndFeelDecorated(true);
	 JOptionPaneExample1 jpe= new JOptionPaneExample1();
	 

	  jpe.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
	}
	public void actionPerformed(ActionEvent ae)
	{
		if(ae.getSource()==b1)
			JOptionPane.showMessageDialog(this,"hello,message_dialog");
		else if(ae.getSource()==b2)
			JOptionPane.showConfirmDialog(this, "hello, confirm dialog");
		else if(ae.getSource()==b3)
			JOptionPane.showInputDialog(this,"hello,input dialog");
		else 
			JOptionPane.showMessageDialog(this, "hello", "world", JOptionPane.PLAIN_MESSAGE);
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -