JInputGroup extends JavaFX’s HBox to create input groups where multiple elements (inputs, buttons, labels) are visually connected with merged borders. This is useful for creating search bars, URL inputs with prefixes, or any composite input controls.
Overview
JInputGroup automatically manages border styling for grouped elements, ensuring that:- The first element has left-rounded corners
- Middle elements have no rounded corners
- The last element has right-rounded corners
- All elements are seamlessly connected with no gaps
Constructor
Creates a new input group container with zero spacing.
Methods
Adds one or more nodes to the input group. Automatically applies positional styling.
Usage Examples
Search Input with Button
Create a search bar with an input field and button:SearchBar.java
URL Input with Prefix
Add a protocol prefix to a URL input:URLInput.java
Multi-Part Input
Create complex inputs with multiple segments:ComplexInput.java
Input with Icon Addons
Add icons as visual indicators:IconInput.java
Behavior
- Automatic Styling: The component listens to children changes and automatically applies
input-group-left,input-group-center, orinput-group-rightstyle classes - Zero Spacing: Elements are positioned with zero spacing so borders touch seamlessly
- Compatible Elements: Works with JInput, JButton, Label, or any JavaFX Node
Style Classes
.input-group- Applied to the container.input-group-left- Applied to the first child element.input-group-center- Applied to middle child elements.input-group-right- Applied to the last child element
See Also
- JInput - Text input component
- JButton - Button component
- JSearchInput - Standalone search input
Source:
com.jjarroyo.components.JInputGroup in JInputGroup.java:10