UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
得到系统的。

解决方案 »

  1.   

    当然可以的!
    可以设置三种标准的外观之一:Windows,Motif(Unitx),或Metal(标准的Swing外观)。
    设置可插入的外观
         要在程序运行时改变外观,可以使用UIManager类的setLookAndFeel方法,将以下作为参数传入:
     javax.swing.plaf.metal.MetalLookAndFeel; Metal外观
    com.sun.java.swing.plaf.motif.MotifLookAndFeel; Motif外观
    com.sun.java.swing.plaf.windows.WindowsLookAndFeel; windows外观
      在改变内容板的外观后,使用SwingUtilities类的updateComponentTreeUI()方法实它起作用,
      SwingUtilities.updateComponentTreeUI(getContentPane());我给你一个例子:
      

  2.   

    如果想要动态改变的话就按lwg2019(想成为Java高手)说的
    如果想改变默认感观,找到jdk/jre/lib/swing.properties文件
    有三行#swing.defaultf语句
    通过增删前面的#来改变
      

  3.   

    通过使用 Swing UIManager 类的静态方法,可以找到当前已安装的 Look & Feel 选项,以及与当前平台匹配的 Look & Feel。以下代码将 Look & Feel 设置成当前平台的 Look & Feel,然后为每个可用的 Look & Feel 构建一组复选框菜单项,并预先选择与当前 Look & Feel 匹配的菜单项: 
    // Get the system Look & Feel name for current platform.
    final String platform = UIManager.getSystemLookAndFeelClassName();
    // If the current Look & Feel does not match the platform Look & Feel,
    // change it so it does.
    if (!UIManager.getLookAndFeel().getName().equals(platform))
    {
      try
      {
        UIManager.setLookAndFeel(platform);
      }
      catch(Exception exception)
      {
        exception.printStackTrace();
      }
    }
    // Action listener for menu items affecting the Look & Feel.
    final ActionListener lookFeelActionListener = new ActionListener()
    {
      // When a new Swing Look & Feel is selected, apply it.
      public void actionPerformed(ActionEvent event)
      {
        setLookAndFeel(event.getActionCommand(), fMyFrame);
      }
    };
    // Enumerate the currently installed Look & Feels.
    final UIManager.LookAndFeelInfo[] installed = UIManager.getInstalledLookAndFeels();
    // For each installed Look & Feel, create a menu item using the
    // Look & Feel name. Select the menu item for the platform Look & Feel
    for (int i = 0; i < installed.length; i++)
    {
      final String name = installedi.getName();
      final JMenuItem menuItem = new JRadioButtonMenuItem(name);
      menuItem.addActionListener(lookAndFeelActionListener);
      if (name.equals(platform))
        menuItem.setSelected(true);
    }
              
    该代码获取当前平台的 Look & Feel 名称,并将它设置成当前的 Look & Feel。它定义了一个操作侦听器来处理 Look & Feel 菜单项选择。然后,它枚举了已安装的 Look & Feel,并使用 Look & Feel 名称作为构造参数,为每一个都创建一个单选按钮菜单项。代码将操作侦听器与每个菜单项都关联起来,并选择与平台 Look & Feel 匹配的菜单项。 操作侦听器调用 setLookAndFeel() 方法,将与所选菜单项和引用关联的 Look & Feel 名称传递给应用程序框架。下面显示了这个方法: 
    // Set the current Look & Feel according to the supplied string,
    // and refresh the user interface for the supplied
    private void setLookAndFeel(final String lookAndFeel, final Component component)
    {
      // Enumerate the currently installed Look & Feels.
      final UIManager.LookAndFeelInfo[] installed = UIManager.getInstalledLookAndFeels();
      // Locate and set the new Look & Feel based on the supplied name.
      boolean set = false;
      for (int i = 0; !set && (i < installed.length); i++)
      {
        final String name = installedi.getName();
        if (name.equals(lookAndFeel))
        {
          set = true;
          try
          {
            // refresh the UI for the component, and all of its children
            UIManager.setLookAndFeel(installedi.getClassName());
            SwingUtilities.updateComponentTreeUI(component);
          }
          catch (Exception exception)
          {
            exception.printStackTrace();
          }
        }
      }
    }
              
    此代码枚举当前安装的 Look & Feel (或者是高速缓存的),并不断迭代,直到它找到名称与所提供名称匹配的 Look & Feel。如果找到一个匹配,则代码将它设置成当前 Look & Feel。将刷新所提供的组件,包括其子节点。