Class PrivBotPanel
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
net.runelite.client.ui.PluginPanel
privbot.ui.PrivBotPanel
- All Implemented Interfaces:
ImageObserver,MenuContainer,Serializable,Accessible,net.runelite.client.ui.Activatable
public class PrivBotPanel
extends net.runelite.client.ui.PluginPanel
Reusable sidebar panel for PrivBot plugins.
Provides a consistent layout with:
- Header section with plugin name and status badge
- Action buttons (start/stop, open settings, etc.)
- Live stats area with configurable key-value rows
- Auto-refresh timer support
Usage:
PrivBotPanel panel = new PrivBotPanel("Auto Slayer");
panel.addActionButton("Start", ModernTheme.ACCENT_SUCCESS, e -> startScript());
panel.addActionButton("Settings", ModernTheme.ACCENT_PRIMARY, e -> openSettings());
panel.setStat("Runtime", "00:00:00");
panel.setStat("Kills/hr", "0");
panel.setStatusBadge("Stopped", ModernTheme.ACCENT_DANGER);
panel.startRefreshTimer(1000, () -> updateStats());
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classFluent description of a sidebar;PrivBotPanel.Builder.build()assembles it.Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanelNested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe one label for the settings button, so every plugin's sidebar reads the same.Fields inherited from class net.runelite.client.ui.PluginPanel
BORDER_OFFSET, PANEL_WIDTH, SCROLLBAR_WIDTHFields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH -
Constructor Summary
ConstructorsConstructorDescriptionPrivBotPanel(String pluginName) Creates a sidebar panel with the given plugin name. -
Method Summary
Modifier and TypeMethodDescriptionaddActionButton(String text, Color color, ActionListener listener) Adds an action button to the button row.static PrivBotPanel.BuilderA sidebar described rather than assembled: Start/Stop that polls the plugin's own state, the standard Settings button, and stats read from suppliers by the refresh timer.Returns the button row for adding custom buttons.Returns the stats panel for adding custom content.The status last set withsetStatus(privbot.ui.PanelStatus, java.lang.String)orsetRunning(boolean).installSettingsButton(Runnable openStudio) The standard settings button (SETTINGS_LABEL), always the same label and colour.voidinstallStartStop(Runnable onStart, Runnable onStop) Installs the standardized prominent Start/Stop control at the top of the panel.booleanvoidpollNow()Run every registered poller once (stats and running state); called by the refresh timer.voidsetPluginTitle(String title) Sets the plugin title text.voidsetRunning(boolean running) Updates the Start/Stop button and status badge to reflect the running state.voidSets a stat value.voidsetStatus(PanelStatus status, String text) Show a state with its glyph (never colour alone):● RUNNING,▲ WARNING...voidsetStatusBadge(String text, Color color) Updates the status badge text and color.voidstartRefreshTimer(int intervalMs, Runnable callback) Starts a periodic refresh timer.voidStops the refresh timer.Methods inherited from class net.runelite.client.ui.PluginPanel
getMinimumSize, getPreferredSize, getScrollPane, getWrappedPanelMethods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUIMethods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, updateMethods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTreeMethods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface net.runelite.client.ui.Activatable
onActivate, onDeactivate
-
Field Details
-
SETTINGS_LABEL
The one label for the settings button, so every plugin's sidebar reads the same.- See Also:
-
-
Constructor Details
-
PrivBotPanel
Creates a sidebar panel with the given plugin name.- Parameters:
pluginName- the display name shown in the header
-
-
Method Details
-
builder
A sidebar described rather than assembled: Start/Stop that polls the plugin's own state, the standard Settings button, and stats read from suppliers by the refresh timer.PrivBotPanel panel = PrivBotPanel.builder("Scurrius") .startStop(plugin::start, plugin::stop, plugin::isEnabled) .settings(plugin::openStudio) .stat("Kills", plugin::getKillCount) .runtime("Runtime", plugin::getStartTime) .build(); -
pollNow
public void pollNow()Run every registered poller once (stats and running state); called by the refresh timer. -
addActionButton
Adds an action button to the button row.- Parameters:
text- button textcolor- accent colorlistener- click handler- Returns:
- the created button
-
installStartStop
Installs the standardized prominent Start/Stop control at the top of the panel.This is the framework-standard "one click to start" affordance — every plugin that calls this gets the same green Start / red Stop button plus an auto-synced status badge. Toggle visual state with
setRunning(boolean)(call it from the plugin's refresh hook so the panel stays in sync if the plugin starts/stops by other means).- Parameters:
onStart- invoked when the user clicks StartonStop- invoked when the user clicks Stop
-
installSettingsButton
The standard settings button (SETTINGS_LABEL), always the same label and colour. -
setRunning
public void setRunning(boolean running) Updates the Start/Stop button and status badge to reflect the running state. No-op ifinstallStartStop(java.lang.Runnable, java.lang.Runnable)was never called.- Parameters:
running- whether the plugin is currently running
-
setStatus
Show a state with its glyph (never colour alone):● RUNNING,▲ WARNING...- Parameters:
text- an optional word replacing the default label, e.g."BANKING"
-
getStatus
The status last set withsetStatus(privbot.ui.PanelStatus, java.lang.String)orsetRunning(boolean). -
isRunning
public boolean isRunning()- Returns:
- whether the panel currently shows the running state.
-
setStat
-
setStatusBadge
-
setPluginTitle
Sets the plugin title text. -
startRefreshTimer
Starts a periodic refresh timer.- Parameters:
intervalMs- interval in millisecondscallback- action to run each interval
-
stopRefreshTimer
public void stopRefreshTimer()Stops the refresh timer. -
getStatsPanel
Returns the stats panel for adding custom content. -
getButtonRow
Returns the button row for adding custom buttons.
-