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

📄 test.java

📁 swing 教程,与大家分享一下,哈哈,希望大家多多指教
💻 JAVA
字号:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class Test extends JApplet {
	private JButton topButton = new JButton(
					"show dialog created from option pane");
	private JButton bottomButton = new JButton(
					"show dialog created with static method");

	private String title = "dialog title";
	private String message = "message";

	public Test() {
		Container contentPane = getContentPane();

		contentPane.setLayout(new FlowLayout());
		contentPane.add(topButton);
		contentPane.add(bottomButton);

		topButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				JOptionPane optionPane = new JOptionPane(
				  message, // message
				  JOptionPane.INFORMATION_MESSAGE); // messageType

				JDialog dialog = optionPane.createDialog(
				  topButton, // parentComponent
				  title); // title

				dialog.show();
			}
		});
		bottomButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				JOptionPane.showMessageDialog(
				  bottomButton, // parentComponent
				  message, // message
				  title, // title
				  JOptionPane.INFORMATION_MESSAGE); // messageType
			}
		});
	}
}

⌨️ 快捷键说明

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