JTerminal documentation Help

MenuBar

The MenuBar allows you to insert a control element in the screen, which is always displayed at the top.

MenuTab tab1 = new MenuTab("File"); tab1.add(new MenuItem("New")); tab1.add(new MenuItem("Save")); tab1.add(new MenuItem("Open")); tab1.add(new MenuItem("Exit").action(() -> { Terminal.get().shutdown(1); })); MenuTab tab2 = new MenuTab("Options"); tab2.add(new MenuItem("Colors")); tab2.add(new MenuItem("Font")); tab2.add(new MenuItem("Language")); MenuBarComponent menuBarComponent = new MenuBarComponent(); menuBarComponent.add(tab1); menuBarComponent.add(tab2);
menubar example

Methods

Method

Description

int minimumMenuWidth()

Returns the width of menu block

void minimumMenuWidth(int)

Set maximum width of menu block

void selectedStyle(TextStyle)

Sets selection style (Default: TextFont.UNDERLINE)

void add(MenuTab)

Add new tab

void remove(MenuTab)

Remove tab

MenuTab selectedTab()

Returns selected tab. If none is present, null is returned

selectTab(MenuTab)

Selects a tab

Collection<MenuTab> menuTabs()

Return all tabs

Last modified: 01 Juni 2025