Package jexer.backend

Class SwingBackend

  • All Implemented Interfaces:
    Backend

    public class SwingBackend
    extends GenericBackend
    This class uses standard Swing calls to handle screen, keyboard, and mouse I/O.
    • Constructor Detail

      • SwingBackend

        public SwingBackend()
        Public constructor. The window will be 80x25 with font size 20 pts.
      • SwingBackend

        public SwingBackend​(java.lang.Object listener)
        Public constructor. The window will be 80x25 with font size 20 pts.
        Parameters:
        listener - the object this backend needs to wake up when new input comes in
      • SwingBackend

        public SwingBackend​(int windowWidth,
                            int windowHeight)
        Public constructor will spawn a new JFrame with font size 20 pts.
        Parameters:
        windowWidth - the number of text columns to start with
        windowHeight - the number of text rows to start with
      • SwingBackend

        public SwingBackend​(int windowWidth,
                            int windowHeight,
                            int fontSize)
        Public constructor will spawn a new JFrame.
        Parameters:
        windowWidth - the number of text columns to start with
        windowHeight - the number of text rows to start with
        fontSize - the size in points. Good values to pick are: 16, 20, 22, and 24.
      • SwingBackend

        public SwingBackend​(java.lang.Object listener,
                            int windowWidth,
                            int windowHeight,
                            int fontSize)
        Public constructor will spawn a new JFrame.
        Parameters:
        listener - the object this backend needs to wake up when new input comes in
        windowWidth - the number of text columns to start with
        windowHeight - the number of text rows to start with
        fontSize - the size in points. Good values to pick are: 16, 20, 22, and 24.
      • SwingBackend

        public SwingBackend​(javax.swing.JComponent component,
                            java.lang.Object listener,
                            int windowWidth,
                            int windowHeight,
                            int fontSize)
        Public constructor will render onto a JComponent.
        Parameters:
        component - the Swing component to render to
        listener - the object this backend needs to wake up when new input comes in
        windowWidth - the number of text columns to start with
        windowHeight - the number of text rows to start with
        fontSize - the size in points. Good values to pick are: 16, 20, 22, and 24.
    • Method Detail

      • setFont

        public void setFont​(java.awt.Font font)
        Set to a new font, and resize the screen to match its dimensions.
        Parameters:
        font - the new font
      • getBlinkMillis

        public long getBlinkMillis()
        Get the number of millis to wait before switching the blink from visible to invisible.
        Returns:
        the number of milli to wait before switching the blink from visible to invisible
      • getSwingComponent

        public SwingComponent getSwingComponent()
        Getter for the underlying Swing component.
        Returns:
        the SwingComponent
      • isImagesOverText

        public boolean isImagesOverText()
        Check if backend will support incomplete image fragments over text display.
        Specified by:
        isImagesOverText in interface Backend
        Overrides:
        isImagesOverText in class GenericBackend
        Returns:
        true if images can partially obscure text
      • isPixelMouse

        public boolean isPixelMouse()
        Check if backend is reporting pixel-based mouse position.
        Specified by:
        isPixelMouse in interface Backend
        Overrides:
        isPixelMouse in class GenericBackend
        Returns:
        true if single-pixel mouse movements are reported
      • setPixelMouse

        public void setPixelMouse​(boolean pixelMouse)
        Set request for backend to report pixel-based mouse position.
        Specified by:
        setPixelMouse in interface Backend
        Overrides:
        setPixelMouse in class GenericBackend
        Parameters:
        pixelMouse - if true, single-pixel mouse movements will be reported, if the backend supports it
      • setMouseStyle

        public void setMouseStyle​(java.lang.String mouseStyle)
        Set the mouse pointer (cursor) style.
        Specified by:
        setMouseStyle in interface Backend
        Overrides:
        setMouseStyle in class GenericBackend
        Parameters:
        mouseStyle - the pointer style string, one of: "default", "none", "hand", "text", "move", or "crosshair"