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

📄 changelf.java

📁 JAVA实现的酒店管理系统
💻 JAVA
字号:
package file1;

/*
 * @Author:黄顺武
 * @Description:窗口风格选择面版
 */

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class ChangeLF extends JPanel implements ActionListener {

	private JFrame frame;
	private JRadioButton windowButton, motifButton, metalButton;
	private JLabel noticeLabel;
	private static ChangeLF lf = new ChangeLF();// 静态变量,避免被重复初始化

	public ChangeLF() {
		ButtonGroup bg = new ButtonGroup();
		windowButton = new JRadioButton("Window");
		motifButton = new JRadioButton("Motif");
		metalButton = new JRadioButton("Metal");
		bg.add(windowButton);
		bg.add(motifButton);
		bg.add(metalButton);
		noticeLabel = new JLabel("请 您 选 择 窗 口 风 格 : ");
		noticeLabel.setFont(new Font(Font.DIALOG, Font.BOLD, 12));
		this.setLayout(new FlowLayout(FlowLayout.CENTER, 10, 2));
		this.add(noticeLabel);
		this.add(windowButton);
		this.add(motifButton);
		this.add(metalButton);
		windowButton.addActionListener(this);
		motifButton.addActionListener(this);
		metalButton.addActionListener(this);
	}

	public void setFrame(JFrame f) {// 设置被设置风格的窗口框架
		this.frame = f;
	}

	public static ChangeLF getChangeLF() {// 返回定义的静态变量
		return lf;
	}

	public void actionPerformed(ActionEvent ae) {
		if (ae.getActionCommand().equalsIgnoreCase("Window")) {
			try {
				UIManager
						.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
				SwingUtilities.updateComponentTreeUI(frame);
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		if (ae.getActionCommand().equalsIgnoreCase("Motif")) {
			try {
				UIManager
						.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
				SwingUtilities.updateComponentTreeUI(frame);
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		if (ae.getActionCommand().equalsIgnoreCase("Metal")) {
			try {
				UIManager
						.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
				SwingUtilities.updateComponentTreeUI(frame);
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}
}

⌨️ 快捷键说明

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