Skip to content

Latest commit

 

History

History
49 lines (36 loc) · 2.56 KB

RibbonAnchoredCommands.md

File metadata and controls

49 lines (36 loc) · 2.56 KB

Flamingo - ribbon anchored commands

The top-right (under left-to-right orientation) corner of the ribbon is reserved for anchored commands. This area can be used to place a small number of commands that can be identified quickly by either their icon only, or by a very short text.

Use JRibbon.addAnchoredCommand() API to add anchored command content. For the screenshot above (that has Share, Chat and Help anchored commands) this is the code that adds such content:

this.getRibbon().addAnchoredCommand(Command.builder()
        .setText(resourceBundle.getString("Share.title"))
        .setIconFactory(Internet_mail.factory())
        .setAction((CommandActionEvent e) -> JOptionPane
                .showMessageDialog(BasicCheckRibbon.this, "Share button clicked"))
        .build()
        .project(CommandButtonPresentationModel.builder().setActionKeyTip("GS").build()));

this.getRibbon().addAnchoredCommand(Command.builder()
        .setIconFactory(Internet_group_chat.factory())
        .setAction((CommandActionEvent e) -> JOptionPane
                .showMessageDialog(BasicCheckRibbon.this, "Chat button clicked"))
        .build()
        .project(CommandButtonPresentationModel.builder().setActionKeyTip("GC").build()));

this.getRibbon().addAnchoredCommand(Command.builder()
        .setIconFactory(Help_browser.factory())
        .setActionRichTooltip(RichTooltip.builder()
                .setTitle(resourceBundle.getString("Help.tooltip.title"))
                .addDescriptionSection(
                        resourceBundle.getString("Help.tooltip.actionParagraph"))
                .build())
        .setAction((CommandActionEvent e) -> JOptionPane
                .showMessageDialog(BasicCheckRibbon.this, "Help button clicked"))
        .build()
        .project(CommandButtonPresentationModel.builder().setActionKeyTip("GH").build()));

The associated keytips are shown at the root level:

Rich tooltips associated with the commands are shown right below the anchored command area:

Next

Continue to ribbon contextual task groups.