Package com.jetbrains

Class JBR

java.lang.Object
com.jetbrains.JBR

public final class JBR extends Object
Entry point into JBR API. Client and JBR side are linked dynamically at runtime and do not have to be of the same version. In some cases (e.g. running on different JRE or old JBR) system will not be able to find implementation for some services, so you'll need a fallback behavior for that case.

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 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

      public static String 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

      public static String getImplVersion()
      Returns JBR API version supported by current runtime or "UNKNOWN".

      Note:

      This method can return "UNKNOWN" even when JBR API isAvailable().
      Returns:
      JBR API version supported by current implementation or "UNKNOWN".
    • isExtensionSupported

      public static boolean isExtensionSupported(Extensions extension)
      Checks whether given extension is supported.
      Parameters:
      extension - extension to check
      Returns:
      true if extension is supported
    • isAccessibleAnnouncerSupported

      public static boolean isAccessibleAnnouncerSupported()
      Checks whether AccessibleAnnouncer 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

      public static AccessibleAnnouncer getAccessibleAnnouncer()
      This interface provides the ability to speak a given string using screen readers.
      Returns:
      full implementation of AccessibleAnnouncer service if any, or null otherwise
    • getAccessibleAnnouncer

      public static AccessibleAnnouncer getAccessibleAnnouncer(Extensions... extensions)
      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, or null otherwise
    • isDesktopActionsSupported

      public static boolean isDesktopActionsSupported()
      Checks whether DesktopActions 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

      public static DesktopActions getDesktopActions()
      Allows desktop actions, like opening a file, or webpage to be overridden.
      Returns:
      full implementation of DesktopActions service if any, or null otherwise
      See Also:
    • getDesktopActions

      public static DesktopActions getDesktopActions(Extensions... extensions)
      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, or null otherwise
      See Also:
    • isFontExtensionsSupported

      public static boolean isFontExtensionsSupported()
      Checks whether FontExtensions 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

      public static FontExtensions getFontExtensions()
      Font-related utilities.
      Returns:
      full implementation of FontExtensions service if any, or null otherwise
    • getFontExtensions

      public static FontExtensions getFontExtensions(Extensions... extensions)
      Font-related utilities.
      Parameters:
      extensions - required extensions to enable
      Returns:
      full implementation of FontExtensions service if any, or null otherwise
    • isFontMetricsAccessorSupported

      public static boolean isFontMetricsAccessorSupported()
      Checks whether FontMetricsAccessor 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

      public static FontMetricsAccessor getFontMetricsAccessor()
      Provides convenience methods to access FontMetrics 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, or null otherwise
    • getFontMetricsAccessor

      public static FontMetricsAccessor getFontMetricsAccessor(Extensions... extensions)
      Provides convenience methods to access FontMetrics 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, or null otherwise
    • isGraphicsUtilsSupported

      public static boolean isGraphicsUtilsSupported()
      Checks whether GraphicsUtils 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

      public static GraphicsUtils getGraphicsUtils()
      Graphics2D utilities.
      Returns:
      full implementation of GraphicsUtils service if any, or null otherwise
    • getGraphicsUtils

      public static GraphicsUtils getGraphicsUtils(Extensions... extensions)
      Graphics2D utilities.
      Parameters:
      extensions - required extensions to enable
      Returns:
      full implementation of GraphicsUtils service if any, or null otherwise
    • isJstackSupported

      public static boolean isJstackSupported()
      Checks whether Jstack 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

      public static Jstack getJstack()
      Jstack-related utilities.
      Returns:
      full implementation of Jstack service if any, or null otherwise
    • getJstack

      public static Jstack getJstack(Extensions... extensions)
      Jstack-related utilities.
      Parameters:
      extensions - required extensions to enable
      Returns:
      full implementation of Jstack service if any, or null otherwise
    • isKeyboardSupported

      public static boolean isKeyboardSupported()
      Checks whether Keyboard 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

      public static Keyboard getKeyboard()
      JBR API to inspect additional properties of AWT key events and keyboards.
      Returns:
      full implementation of Keyboard service if any, or null otherwise
    • getKeyboard

      public static Keyboard getKeyboard(Extensions... extensions)
      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, or null otherwise
    • isNativeRasterLoaderSupported

      public static boolean isNativeRasterLoaderSupported()
      Checks whether NativeRasterLoader 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

      public static NativeRasterLoader getNativeRasterLoader()
      Direct raster loading for VolatileImage.
      Returns:
      full implementation of NativeRasterLoader service if any, or null otherwise
    • getNativeRasterLoader

      public static NativeRasterLoader getNativeRasterLoader(Extensions... extensions)
      Direct raster loading for VolatileImage.
      Parameters:
      extensions - required extensions to enable
      Returns:
      full implementation of NativeRasterLoader service if any, or null otherwise
    • isProjectorUtilsSupported

      public static boolean isProjectorUtilsSupported()
      Checks whether ProjectorUtils 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

      public static ProjectorUtils getProjectorUtils()
      GraphicsEnvironment-related utilities.
      Returns:
      full implementation of ProjectorUtils service if any, or null otherwise
    • getProjectorUtils

      public static ProjectorUtils getProjectorUtils(Extensions... extensions)
      GraphicsEnvironment-related utilities.
      Parameters:
      extensions - required extensions to enable
      Returns:
      full implementation of ProjectorUtils service if any, or null otherwise
    • isRoundedCornersManagerSupported

      public static boolean isRoundedCornersManagerSupported()
      Checks whether RoundedCornersManager 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

      public static RoundedCornersManager getRoundedCornersManager()
      This manager allows decorate awt Window with rounded corners. Appearance depends on operating system.
      Returns:
      full implementation of RoundedCornersManager service if any, or null otherwise
    • getRoundedCornersManager

      public static RoundedCornersManager getRoundedCornersManager(Extensions... extensions)
      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, or null otherwise
    • isTextInputSupported

      public static boolean isTextInputSupported()
      Checks whether TextInput 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

      public static TextInput 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 from TextComponent or JTextComponent. 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());
                   }
               }
           });
       }
       
       
      This assumes that CustomTextComponent has a method called select, that selects a text range, similar to the TextComponent.select(int, int) and JTextComponent.select(int, int). See TextInput.SelectTextRangeEvent for more information.
      Returns:
      full implementation of TextInput service if any, or null otherwise
    • getTextInput

      public static TextInput getTextInput(Extensions... extensions)
      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 from TextComponent or JTextComponent. 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());
                   }
               }
           });
       }
       
       
      This assumes that CustomTextComponent has a method called select, that selects a text range, similar to the TextComponent.select(int, int) and JTextComponent.select(int, int). See TextInput.SelectTextRangeEvent for more information.
      Parameters:
      extensions - required extensions to enable
      Returns:
      full implementation of TextInput service if any, or null otherwise
    • isWindowDecorationsSupported

      public static boolean isWindowDecorationsSupported()
      Checks whether WindowDecorations 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

      public static WindowDecorations getWindowDecorations()
      Window decorations consist of title bar, window controls and border.
      Returns:
      full implementation of WindowDecorations service if any, or null otherwise
      See Also:
    • getWindowDecorations

      public static WindowDecorations getWindowDecorations(Extensions... extensions)
      Window decorations consist of title bar, window controls and border.
      Parameters:
      extensions - required extensions to enable
      Returns:
      full implementation of WindowDecorations service if any, or null otherwise
      See Also:
    • isWindowMoveSupported

      public static boolean isWindowMoveSupported()
      Checks whether WindowMove 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

      public static WindowMove getWindowMove()
      X11 WM-assisted window moving facility.
      Returns:
      full implementation of WindowMove service if any, or null otherwise
    • getWindowMove

      public static WindowMove getWindowMove(Extensions... extensions)
      X11 WM-assisted window moving facility.
      Parameters:
      extensions - required extensions to enable
      Returns:
      full implementation of WindowMove service if any, or null otherwise