Java JToolBar

JToolBar container allows us to group other components, usually buttons with icons in a row or column. JToolBar provides a component which is useful for displaying commonly used actions or controls.

Nested Classes

Modifier and TypeClassDescription
protected classJToolBar.AccessibleJToolBarThis class implements accessibility support for the JToolBar class.
static classJToolBar.SeparatorA toolbar-specific separator.

Constructors

ConstructorDescription
JToolBar()It creates a new tool bar; orientation defaults to HORIZONTAL.
JToolBar(int orientation)It creates a new tool bar with the specified orientation.
JToolBar(String name)It creates a new tool bar with the specified name.
JToolBar(String name, int orientation)It creates a new tool bar with a specified name and orientation.

Useful Methods

Modifier and TypeMethodDescription
JButtonadd(Action a)It adds a new JButton which dispatches the action.
protected voidaddImpl(Component comp, Object constraints, int index)If a JButton is being added, it is initially set to be disabled.
voidaddSeparator()It appends a separator of default size to the end of the tool bar.
protected PropertyChangeListenercreateActionChangeListener(JButton b)It returns a properly configured PropertyChangeListener which updates the control as changes to the Action occur, or null if the default property change listener for the control is desired.
protected JButtoncreateActionComponent(Action a)Factory method which creates the JButton for Actions added to the JToolBar.
ToolBarUIgetUI()It returns the tool bar's current UI.
voidsetUI(ToolBarUI ui)It sets the L&F object that renders this component.
voidsetOrientation(int o)It sets the orientation of the tool bar.

Java JToolBar Example

Output:

Java Jtoolbar
Next TopicJava JViewPort




Latest Courses