GitXplorerGitXplorer
D

JFrame-Titlebar

public
0 stars
0 forks
0 issues

Commits

List of commits on branch master.
Unverified
63488388d71feb8f0bc07632518837c14def7f7a

Upload project

DDegubi committed 3 years ago

README

The README file for this repository.

JFrame-Titlebar

Github issues Dependencies

Installation

Maven dependency: (via Github Packages)

<repository>
    <id>github</id>
    <url>https://maven.pkg.github.com/Degubi/jframe-titlebar</url>
</repository>

<dependency>
    <groupId>degubi</groupId>
    <artifactId>jframe-titlebar</artifactId>
    <version>1.0.0</version>
</dependency>

Jar file:

Jar file downloads are available under 'Packages'

Usage

All functions are found in a single class: JFrameTitlebar

var frame = new JFrame("Hi");

frame.setSize(800, 600);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

// This next line is important, because the functions found in JFrameTitlebar only work if the frame is already visible
frame.setVisible(true);

JFrameTitlebar.setDarkMode(frame);  // Sets the titlebar theme to dark
JFrameTitlebar.setLightMode(frame); // Sets the titlebar theme to light

Example with a titlebar theme toggle button

public final class Main {

    public static void main(String[] args) {
        var frame = new JFrame("Hi");

        var toggleButton = new JButton("Toggle");
        toggleButton.addActionListener(e -> JFrameTitlebar.setMode(frame, !JFrameTitlebar.isDarkMode(frame)));

        frame.setContentPane(toggleButton);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(800, 600);
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
    }
}

Contributing

Feedback, bug reports and enhancements are always welcome.