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

📄 plaf.java

📁 这个是学习网络编程的好好文档! 里面有一些老师发给的学习jsp的课件!
💻 JAVA
字号:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

class PLAF extends JFrame implements ActionListener
{
  public PLAF()
  {
    createButtonPanel();
    this.getContentPane().add(buttonPanel,BorderLayout.NORTH);
    this.getContentPane().add(new JTextField("Input String"),BorderLayout.CENTER);
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setSize(600,300);
    setVisible(true);
  }
  
  public void actionPerformed(ActionEvent e)
  {
    String cmd = e.getActionCommand();
    try
    {
      UIManager.setLookAndFeel(cmd);
      //this.setTitle("观感: "+cmd);
    }
    catch(Exception ex)
    {
      JOptionPane.showMessageDialog(this,"不支持["+cmd+"]");
    }
    SwingUtilities.updateComponentTreeUI(this);
    setTitle(UIManager.getLookAndFeel().getName());
  }
  
  private void createButtonPanel()
  {
    buttonPanel = new JPanel();
    buttonPanel.setLayout(new GridLayout());
    for(int i=0;i<cmds.length;i++)
    {
      JButton b = new JButton(cmds[i]);
      b.setFont(new Font("Dialog",Font.BOLD,18));
      b.setActionCommand(LandF[i]);
      b.addActionListener(this);
      buttonPanel.add(b);
    }
  }
  
  private JPanel buttonPanel;

  private String[] cmds = {"Windows","Cross Plat","Java(Metal)","CED/Motif","Mac"};
  
  private String[] LandF = {"com.sun.java.swing.plaf.windows.WindowsLookAndFeel",
                            "UIManager.getCrossPlatformLookAndFeel()",
                            "javax.swing.plaf.metal.MetalLookAndFeel",
                            "com.sun.java.swing.plaf.motif.MotifLookAndFeel",
                            "javax.swing.plaf.mac.MacLookAndFeel"};
}  

class PLAFTester
{
  public static void main(String[] args)
  {
    new PLAF();
  }
}

⌨️ 快捷键说明

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