org.dstadler.commons.os.WindowTitle Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of commons-dost Show documentation
Show all versions of commons-dost Show documentation
Common utilities I find useful in many of my projects.
package org.dstadler.commons.os;
import com.sun.jna.Library;
import com.sun.jna.Native;
import com.sun.jna.Platform;
/**
* Small helper class that can be used to set the console title
* on Windows.
*
* @author dominik.stadler
*
*/
public class WindowTitle {
/**
* http://en.wikipedia.org/wiki/Java_Native_Access
* https://jna.dev.java.net/javadoc/overview-summary.html
*
*/
public interface Kernel32 extends Library {
/* http://msdn.microsoft.com/en-us/library/ms686050%28VS.85%29.aspx
*
*
BOOL WINAPI SetConsoleTitle(
__in LPCTSTR lpConsoleTitle
);*/
boolean SetConsoleTitleA(String title);
}
public static void setConsoleTitle(String title) {
if(!Platform.isWindows()) {
return;
}
Kernel32 lib = (Kernel32) Native.loadLibrary("kernel32", Kernel32.class);
lib.SetConsoleTitleA(title);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy