PluginPanel
A side panel for your plugin, opened from a button in the client's sidebar.
Abstract classRuneLiteRuneLite docs
public abstract class PluginPanel extends JPanel implements ActivatableExtend it and build it with Swing: JLabel, JButton, JComboBox, JTextField, layouts and borders, styled with ColorScheme and FontManager. Create a NavigationButton with NavigationButton.builder() (tooltip, icon, priority, panel) and add it with ClientToolbar.addNavigation in startUp(); remove it with ClientToolbar.removeNavigation in shutDown().
Swing runs on its own thread. From a game event or loop(), change the panel inside SwingUtilities.invokeLater(...); from a button, use ClientThread.invoke(...) for game calls, or set a field your loop() reads. A panel reaches only its own components.
Example
package example;
import java.awt.BorderLayout;
import java.awt.image.BufferedImage;
import javax.inject.Inject;
import javax.swing.JButton;
import javax.swing.JLabel;
import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.ui.ClientToolbar;
import net.runelite.client.ui.NavigationButton;
import net.runelite.client.ui.PluginPanel;
import net.runelite.client.util.ImageUtil;
@PluginDescriptor(name = "Example Panel")
public class ExamplePlugin extends Plugin {
@Inject private ClientToolbar clientToolbar;
private NavigationButton button;
@Override
protected void startUp() {
BufferedImage icon = ImageUtil.loadImageResource(ExamplePlugin.class, "icon.png");
button = NavigationButton.builder().tooltip("Example").icon(icon).priority(5)
.panel(new ExamplePanel()).build();
clientToolbar.addNavigation(button);
}
@Override
protected void shutDown() {
clientToolbar.removeNavigation(button);
}
}
class ExamplePanel extends PluginPanel {
private final JLabel status = new JLabel("Ready");
ExamplePanel() {
setLayout(new BorderLayout());
JButton start = new JButton("Start");
start.addActionListener(event -> status.setText("Running"));
add(status, BorderLayout.NORTH);
add(start, BorderLayout.CENTER);
}
}Constants
ABORT, ALLBITS, BORDER_OFFSET, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, ERROR, FRAMEBITS, HEIGHT, LEFT_ALIGNMENT, PANEL_WIDTH, PROPERTIES, RIGHT_ALIGNMENT, SCROLLBAR_WIDTH, SOMEBITS, TOOL_TIP_TEXT_KEY, TOP_ALIGNMENT, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW, WIDTH
Also allowed
These work as in the RuneLite docs.
add, addFocusListener, addImpl, addMouseListener, addMouseMotionListener, addMouseWheelListener, addNotify, areFocusTraversalKeysSet, bounds, checkImage, clone, coalesceEvents, computeVisibleRect, contains, countComponents, createImage, disable, disableEvents, dispatchEvent, doLayout, enable, enableEvents, enableInputMethods, equals, findComponentAt, firePropertyChange, fireVetoableChange, getAlignmentX, getAlignmentY, getAutoscrolls, getBackground, getBaseline, getBorder, getBounds, getClientProperty, getComponent, getComponentAt, getComponentCount, getComponentGraphics, getComponentPopupMenu, getComponents, getComponentZOrder, getCursor, getDebugGraphicsOptions, getDefaultLocale, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getIgnoreRepaint, getInheritsPopupMenu, getInsets, getLayout, getListeners, getLocale, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getPopupLocation, getPreferredSize, getScrollPane, getSize, getToolTipLocation, getToolTipText, getTreeLock, getUIClassID, getVerifyInputWhenFocusTarget, getVisibleRect, getWidth, getWrappedPanel, getX, getY, grabFocus, hasFocus, hashCode, hide, imageUpdate, insets, inside, invalidate, isAncestorOf, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, isFontSet, isForegroundSet, isLightweight, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isShowing, isValid, isValidateRoot, isVisible, layout, locate, location, minimumSize, move, new PluginPanel, nextFocus, paint, paintAll, paintBorder, paintChildren, paintComponent, paintComponents, paintImmediately, paramString, preferredSize, prepareImage, printBorder, printChildren, printComponent, printComponents, processComponentEvent, processEvent, processFocusEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, putClientProperty, remove, removeAll, removeFocusListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, repaint, requestDefaultFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, reshape, resize, revalidate, scrollRectToVisible, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setBounds, setComponentPopupMenu, setComponentZOrder, setCursor, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFocusable, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFocusTraversalPolicyProvider, setFont, setForeground, setIgnoreRepaint, setInheritsPopupMenu, setLayout, setLocale, setLocation, setMaximumSize, setMinimumSize, setMixingCutoutShape, setName, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setSize, setToolTipText, setVerifyInputWhenFocusTarget, setVisible, show, size, toString, transferFocus, transferFocusBackward, transferFocusDownCycle, transferFocusUpCycle, update, updateUI, validate, validateTree