📄 mainframe.java~8~
字号:
package jplafdemo;import java.awt.*;import java.awt.event.*;import javax.swing.*;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2002</p> * <p>Company: </p> * @author unascribed * @version 1.0 */public class MainFrame extends JFrame { private JPanel contentPane; private BorderLayout borderLayout1 = new BorderLayout(); private JMenuBar jMenuBar1 = new JMenuBar(); private JMenu jMenu1 = new JMenu(); private JMenuItem jMenuItem1 = new JMenuItem(); private JMenuItem jMenuItem2 = new JMenuItem(); private JMenuItem jMenuItem3 = new JMenuItem(); private String plafName=UIManager.getCrossPlatformLookAndFeelClassName(); private JButton jButton1 = new JButton(); private JTextField jTextField1 = new JTextField(); private JRadioButton jRadioButton1 = new JRadioButton(); private JCheckBox jCheckBox1 = new JCheckBox(); private JComboBox jComboBox1 = new JComboBox(); //Construct the frame public MainFrame() { enableEvents(AWTEvent.WINDOW_EVENT_MASK); try { jbInit(); } catch(Exception e) { e.printStackTrace(); } } //Component initialization private void jbInit() throws Exception { //setIconImage(Toolkit.getDefaultToolkit().createImage(MainFrame.class.getResource("[Your Icon]"))); contentPane = (JPanel) this.getContentPane(); contentPane.setLayout(borderLayout1); this.setJMenuBar(jMenuBar1); this.setSize(new Dimension(423, 183)); this.setTitle("JPlafDemo"); jMenu1.setFont(new java.awt.Font("Dialog", 0, 13)); jMenu1.setText("Plaf"); jMenuItem1.setFont(new java.awt.Font("Dialog", 0, 13)); jMenuItem1.setText("Windows"); jMenuItem1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jMenuItem1_actionPerformed(e); } }); jMenuItem2.setFont(new java.awt.Font("Dialog", 0, 13)); jMenuItem2.setText("Metal"); jMenuItem2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jMenuItem2_actionPerformed(e); } }); jMenuItem3.setFont(new java.awt.Font("Dialog", 0, 13)); jMenuItem3.setText("Motif"); jMenuItem3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jMenuItem3_actionPerformed(e); } }); jButton1.setText("jButton1"); jTextField1.setText("jTextField1"); jRadioButton1.setText("jRadioButton1"); jCheckBox1.setText("jCheckBox1"); jMenuBar1.add(jMenu1); jMenu1.add(jMenuItem1); jMenu1.add(jMenuItem2); jMenu1.add(jMenuItem3); contentPane.add(jTextField1, BorderLayout.SOUTH); contentPane.add(jRadioButton1, BorderLayout.WEST); contentPane.add(jCheckBox1, BorderLayout.EAST); contentPane.add(jComboBox1, BorderLayout.NORTH); contentPane.add(jButton1, BorderLayout.CENTER); } //Overridden so we can exit when window is closed protected void processWindowEvent(WindowEvent e) { super.processWindowEvent(e); if (e.getID() == WindowEvent.WINDOW_CLOSING) { System.exit(0); } } void jMenuItem1_actionPerformed(ActionEvent e) { this.plafName = UIManager.getSystemLookAndFeelClassName(); try{ UIManager.setLookAndFeel(this.plafName); SwingUtilities.updateComponentTreeUI(this); this.pack(); }catch(Exception err){ err.printStackTrace(); } this.jTextField1.setText(this.plafName); } void jMenuItem2_actionPerformed(ActionEvent e) { this.plafName=UIManager.getCrossPlatformLookAndFeelClassName(); try{ UIManager.setLookAndFeel(this.plafName); SwingUtilities.updateComponentTreeUI(this); this.pack(); }catch(Exception err){ err.printStackTrace(); } this.jTextField1.setText(this.plafName); } void jMenuItem3_actionPerformed(ActionEvent e) { this.plafName="com.sun.java.swing.plaf.motif.MotifLookAndFeel"; try{ UIManager.setLookAndFeel(this.plafName); SwingUtilities.updateComponentTreeUI(this); this.pack(); }catch(Exception err){ err.printStackTrace(); } this.jTextField1.setText(this.plafName); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -