SwingEase is a modern, fluent Java Swing UI library that makes creating beautiful user interfaces easy and intuitive. It provides a collection of pre-built components and layouts with a chainable API inspired by Flutter.
- 🎨 Modern UI components with customizable styles
- 📐 Flexible layout system with MigLayout
- ⚡ Fluent API design
- 🎯 Easy positioning and sizing
- 🖌️ Custom styling support with gradients
- 📦 Modern components with rounded corners
Add these dependencies to your project:
dependencies {
implementation("com.formdev:flatlaf:3.4")
implementation("com.miglayout:miglayout-swing:11.1")
// Placeholder for the dependency
}
dependencies {
implementation 'com.formdev:flatlaf:3.4'
implementation 'com.miglayout:miglayout-swing:11.1'
// Placeholder for the dependency
}
<dependencies>
<dependency>
<groupid>com.formdev</groupid>
<artifactid>flatlaf</artifactid>
<version>3.4</version>
</dependency>
<dependency>
<groupid>com.miglayout</groupid>
<artifactid>miglayout-swing</artifactid>
<version>11.1</version>
</dependency>
<!--
Placeholder for the dependency
<dependency>
<groupid>de.dragonrex</groupid>
<artifactid>swing-lite</artifactid>
<version>1.0.0</version>
</dependency>
-->
</dependencies>
Here's a simple example of creating a login form:
package de.dragonrex.test;
import com.formdev.flatlaf.FlatLightLaf;
import de.dragonrex.components.Button;
import de.dragonrex.components.TextField;
import de.dragonrex.layout.Row;
import de.dragonrex.math.Size;
import de.dragonrex.UI;
import de.dragonrex.components.Text;
import de.dragonrex.layout.Column;
import de.dragonrex.style.Padding;
import java.awt.*;
public class Main {
public static void main(String[] args) {
UI.build(
"",
Size.of(800, 600),
new FlatLightLaf(),
Column.of(
Padding.of(100, 350, 10, 10,
Text.of("Login Form")
.fontSize(14).bold()
.size(200, 30)
),
Padding.of(0, 300, 10, 10,
TextField.of()
.placeholder("Enter your username")
.columns(1)
.size(200, 40)
),
Padding.of(0, 300, 10, 10,
TextField.of()
.placeholder("Enter your password")
.columns(1)
.size(200, 40)
),
Row.of(
Padding.of(0, 295, 10, 5,
Button.of("Login")
.onClick(() -> System.out.println("Login clicked"))
.size(100, 40)
.background(Color.RED)
),
Padding.of(0, 5, 10, 10,
Button.of("Cancel")
.onClick(() -> System.out.println("Login canceled"))
.gradient(Color.GREEN, Color.BLUE)
.size(100, 40)
)
)
)
);
}
}
All components support these basic styling properties:
size(width, height)
: Set component dimensionsbackgroundColor(Color)
: Set background colorforegroundColor(Color)
: Set text/foreground colormargin(top, left, bottom, right)
: Set marginsvisible(boolean)
: Set visibilityposition(x, y)
: Set absolute position
Modern components (MButton, Container) additionally support:
radius(int)
: Set corner radiusgradient(Color, Color)
: Set gradient background
This project is licensed under the MIT License. See the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
If you have any questions or need help, please open an issue in the GitHub repository.