Comments (1)
Java docs: MultiSelectField, MultiSelectField.Builder ValidatedMultiSelectField
The builder is probably the most convenient way to create a MultiSelectField
. All of the builder settings are optional. The builder constructor parameters control the appearance of the MultiSelectItems.
showDelete
- display a delete button (x) on each itemopaqueItems
- fill the item chips with the background color
MultiSelectField field = MultiSelectField.builder(true, true)
// prepopulate the field with values
.items(Arrays.asList("one", "two"))
// the `tab` key switches focus instead inputing a character
.disableTab()
// validate pending items (e.g. only allow unique values)
.pendingItemValidator((input, text) -> input.getItems().indexOf(text) == input.getItems().size()-1)
// don't add the pending item when focus changes
.setKeepTextOnFocusLost(true)
// don't allow focus change with an invalid pending item
.setYieldFocusOnError(false)
.get();
If .validator
is used then the builder returns a ValidatedMultiSelectField
which can be used with ValidationBorder
to indicate invalid input.
ValidatedMultiSelectField field = MultiSelectField.builder(true, true)
// validate the list (e.g. require minimum input)
.validator(items -> items.size() < 2 ? "Need at least 2 values" : null)
.get();
JScrollPane scrollPane = new JScrollPane(field);
ValidationBorder.addToViewport(field);
JFrame frame = new JFrame("test");
frame.getContentPane().setLayout(new BorderLayout());
frame.getContentPane().add(scrollPane, BorderLayout.CENTER);
frame.pack();
frame.setSize(400, 100);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.setVisible(true);
from swing-extensions.
Related Issues (1)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swing-extensions.