Class ExpanderGroup
Expanders open, an accordion: opening one closes the one
that was open. All of them may be closed; closing the open one leaves none open.
When the user opened one, the closing member and then the opening one announce
EXPANDED, then each runs its own onChange, and then the group's
onSelect runs with the open member's index, as a ButtonGroup's does with the
chosen radio's. When code did it, both announce and no
handler runs. A group is not a widget: it has no box, no place in the tree and nothing to say
to a reader, which hears each section by itself.
Each header stays a tab stop of its own: a section is a button, and a form of five sections is five things to reach, as on every platform.
A section is out of its group for as long as it is out of a scene it was in, as a radio is
out of its ButtonGroup: taken out of the tree, or its window closed. The group does not
count it, hold it or open it then, and it takes its place again, among the members that are
there, when it is back in a scene; if it comes back open while the group opened another
meanwhile, it closes, as an adjustment. A section added before it was ever in a scene is a
member from the start.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdds a section.Closes the open member, if any: a caller's write, announced, with no handler.@Nullable Expanderexpanded()intmembers()onSelect(@Nullable IntConsumer listener) The application's response to the user opening or closing a member, with the index of the one open afterwards, or -1 when the user closed the open one: a click, Space or Enter on a header, or an assistive technology's expand or collapse, once both members' own handlers have run, asButtonGroup.onSelectis called.Takes a section out of the group: it opens and closes by itself from then on, and stays as it is.setExpandedIndex(int index) Opens the member atindex, closing the one that was open: a caller's write, so both announceEXPANDED/CODEand no handler runs.
-
Constructor Details
-
ExpanderGroup
public ExpanderGroup()
-
-
Method Details
-
add
Adds a section. If it is open it becomes the group's open member, and the one that was open closes, saying so as an adjustment: the group closed it, not a caller.- Parameters:
expander- the section; one in another group leaves that one first- Returns:
- this group
-
remove
Takes a section out of the group: it opens and closes by itself from then on, and stays as it is. Nothing happens for one that is not a member.- Parameters:
expander- the section- Returns:
- this group
-
members
- Returns:
- the members, in the order they were added; one that is out of the scene it was in is not among them until it is back
-
expanded
- Returns:
- the open member, or null when all are closed
-
expandedIndex
public int expandedIndex()- Returns:
- the open member's index, or -1 when all are closed
-
setExpandedIndex
Opens the member atindex, closing the one that was open: a caller's write, so both announceEXPANDED/CODEand no handler runs.- Parameters:
index- a member in[0, members().size())- Returns:
- this group
- Throws:
IndexOutOfBoundsException- ifindexis not a member
-
collapseAll
Closes the open member, if any: a caller's write, announced, with no handler.- Returns:
- this group
-
onSelect
The application's response to the user opening or closing a member, with the index of the one open afterwards, or -1 when the user closed the open one: a click, Space or Enter on a header, or an assistive technology's expand or collapse, once both members' own handlers have run, asButtonGroup.onSelectis called. Never forsetExpandedIndex(int),collapseAll()or a member'sExpander.setExpanded(boolean), which are a caller's writes; to hear every change whatever caused it, watch the members.- Parameters:
listener- the handler, ornullto clear the slot- Returns:
- this group
- Throws:
IllegalStateException- if a handler is already registered
-