?? lookfeeloption.txt
字號:
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 + =
減小字號
Ctrl + -