4.9 KiB
Built-In Button
UI guidelines on using built-in buttons.
A built-in button is an icon placed inside an input control.
When to use
Browse
The Browse button opens a dialog with the disk, a tree view, or a table of values.
Use the Browse icon for a file/folder path selected from the disk:
A combo box with the Browse button:
val browseExtension = ExtendableTextComponent.Extension.create(
AllIcons.General.OpenDisk,
AllIcons.General.OpenDiskHover,
"Open file",
{ System.out.println("Browse file clicked") }
)
val extComboBox = ComboBox<String>(STRING_VALUES)
extComboBox.setEditable(true)
extComboBox.setEditor(object : BasicComboBoxEditor() {
override fun createEditorComponent(): JTextField {
val ecbEditor = ExtendableTextField()
ecbEditor.addExtension(browseExtension)
ecbEditor.setBorder(null)
return ecbEditor
}
})
ExtendableTextComponent.Extension browseExtension =
ExtendableTextComponent.Extension.create(
AllIcons.General.OpenDisk,
AllIcons.General.OpenDiskHover,
"Open file",
() -> System.out.println("Browse file clicked")
);
ComboBox<String> extComboBox = new ComboBox<>(STRING_VALUES);
extComboBox.setEditable(true);
extComboBox.setEditor(new BasicComboBoxEditor() {
@Override
protected JTextField createEditorComponent() {
ExtendableTextField ecbEditor = new ExtendableTextField();
ecbEditor.addExtension(browseExtension);
ecbEditor.setBorder(null);
return ecbEditor;
}
});
Expand a field
If the input text can be long and the place is constrained,
use the Expand button to expand the control
(ExpandableTextField
):
When the field is expanded, show the Collapse button:
{width=706}
List values
Use the List icon to select a value from the list of classes, methods, or environment variables:
Add value
The Plus button works the same way as the Browse button. The only difference is that the selected value is added instead of overwriting the existing one.
How to use
Place the built-in button inside the input field. Do not place the built-in button next to the field control:
Correct | Incorrect |
![]() |
![]() |
To place a button inside a text field, use ExtendableTextField
and
its addExtension()
method.
The shortcut for a built-in button is Shift+Enter.
When not to use
Cut, Copy, Paste
Do not use the Copy, Paste or Cut button. Instead, make sure these actions are available on pressing Cmd/Ctrl+X, Cmd/Ctrl+C, and Cmd/Ctrl+V shortcuts or from the context menu.
Correct | Incorrect |
![]() |
![]() |
Help, Info
Do not use the Help or Info buttons to open an external link or a hint. Use the context help instead.
Correct | Incorrect |
![]() |
![]() |