Class Gui
java.lang.Object
com.realtime.crossfire.jxclient.gui.gui.Gui
Combines a list of
GUIElements to for a gui.
A dialog can be modal. Such dialogs do not propagate key or mouse events to lower dialogs.
-
Constructor Summary
ConstructorsConstructorDescriptionGui(@NotNull String name, @NotNull KeyBindings keyBindings) Creates a new instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidActivates the first default gui element of this gui.voidautoSize(int screenWidth, int screenHeight) Auto-resizes the dialog.booleanDeactivates the command text input field of this dialog.@NotNull JComponentReturns theJComponentfor this instance.@Nullable AbstractGUIElementgetElementFromPoint(int x, int y) Determines theGUIElementfor a given coordinate.<T extends GUIElement>
TgetFirstElement(@NotNull Class<T> class_) Returns the first gui element of this gui belonging to the given class.<T extends GUIElement>
TgetFirstElement(@NotNull Class<T> class_, @NotNull String name) Returns the first gui element of this gui belonging to the given class and having the given name.<T extends GUIElement>
TgetFirstElementEndingWith(@NotNull Class<T> class_, @NotNull String ending) Returns the first gui element of this gui which belongs to the given class and that's name ends with the given ending.<T extends GUIElement>
TgetFirstElementNotEndingWith(@NotNull Class<T> class_, @NotNull String ending) Returns the first gui element of this gui which belongs to the given class and that's name does not end with the given ending.@Nullable GUIPicturegetHelp()Returns the help icon of this dialog.@NotNull KeyBindingsReturns the key bindings instance for this gui.booleanhandleKeyPress(@NotNull KeyEvent2 e) Dispatches a key pressKeyEvent.voidhideInState(@NotNull RendererGuiState state) Hides the dialog in a state.booleanisActiveElement(@Nullable ActivatableGUIElement activeElement) Returns whether a given gui element is the active element of this dialog.booleanReturns whether this dialog is an auto-size dialog.booleanisHidden(@NotNull RendererGuiState state) Returns whether this gui is visible in a state.booleanisModal()Returns the modal state.booleanReturns whether this dialog retains its position across restarts.booleanReturns whether the dialog is user-resizable.booleanisWithinDrawingArea(int x, int y) Returns whether a given point is within this dialog's drawing area.voidCallGUIElement.notifyOpen()for all GUI elements.voidrepaint()Repaints this component.voidsetActiveElement(@NotNull ActivatableGUIElement activeElement, boolean active) Sets the gui element owning the focus.voidsetActiveElementActive(boolean active) Activates or deactivates the GUI element owning the focus.voidsetAutoSize(@Nullable Extent autoSize) Sets the auto-size state.voidsetBounds(int x, int y, int width, int height, int windowWidth, int windowHeight) Sets the position and size of this dialog.voidsetDefaultPosition(@NotNull Expression defaultX, @NotNull Expression defaultY) Sets the default position for this dialog.voidsetForcedActive(@Nullable ActivatableGUIElement forcedActive) Sets anActivatableGUIElementthat is always active.voidsetGuiAutoCloseListener(@Nullable GuiAutoCloseListener guiAutoCloseListener) Sets theGuiAutoCloseListenerto be notified when this dialog becomes inactive.voidsetHelp(@NotNull GUIPicture help) Sets the help icon of this dialog.voidsetModal(boolean modal) Sets the modal state.voidsetOpaqueDialogBackground(boolean opaque) Sets whether the dialog's background is opaque.voidMakes this dialog retain its position across restarts.voidsetShowSentCommands(boolean showSentCommands) Sets whether the commands sent to the server should be shown in the messages dialog.voidsetShowTimestamps(boolean showTimestamps) Sets whether timestamps should be shown in the messages dialog.voidsetUserResizable(boolean userResizable) Sets whether the dialog is user-resizable.@NotNull StringtoString()
-
Constructor Details
-
Gui
Creates a new instance.- Parameters:
name- the name of this GUIkeyBindings- the keybindings to use
-
-
Method Details
-
getComponent
Returns theJComponentfor this instance.- Returns:
- the component
-
setAutoSize
Sets the auto-size state. Auto-size dialogs cannot be moved or resized manually.- Parameters:
autoSize- the new auto-size ornull
-
isAutoSize
public boolean isAutoSize()Returns whether this dialog is an auto-size dialog. Auto-size dialogs cannot be moved or resized manually.- Returns:
- whether this dialog is auto-size
-
setModal
public void setModal(boolean modal) Sets the modal state.- Parameters:
modal- the new modal state
-
isModal
public boolean isModal()Returns the modal state.- Returns:
- the modal state
-
setUserResizable
public void setUserResizable(boolean userResizable) Sets whether the dialog is user-resizable.- Parameters:
userResizable- whether the dialog is user-resizable
-
isUserResizable
public boolean isUserResizable()Returns whether the dialog is user-resizable.- Returns:
- whether the dialog is user-resizable
-
activateDefaultElement
public void activateDefaultElement()Activates the first default gui element of this gui. -
getFirstElementEndingWith
@Nullable public <T extends GUIElement> T getFirstElementEndingWith(@NotNull @NotNull Class<T> class_, @NotNull @NotNull String ending) Returns the first gui element of this gui which belongs to the given class and that's name ends with the given ending.- Type Parameters:
T- the class to search for- Parameters:
class_- the class to search forending- the ending to search for- Returns:
- the gui element or
nullif not found
-
getFirstElementNotEndingWith
@Nullable public <T extends GUIElement> T getFirstElementNotEndingWith(@NotNull @NotNull Class<T> class_, @NotNull @NotNull String ending) Returns the first gui element of this gui which belongs to the given class and that's name does not end with the given ending.- Type Parameters:
T- the class to search for- Parameters:
class_- the class to search forending- the ending to search for- Returns:
- the gui element or
nullif not found
-
getFirstElement
Returns the first gui element of this gui belonging to the given class.- Type Parameters:
T- the class to search for- Parameters:
class_- the class to search for- Returns:
- the gui element or
nullif not found
-
getElementFromPoint
Determines theGUIElementfor a given coordinate.- Parameters:
x- the x-coordinate to checky- the y-coordinate to check- Returns:
- the
GUIElementat the given coordinate ornullif none was found
-
setActiveElement
Sets the gui element owning the focus.- Parameters:
activeElement- the gui elementactive- the new active state
-
isActiveElement
Returns whether a given gui element is the active element of this dialog.- Parameters:
activeElement- the gui element- Returns:
- whether the given gui element is active
-
setActiveElementActive
public void setActiveElementActive(boolean active) Activates or deactivates the GUI element owning the focus. Does nothing if no focus owner exists.- Parameters:
active- whether to activate the GUI element
-
handleKeyPress
Dispatches a key pressKeyEvent.- Parameters:
e- the event to dispatch- Returns:
- whether a gui element did handle the event
-
deactivateCommandInput
public boolean deactivateCommandInput()Deactivates the command text input field of this dialog. Does nothing if the command text input field is not active or if this dialog has no command text input field.- Returns:
- whether the command text input field has been deactivated
-
getFirstElement
@Nullable public <T extends GUIElement> T getFirstElement(@NotNull @NotNull Class<T> class_, @NotNull @NotNull String name) Returns the first gui element of this gui belonging to the given class and having the given name.- Type Parameters:
T- the class to search for- Parameters:
class_- the class to search forname- the button's name- Returns:
- the button or
nullif no button matches
-
getKeyBindings
Returns the key bindings instance for this gui.- Returns:
- the key bindings
-
hideInState
Hides the dialog in a state.- Parameters:
state- the state
-
isHidden
Returns whether this gui is visible in a state.- Parameters:
state- the state- Returns:
- whether this gui is hidden
-
setGuiAutoCloseListener
Sets theGuiAutoCloseListenerto be notified when this dialog becomes inactive.- Parameters:
guiAutoCloseListener- the listener to be notified ornull
-
isWithinDrawingArea
public boolean isWithinDrawingArea(int x, int y) Returns whether a given point is within this dialog's drawing area.- Parameters:
x- the x-coordinate of the pointy- the y-coordinate of the point- Returns:
- whether the coordinate is within the drawing area
-
setForcedActive
Sets anActivatableGUIElementthat is always active. It prevents any other element from getting active.- Parameters:
forcedActive- the element to set ornullto unset
-
toString
-
autoSize
public void autoSize(int screenWidth, int screenHeight) Auto-resizes the dialog. This makes sure that the dialog is completely visible on the screen.- Parameters:
screenWidth- the screen widthscreenHeight- the screen height
-
setDefaultPosition
public void setDefaultPosition(@NotNull @NotNull Expression defaultX, @NotNull @NotNull Expression defaultY) Sets the default position for this dialog.- Parameters:
defaultX- the default x-coordinatedefaultY- the default y-coordinate
-
isSaveDialog
public boolean isSaveDialog()Returns whether this dialog retains its position across restarts.- Returns:
- whether this dialog retains its position across restarts
-
setSaveDialog
public void setSaveDialog()Makes this dialog retain its position across restarts. -
notifyOpen
public void notifyOpen()CallGUIElement.notifyOpen()for all GUI elements. -
getHelp
Returns the help icon of this dialog.- Returns:
- the help icon or
nullif this is not a dialog or if this dialog has no help icon
-
setHelp
Sets the help icon of this dialog.- Parameters:
help- the help icon
-
setBounds
public void setBounds(int x, int y, int width, int height, int windowWidth, int windowHeight) Sets the position and size of this dialog. The location may be modified to make sure the dialog is fully visible in the main window. The size will be increased if it is smaller than the allowed minimum size or decreased if it is larger than the allowed maximum size.- Parameters:
x- the x-coordinate of the dialogy- the y-coordinate of the dialogwidth- the width of the dialogheight- the height of the dialogwindowWidth- the main window's widthwindowHeight- the main window's height
-
repaint
public void repaint()Repaints this component. -
setOpaqueDialogBackground
public void setOpaqueDialogBackground(boolean opaque) Sets whether the dialog's background is opaque.- Parameters:
opaque- whether the background is opaque
-
setShowSentCommands
public void setShowSentCommands(boolean showSentCommands) Sets whether the commands sent to the server should be shown in the messages dialog.- Parameters:
showSentCommands- whether to show the commands
-
setShowTimestamps
public void setShowTimestamps(boolean showTimestamps) Sets whether timestamps should be shown in the messages dialog.- Parameters:
showTimestamps- whether to show timestamps
-