Learning The "J"

Home » JAVA Learning » Netbeans Ribbon Bar Integration

Netbeans Ribbon Bar Integration

This tutorial is based on the following tutorial https://platform.netbeans.org/tutorials/nbm-ribbonbar.html#intro
Download the source code from https://java.net/projects/nbribbonbar/. After configuring it you should see something similar to the following
flprojstructure

 

 

On expanding the Flamingo module you could see following
fljars

It is to be noted that flamingo.jar, forms-1.3.0.jar and trident.jar are added in this module as libraries

Mark all the packages of Flamingo as public

flpublic

 

 

 

Make a new project and add the Flamingo and Flamingo Integration modules to your newly created project

flproj

Expand the Flamingo Integration module and add the resources package in it, in the resources package we can place our icons and images

flint

Ribbon bar

ribbonstruct

Open the LayerRibbonComponentProvider class present in the package com.pinkmatter.modules.flamingo

Add the following to the @Override method public JComponent createRibbon()


JRibbon ribbon = new JRibbon();

JCommandButton LASSetupbutton1 = new JCommandButton("DICOM Viewers", null);
LASSetupbutton1.setIcon(  ImageWrapperResizableIcon.getIcon(LayerRibbonComponentProvider.class.getClassLoader().getResource("/com/pinkmatter/api/flamingo/resources/lasimg.jpg"), new Dimension(100, 100)));

JRibbonBand band1=new JRibbonBand("LAS band1", null);
band1.addCommandButton(LASSetupbutton1, TOP);
band1.setResizePolicies((List) Arrays.asList(new IconRibbonBandResizePolicy(band1.getControlPanel())));

RibbonTask task1 = new RibbonTask("LAS Setup", band1);

band1.setResizePolicies((List) Arrays.asList(new CoreRibbonResizePolicies.None(band1.getControlPanel()),
        new IconRibbonBandResizePolicy(band1.getControlPanel())));

ribbon.addTask(task1);		

LASSetupbutton1.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {           
        Action action = FileUtil.getConfigObject("Actions/Window/org-netbeans-modules-options-OptionsWindowAction.instance", Action.class);
        action.actionPerformed(e);
        }
    });
	
return ribbon;

Related links kinks
https://dzone.com/articles/office-laf-netbeans-platform
https://java.net/projects/officelaf/sources
https://java.net/projects/nbribbonbar/
https://blogs.oracle.com/geertjan/entry/decreasing_the_height_of_the1
https://blogs.oracle.com/geertjan/entry/fixing_the_ribbon_bar_integration

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Start here

%d bloggers like this: