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

📄 style.java

📁 java经典的源代码 我非常喜欢这个源代码 对于编程很有好处
💻 JAVA
字号:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Style extends JFrame{
  private JButton jb;
  private JCheckBox jcb;
  private JTextField jtf;
  private JRadioButton jrb;
  
  public Style(String title) {
    super(title);
  }

  public void init(){
    jb=new JButton("JButton");
    jcb=new JCheckBox("JCheckBox");
    jtf=new JTextField("JTextField");
    jrb=new JRadioButton("JRadioButton");
    Container cp=getContentPane();
    cp.setLayout(new FlowLayout());
    cp.add(jb);
    cp.add(jcb);
    cp.add(jtf);
    cp.add(jrb);
  }

  public static void main(String[] args) {
    Style style1 = new Style("Java程序界面风格演示");
    if(args.length==0){
      System.out.println("Usage:LookAndFeelStyel"+"[cross|system|motif|mac]");
      System.exit(1);
    }
    if(args[0].equals("cross")){
      try{
        UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
      }
      catch(Exception e){}
    }
    if(args[0].equals("system")){
      try{
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
      }
      catch(Exception e){}
    }
    if(args[0].equals("motif")){
      try{
        UIManager.setLookAndFeel("com.sun.javax.swing.plaf.motif.MotifLookAndFeel");
      }
      catch(Exception e){}
    }
    if(args[0].equals("mac")){
      try{
        UIManager.setLookAndFeel("javax.swing.plaf.mac.MacLookAndFeel");
      }
      catch(Exception e){}
    }
    style1.init();
    style1.setSize(200,150);
    style1.setVisible(true);
    style1.addWindowListener(new WindowAdapter() {
      public void windowClosing(WindowEvent e) {
        System.exit(0);
      }
    });
  }
}

⌨️ 快捷键说明

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