📄 ex_lookfree.java
字号:
package soe;import java.awt.Checkbox;import java.awt.CheckboxGroup;import java.awt.Frame;import java.awt.GridLayout;import java.awt.Label;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.event.WindowAdapter;import java.awt.event.WindowEvent;import javax.swing.JButton;import javax.swing.JRadioButton;import javax.swing.SwingUtilities;import javax.swing.UIManager;import javax.swing.UnsupportedLookAndFeelException;public class ex_LookFree{ static Frame fm=new Frame("RadioButton Group"); static Label l=new Label("What is your choice:"); public static void main(String[] args) { fm.setLayout(new GridLayout(0,1)); CheckboxGroup cg1=new CheckboxGroup(); fm.add(l); JRadioButton chk1=new JRadioButton("Metal"); JRadioButton chk2=new JRadioButton("Motif"); JRadioButton chk3=new JRadioButton("GTK"); fm.add(chk1); fm.add(chk2); fm.add(chk3); /*ch1.addActionCommand(""); ch1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { setDefaultLookAndFeelDecorated(true); } }); ch2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { changeLookFeel1(); } }); ch3.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { changeLookFeel2(); } });*/ fm.setSize(250, 200); fm.setVisible(true); fm.addWindowListener(new WindowAdapter(){ public void windowClosing(WindowEvent we){ System.exit(0); } }); } public void chLookFeel1(){ try { UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel"); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (UnsupportedLookAndFeelException e) { e.printStackTrace(); } } public void changeLookFeel2() { try { UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel"); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (UnsupportedLookAndFeelException e) { e.printStackTrace(); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -