Java Swing-2.环境搭建及窗口背景

环境搭建及设置窗口背景

环境搭建

jdk:1.8
Maven:3.2.5

开发一个小型的桌面程序,可直接创建一个基础的Maven 项目,我的场景中不使用Spring 所以并没有 使用Springboot 框架

  • 下面是我的pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0modelVersion>
  <groupId>org.examplegroupId>
  <artifactId>Swing-TestartifactId>
  <version>1.0-SNAPSHOTversion>
  <name>Archetype - Swing-Testname>
  <url>http://maven.apache.orgurl>


  <dependencies>
  
    <dependency>
      <groupId>com.formdevgroupId>
      <artifactId>flatlafartifactId>
      <version>3.5.2version>
    dependency>
  dependencies>
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.pluginsgroupId>
        <artifactId>maven-compiler-pluginartifactId>
        <configuration>
          <source>8source>
          <target>8target>
        configuration>
      plugin>
    plugins>
  build>
project>

设置背景

查看支持的皮肤

    public static void  getLookAndFeel(){
        System.out.println("查看系统支持LAF");
        for (UIManager.LookAndFeelInfo feel : UIManager.getInstalledLookAndFeels()) {
            System.out.println(feel.getClassName()+"--------->"+feel);
        }
    }

改变皮肤

UIManager.setLookAndFeel("...皮肤全路径");
SwingUtilities.updateComponentTreeUI(f);
//f=JFrame Swing 定义的容器组件
// 如果如果切换皮肤时,关闭,放大,最小化等按钮图标异常,可替换一下方法进行尝试
// 分别配置样式
UIManager.setLookAndFeel("...皮肤全路径");
SwingUtilities.updateComponentTreeUI(f.getContentPane());
SwingUtilities.updateComponentTreeUI(mb);
SwingUtilities.updateComponentTreeUI(pop);

开源皮肤

flatLaf

  • https://www.formdev.com/flatlaf/themes/
  • 
    
        com.formdev
        flatlaf
        3.5.2
    
    

打包为exe 安装包

使用 exe4J,网上打包教程众多,便不在写具体教程了,可直接搜索《EXE4J 将Jar 打包成可执行文件》或《EXE4J打包》

你可能感兴趣的:(java,swing,java,开发语言)