Package jexer.backend
Class SwingBackend
- java.lang.Object
-
- jexer.backend.GenericBackend
-
- jexer.backend.SwingBackend
-
- All Implemented Interfaces:
Backend
public class SwingBackend extends GenericBackend
This class uses standard Swing calls to handle screen, keyboard, and mouse I/O.
-
-
Field Summary
-
Fields inherited from class jexer.backend.GenericBackend
lastUserInputTime, readOnly, screen, sessionInfo, terminal
-
-
Constructor Summary
Constructors Constructor Description SwingBackend()
Public constructor.SwingBackend(int windowWidth, int windowHeight)
Public constructor will spawn a new JFrame with font size 20 pts.SwingBackend(int windowWidth, int windowHeight, int fontSize)
Public constructor will spawn a new JFrame.SwingBackend(java.lang.Object listener)
Public constructor.SwingBackend(java.lang.Object listener, int windowWidth, int windowHeight, int fontSize)
Public constructor will spawn a new JFrame.SwingBackend(javax.swing.JComponent component, java.lang.Object listener, int windowWidth, int windowHeight, int fontSize)
Public constructor will render onto a JComponent.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
getBlinkMillis()
Get the number of millis to wait before switching the blink from visible to invisible.SwingComponent
getSwingComponent()
Getter for the underlying Swing component.boolean
isImagesOverText()
Check if backend will support incomplete image fragments over text display.boolean
isPixelMouse()
Check if backend is reporting pixel-based mouse position.void
setFont(java.awt.Font font)
Set to a new font, and resize the screen to match its dimensions.void
setMouseStyle(java.lang.String mouseStyle)
Set the mouse pointer (cursor) style.void
setPixelMouse(boolean pixelMouse)
Set request for backend to report pixel-based mouse position.-
Methods inherited from class jexer.backend.GenericBackend
flushScreen, getEvents, getScreen, getSessionInfo, hasEvents, isReadOnly, reloadOptions, setListener, setReadOnly, setTitle, shutdown
-
-
-
-
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 withwindowHeight
- 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 withwindowHeight
- the number of text rows to start withfontSize
- 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 inwindowWidth
- the number of text columns to start withwindowHeight
- the number of text rows to start withfontSize
- 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 tolistener
- the object this backend needs to wake up when new input comes inwindowWidth
- the number of text columns to start withwindowHeight
- the number of text rows to start withfontSize
- 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 interfaceBackend
- Overrides:
isImagesOverText
in classGenericBackend
- 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 interfaceBackend
- Overrides:
isPixelMouse
in classGenericBackend
- 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 interfaceBackend
- Overrides:
setPixelMouse
in classGenericBackend
- 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 interfaceBackend
- Overrides:
setMouseStyle
in classGenericBackend
- Parameters:
mouseStyle
- the pointer style string, one of: "default", "none", "hand", "text", "move", or "crosshair"
-
-