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

📄 lookfeeloption.java

📁 samplecode 111 for J2SE project
💻 JAVA
字号:
package soe;import java.awt.FlowLayout;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.ButtonGroup;import javax.swing.JFrame;import javax.swing.JRadioButton;import javax.swing.SwingUtilities;import javax.swing.UIManager;public class LookFeelOption extends JFrame implements ActionListener {	/**	 * Display button with Swing with Window Decoration	 */	private static final long serialVersionUID = 1L;	public static void main(String[] args) {		// Set Window Decoration of look and feel		JFrame.setDefaultLookAndFeelDecorated(true);		new LookFeelOption();	}	LookFeelOption() {	super("SwingButtonTest");	setSize(200, 200);	// set layout of the components(center)	getContentPane().setLayout(new FlowLayout());	// create button	//JButton b1 = new JButton("OK");		//Create JButton	JRadioButton motif = new JRadioButton("Motif");	motif.setActionCommand("com.sun.java.swing.plaf.motif.MotifLookAndFeel");	motif.addActionListener(this);		JRadioButton gtk = new JRadioButton("GTK");	gtk.setActionCommand("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");	gtk.addActionListener(this);		JRadioButton mtl = new JRadioButton("Metal");	mtl.setActionCommand("javax.swing.plaf.metal.MetalLookAndFeel");	mtl.addActionListener(this);	// create check group	ButtonGroup group=new ButtonGroup();	group.add(motif);	group.add(gtk);	group.add(mtl);	getContentPane().add(motif);	getContentPane().add(gtk);	getContentPane().add(mtl);	// get container to locate button	//getContentPane().add(b1);			// close window	setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);	// show();	setVisible(true);	}	public void actionPerformed(ActionEvent ae) {		// TODO Auto-generated method stub		try		{			UIManager.setLookAndFeel(ae.getActionCommand());			SwingUtilities.updateComponentTreeUI(this);			pack();		}catch (Exception e)		{			e.printStackTrace();		}	}}

⌨️ 快捷键说明

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