Skip to content

Latest commit

 

History

History
125 lines (84 loc) · 3.44 KB

README.md

File metadata and controls

125 lines (84 loc) · 3.44 KB

Layered Font Icon Support For Java Swing / FlatLaf

Latest Version

This is a very basic multi-layer font icon utility that I extracted from another project of mine, for Java 11+ and Scala 3. It lets you use your own font icons in Swing applications, optionally with multiple layers in one icon. Below screenshot shows several examples using the same three layers.

Screenshot

Another example that shows how "unset" colors change with the foreground color:

Screenshot

Layers can also take their colors from the UIManager, using a key. This is especially useful when using FlatLaf, which lets you define such key-value pairs in the properties files. For example, let's assume we have two themes, light and dark.

In DarkTheme.properties:

Theme.accent = #33A1FD

In LightTheme.properties:

Theme.accent = #DF2935

We can now use "Theme.accent" to lookup colors.

Scala:

Layer(Symbol.CutAccent.text, LayerColor.FromKey("Theme.accent"))

Java:

Layer.ofKey(Symbol.CUT_ACCENT.text(), "Theme.accent")

Screenshot

Animated theme change in FlatLaf:

Animated transition with FlatLaf

To see how to use, please check Java and Scala demos, and documentation comments in the core/.../Layer.scala file.

The 'basic' project offers Java Swing support without any other dependencies. The 'flat' project adds a little better support for the magnificent FlatLaf look and feel.

Basic usage

Maven

In pom.xml, add

<dependencies>
    <dependency>
        <groupId>io.github.mimoguz</groupId>
        <artifactId>layeredfonticon-core_3</artifactId>
        <version>0.2.0</version>
    </dependency>
    <dependency>
        <groupId>io.github.mimoguz</groupId>
        <artifactId>layeredfonticon-basic_3</artifactId>
        <version>0.2.0</version>
    </dependency>
</dependencies>

to use the basic version, or

<dependencies>
    <dependency>
        <groupId>io.github.mimoguz</groupId>
        <artifactId>layeredfonticon-core_3</artifactId>
        <version>0.2.0</version>
    </dependency>
    <dependency>
        <groupId>io.github.mimoguz</groupId>
        <artifactId>layeredfonticon-flat_3</artifactId>
        <version>0.2.0</version>
    </dependency>
</dependencies>

to use FlatLaf specific version.

sbt

In build.sbt, add

libraryDependencies ++= Seq(
  "io.github.mimoguz" %% "layeredfonticon-core" % "0.2.0",
  "io.github.mimoguz" %% "layeredfonticon-basic" % "0.2.0"
)

to use the basic version, or

libraryDependencies ++= Seq(
  "io.github.mimoguz" %% "layeredfonticon-core" % "0.2.0",
  "io.github.mimoguz" %% "layeredfonticon-flat" % "0.2.0"
)

to use FlatLaf specific version.

Building

You will need JDK 11+ and sbt. Then, running

sbt publishLocal

in the project root will publish the artefacts to your local ivy repository and list what's published. To publish to default Maven repository at ~/.m2, run

sbt publishM2

instead. If you just want jars, run

sbt package

and check the "target/scala-3.2.1" directory.