Simple usage example:
if (JBR.isSomeServiceSupported()) { JBR.getSomeService().doSomething(); } else { planB(); }
Implementation note:
JBR API is initialized on first access to this class (in static initializer). Actual implementation is linked on demand, when corresponding service is requested by client.-
Method Summary
Modifier and TypeMethodDescriptionstatic AccessibleAnnouncer
This interface provides the ability to speak a given string using screen readers.static AccessibleAnnouncer
getAccessibleAnnouncer
(Extensions... extensions) This interface provides the ability to speak a given string using screen readers.static String
Returns JBR API version.static DesktopActions
Allows desktop actions, like opening a file, or webpage to be overridden.static DesktopActions
getDesktopActions
(Extensions... extensions) Allows desktop actions, like opening a file, or webpage to be overridden.static FontExtensions
Font-related utilities.static FontExtensions
getFontExtensions
(Extensions... extensions) Font-related utilities.static FontMetricsAccessor
Provides convenience methods to accessFontMetrics
instances, and obtain character advances from them without rounding.static FontMetricsAccessor
getFontMetricsAccessor
(Extensions... extensions) Provides convenience methods to accessFontMetrics
instances, and obtain character advances from them without rounding.static GraphicsUtils
Graphics2D utilities.static GraphicsUtils
getGraphicsUtils
(Extensions... extensions) Graphics2D utilities.static String
Returns JBR API version supported by current runtime or "UNKNOWN".static Jstack
Jstack-related utilities.static Jstack
getJstack
(Extensions... extensions) Jstack-related utilities.static Keyboard
JBR API to inspect additional properties of AWT key events and keyboards.static Keyboard
getKeyboard
(Extensions... extensions) JBR API to inspect additional properties of AWT key events and keyboards.static NativeRasterLoader
Direct raster loading for VolatileImage.static NativeRasterLoader
getNativeRasterLoader
(Extensions... extensions) Direct raster loading for VolatileImage.static ProjectorUtils
GraphicsEnvironment
-related utilities.static ProjectorUtils
getProjectorUtils
(Extensions... extensions) GraphicsEnvironment
-related utilities.static RoundedCornersManager
This manager allows decorate awt Window with rounded corners.static RoundedCornersManager
getRoundedCornersManager
(Extensions... extensions) This manager allows decorate awt Window with rounded corners.static TextInput
This is a JBR API for text-input related functionality for applications that implement custom text components.static TextInput
getTextInput
(Extensions... extensions) This is a JBR API for text-input related functionality for applications that implement custom text components.static WindowDecorations
Window decorations consist of title bar, window controls and border.static WindowDecorations
getWindowDecorations
(Extensions... extensions) Window decorations consist of title bar, window controls and border.static WindowMove
X11 WM-assisted window moving facility.static WindowMove
getWindowMove
(Extensions... extensions) X11 WM-assisted window moving facility.static boolean
Checks whetherAccessibleAnnouncer
service is supported by the runtime.static boolean
Checks whether JBR API is available at runtime.static boolean
Checks whetherDesktopActions
service is supported by the runtime.static boolean
isExtensionSupported
(Extensions extension) Checks whether given extension is supported.static boolean
Checks whetherFontExtensions
service is supported by the runtime.static boolean
Checks whetherFontMetricsAccessor
service is supported by the runtime.static boolean
Checks whetherGraphicsUtils
service is supported by the runtime.static boolean
Checks whetherJstack
service is supported by the runtime.static boolean
Checks whetherKeyboard
service is supported by the runtime.static boolean
Checks whetherNativeRasterLoader
service is supported by the runtime.static boolean
Checks whetherProjectorUtils
service is supported by the runtime.static boolean
Checks whetherRoundedCornersManager
service is supported by the runtime.static boolean
Checks whetherTextInput
service is supported by the runtime.static boolean
Checks whetherWindowDecorations
service is supported by the runtime.static boolean
Checks whetherWindowMove
service is supported by the runtime.
-
Method Details
-
isAvailable
public static boolean isAvailable()Checks whether JBR API is available at runtime.- Returns:
- true when running on JBR which implements JBR API
-
getApiVersion
Returns JBR API version. Development versions of JBR API return "SNAPSHOT". When running on Java 8, returns "UNKNOWN".Note:
This is an API version, which comes with client application, it is *almost* a compile-time constant and has nothing to do with JRE it runs on.- Returns:
- JBR API version in form
MAJOR.MINOR.PATCH
, or "SNAPSHOT" / "UNKNOWN".
-
getImplVersion
Returns JBR API version supported by current runtime or "UNKNOWN".Note:
This method can return "UNKNOWN" even when JBR APIisAvailable()
.- Returns:
- JBR API version supported by current implementation or "UNKNOWN".
-
isExtensionSupported
Checks whether given extension is supported.- Parameters:
extension
- extension to check- Returns:
- true is extension is supported
-
isAccessibleAnnouncerSupported
public static boolean isAccessibleAnnouncerSupported()Checks whetherAccessibleAnnouncer
service is supported by the runtime.- Returns:
- true if current runtime has implementation for all methods in
AccessibleAnnouncer
and its dependencies (can fully implement given service). - See Also:
-
getAccessibleAnnouncer
This interface provides the ability to speak a given string using screen readers.- Returns:
- full implementation of
AccessibleAnnouncer
service if any, ornull
otherwise
-
getAccessibleAnnouncer
This interface provides the ability to speak a given string using screen readers.- Parameters:
extensions
- required extensions to enable- Returns:
- full implementation of
AccessibleAnnouncer
service if any, ornull
otherwise
-
isDesktopActionsSupported
public static boolean isDesktopActionsSupported()Checks whetherDesktopActions
service is supported by the runtime.- Returns:
- true if current runtime has implementation for all methods in
DesktopActions
and its dependencies (can fully implement given service). - See Also:
-
getDesktopActions
Allows desktop actions, like opening a file, or webpage to be overridden.- Returns:
- full implementation of
DesktopActions
service if any, ornull
otherwise - See Also:
-
getDesktopActions
Allows desktop actions, like opening a file, or webpage to be overridden.- Parameters:
extensions
- required extensions to enable- Returns:
- full implementation of
DesktopActions
service if any, ornull
otherwise - See Also:
-
isFontExtensionsSupported
public static boolean isFontExtensionsSupported()Checks whetherFontExtensions
service is supported by the runtime.- Returns:
- true if current runtime has implementation for all methods in
FontExtensions
and its dependencies (can fully implement given service). - See Also:
-
getFontExtensions
Font-related utilities.- Returns:
- full implementation of
FontExtensions
service if any, ornull
otherwise
-
getFontExtensions
Font-related utilities.- Parameters:
extensions
- required extensions to enable- Returns:
- full implementation of
FontExtensions
service if any, ornull
otherwise
-
isFontMetricsAccessorSupported
public static boolean isFontMetricsAccessorSupported()Checks whetherFontMetricsAccessor
service is supported by the runtime.- Returns:
- true if current runtime has implementation for all methods in
FontMetricsAccessor
and its dependencies (can fully implement given service). - See Also:
-
getFontMetricsAccessor
Provides convenience methods to accessFontMetrics
instances, and obtain character advances from them without rounding. Also provides an (unsafe) way to override character advances in those instances with arbitrary specified values.- Returns:
- full implementation of
FontMetricsAccessor
service if any, ornull
otherwise
-
getFontMetricsAccessor
Provides convenience methods to accessFontMetrics
instances, and obtain character advances from them without rounding. Also provides an (unsafe) way to override character advances in those instances with arbitrary specified values.- Parameters:
extensions
- required extensions to enable- Returns:
- full implementation of
FontMetricsAccessor
service if any, ornull
otherwise
-
isGraphicsUtilsSupported
public static boolean isGraphicsUtilsSupported()Checks whetherGraphicsUtils
service is supported by the runtime.- Returns:
- true if current runtime has implementation for all methods in
GraphicsUtils
and its dependencies (can fully implement given service). - See Also:
-
getGraphicsUtils
Graphics2D utilities.- Returns:
- full implementation of
GraphicsUtils
service if any, ornull
otherwise
-
getGraphicsUtils
Graphics2D utilities.- Parameters:
extensions
- required extensions to enable- Returns:
- full implementation of
GraphicsUtils
service if any, ornull
otherwise
-
isJstackSupported
public static boolean isJstackSupported()Checks whetherJstack
service is supported by the runtime.- Returns:
- true if current runtime has implementation for all methods in
Jstack
and its dependencies (can fully implement given service). - See Also:
-
getJstack
Jstack-related utilities.- Returns:
- full implementation of
Jstack
service if any, ornull
otherwise
-
getJstack
Jstack-related utilities.- Parameters:
extensions
- required extensions to enable- Returns:
- full implementation of
Jstack
service if any, ornull
otherwise
-
isKeyboardSupported
public static boolean isKeyboardSupported()Checks whetherKeyboard
service is supported by the runtime.- Returns:
- true if current runtime has implementation for all methods in
Keyboard
and its dependencies (can fully implement given service). - See Also:
-
getKeyboard
JBR API to inspect additional properties of AWT key events and keyboards.- Returns:
- full implementation of
Keyboard
service if any, ornull
otherwise
-
getKeyboard
JBR API to inspect additional properties of AWT key events and keyboards.- Parameters:
extensions
- required extensions to enable- Returns:
- full implementation of
Keyboard
service if any, ornull
otherwise
-
isNativeRasterLoaderSupported
public static boolean isNativeRasterLoaderSupported()Checks whetherNativeRasterLoader
service is supported by the runtime.- Returns:
- true if current runtime has implementation for all methods in
NativeRasterLoader
and its dependencies (can fully implement given service). - See Also:
-
getNativeRasterLoader
Direct raster loading for VolatileImage.- Returns:
- full implementation of
NativeRasterLoader
service if any, ornull
otherwise
-
getNativeRasterLoader
Direct raster loading for VolatileImage.- Parameters:
extensions
- required extensions to enable- Returns:
- full implementation of
NativeRasterLoader
service if any, ornull
otherwise
-
isProjectorUtilsSupported
public static boolean isProjectorUtilsSupported()Checks whetherProjectorUtils
service is supported by the runtime.- Returns:
- true if current runtime has implementation for all methods in
ProjectorUtils
and its dependencies (can fully implement given service). - See Also:
-
getProjectorUtils
GraphicsEnvironment
-related utilities.- Returns:
- full implementation of
ProjectorUtils
service if any, ornull
otherwise
-
getProjectorUtils
GraphicsEnvironment
-related utilities.- Parameters:
extensions
- required extensions to enable- Returns:
- full implementation of
ProjectorUtils
service if any, ornull
otherwise
-
isRoundedCornersManagerSupported
public static boolean isRoundedCornersManagerSupported()Checks whetherRoundedCornersManager
service is supported by the runtime.- Returns:
- true if current runtime has implementation for all methods in
RoundedCornersManager
and its dependencies (can fully implement given service). - See Also:
-
getRoundedCornersManager
This manager allows decorate awt Window with rounded corners. Appearance depends on operating system.- Returns:
- full implementation of
RoundedCornersManager
service if any, ornull
otherwise
-
getRoundedCornersManager
This manager allows decorate awt Window with rounded corners. Appearance depends on operating system.- Parameters:
extensions
- required extensions to enable- Returns:
- full implementation of
RoundedCornersManager
service if any, ornull
otherwise
-
isTextInputSupported
public static boolean isTextInputSupported()Checks whetherTextInput
service is supported by the runtime.- Returns:
- true if current runtime has implementation for all methods in
TextInput
and its dependencies (can fully implement given service). - See Also:
-
getTextInput
This is a JBR API for text-input related functionality for applications that implement custom text components.Suppose an application implements a custom text component called
CustomTextComponent
, that doesn't inherit fromTextComponent
orJTextComponent
. For this component to work correctly, the application needs to handle certain events that are missing from the Java specification.To do this, the application should add an event listener for the events provided by this API. This is best done at application startup time, since the event listener is global, and not per-component. For example, this would be a proper way to implement this event handler for
CustomTextComponent
:var textInput = JBR.getTextInput(); if (textInput != null) { textInput.setGlobalEventListener(new TextInput.EventListener() { @Override public void handleSelectTextRangeEvent(TextInput.SelectTextRangeEvent event) { if (event.getSource() instanceof CustomTextComponent) { ((CustomTextComponent)event.getSource()).select(event.getBegin(), event.getBegin() + event.getLength()); } } }); }
CustomTextComponent
has a method calledselect
, that selects a text range, similar to theTextComponent.select(int, int)
andJTextComponent.select(int, int)
. SeeTextInput.SelectTextRangeEvent
for more information.- Returns:
- full implementation of
TextInput
service if any, ornull
otherwise
-
getTextInput
This is a JBR API for text-input related functionality for applications that implement custom text components.Suppose an application implements a custom text component called
CustomTextComponent
, that doesn't inherit fromTextComponent
orJTextComponent
. For this component to work correctly, the application needs to handle certain events that are missing from the Java specification.To do this, the application should add an event listener for the events provided by this API. This is best done at application startup time, since the event listener is global, and not per-component. For example, this would be a proper way to implement this event handler for
CustomTextComponent
:var textInput = JBR.getTextInput(); if (textInput != null) { textInput.setGlobalEventListener(new TextInput.EventListener() { @Override public void handleSelectTextRangeEvent(TextInput.SelectTextRangeEvent event) { if (event.getSource() instanceof CustomTextComponent) { ((CustomTextComponent)event.getSource()).select(event.getBegin(), event.getBegin() + event.getLength()); } } }); }
CustomTextComponent
has a method calledselect
, that selects a text range, similar to theTextComponent.select(int, int)
andJTextComponent.select(int, int)
. SeeTextInput.SelectTextRangeEvent
for more information.- Parameters:
extensions
- required extensions to enable- Returns:
- full implementation of
TextInput
service if any, ornull
otherwise
-
isWindowDecorationsSupported
public static boolean isWindowDecorationsSupported()Checks whetherWindowDecorations
service is supported by the runtime.- Returns:
- true if current runtime has implementation for all methods in
WindowDecorations
and its dependencies (can fully implement given service). - See Also:
-
getWindowDecorations
Window decorations consist of title bar, window controls and border.- Returns:
- full implementation of
WindowDecorations
service if any, ornull
otherwise - See Also:
-
getWindowDecorations
Window decorations consist of title bar, window controls and border.- Parameters:
extensions
- required extensions to enable- Returns:
- full implementation of
WindowDecorations
service if any, ornull
otherwise - See Also:
-
isWindowMoveSupported
public static boolean isWindowMoveSupported()Checks whetherWindowMove
service is supported by the runtime.- Returns:
- true if current runtime has implementation for all methods in
WindowMove
and its dependencies (can fully implement given service). - See Also:
-
getWindowMove
X11 WM-assisted window moving facility.- Returns:
- full implementation of
WindowMove
service if any, ornull
otherwise
-
getWindowMove
X11 WM-assisted window moving facility.- Parameters:
extensions
- required extensions to enable- Returns:
- full implementation of
WindowMove
service if any, ornull
otherwise
-