Flamingo tutorial
In this article, I will provide you with the documentation to easily use the Flamingo framework and more precisely, its ribbon widget.
Introduction
Never say that Microsoft never innovates: in Office, it introduced an interesting concept, the ribbon band.

The ribbon band is a toolbar of sort. But whereas toolbars are fixed, ribbons layout can change according to the width they display. If you have such an application, just play with it for a few seconds and you will see the magic happens.
Recent versions of Swing do not have such widgets. However, I found the Flamingo project on java.net. Examples made with Flamingo look awfully similar to Office.

Trying to use Flamingo for the first time is no small feat since there’s no documentation on the Web, apart from Javadocs and the source for a test application. The following is what I understood since I began my trial and error journey.
The basics
Semantics
- the ribbon is the large bar on the screenshot above. There can be only a single ribbon for a frame
- a task is a tabbed group of one or more band. On the screenshot, tasks are Page Layout, Write, Animations and so on
- a band is a group of one or more widgets. On the screenshot, bands are Clipboard, Quick Styles, Font and so on
Underlying concepts
The core difference between buttons in a toolbar and band in a ribbon bar is that bands are resizable. For examples, these are the steps for displaying the Document band, in regard to both its relative width and the ribbon width.




The last step is known as the iconified state. When you click on the button, it displays the entire band as a popup.
Your first ribbon
Setup
In order to use the Flamingo framework, the first step is to download it. If you’re using Maven, tough luck! I didn’t find Flamingo in central nor java.net repositories. So download it anyway and install it manually in your local (or enterprise) repository. For information, I choosed the net.java.dev.flamingo:flamingo location.
The frame
If you are starting from scratch, you’re lucky. Just inherit from JRibbonFrame: the method getRibbon() will provide you a reference to the ribbon instance. From there, you will be able to add tasks to it.
However, chances are you probably already have your own frame hierachy. In this case, you have to instantiate a JRibbon and add it on the NORTH location of your BorderLayout-ed frame.
In both cases, the result should be something akin to that:

Adding a task
Tasks represent logical band grouping. They look like tabs and act the part too. Let’s add two such tasks aptly named “One” and “Two”.
public class MainFrame extends JRibbonFrame {
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
MainFrame frame = new MainFrame();
frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
RibbonTask task1 = new RibbonTask("One");
RibbonTask task2 = new RibbonTask("Two");
frame.getRibbon().addTask(task1);
frame.getRibbon().addTask(task2);
}
});
}
}
Notice the getRibbon() method on the JRibbonFrame. It is the reference on the ribbon bar.
Also notice that the addTask() method accepts a task but also a varargs of JRibbonBand. And if you launch the above code, it will fail miserably with the following error:
Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Cannot have empty ribbon task at org.jvnet.flamingo.ribbon.RibbonTask.<init>(RibbonTask.java:85) at MainFrame$1.run(MainFrame.java:37) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209) at java.awt.EventQueue.dispatchEvent(EventQueue.java:597) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161) at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Adding bands
To satisfy our Flamingo friend, let’s add a ribbon band to each task. The constructor of JRibbonBand takes two argument, the label and an instance of a previously unknown class, ResizableIcon. It will be seen in detail in the next section.
As for now, if you just create the RibbonTask with a reference to the JRibbonBand and launch the application, you will get such an error:
Exception in thread "AWT-EventQueue-0" java.lang.IllegalStateException: Inconsistent preferred widths Ribbon band 'Hello has the following resize policies org.jvnet.flamingo.ribbon.resize.CoreRibbonResizePolicies$None with preferred width -4 org.jvnet.flamingo.ribbon.resize.CoreRibbonResizePolicies$Low2Mid with preferred width -4 org.jvnet.flamingo.ribbon.resize.CoreRibbonResizePolicies$Mid2Mid with preferred width -4 org.jvnet.flamingo.ribbon.resize.CoreRibbonResizePolicies$Mirror with preferred width -4 org.jvnet.flamingo.ribbon.resize.CoreRibbonResizePolicies$Mid2Low with preferred width -4 org.jvnet.flamingo.ribbon.resize.CoreRibbonResizePolicies$High2Mid with preferred width -4 org.jvnet.flamingo.ribbon.resize.IconRibbonBandResizePolicy with preferred width 42
Remember that bands are resizable? Flamingo needs information on how to do it. Before initial display, it will check that those policies are consistent. By default, they are not and this is the reason why it complains: Flamingo requires you to have at least the iconified policy that must be in the last place. In most cases, however, you’ll want to have at least a normal display in the policies list.
Let’s modify the code to do it:
JRibbonBand band1 = new JRibbonBand("Hello", null);
JRibbonBand band2 = new JRibbonBand("world!", null);
band1.setResizePolicies((List) Arrays.asList(new IconRibbonBandResizePolicy(band1.getControlPanel())));
band2.setResizePolicies((List) Arrays.asList(new IconRibbonBandResizePolicy(band1.getControlPanel())));
RibbonTask task1 = new RibbonTask("One", band1);
RibbonTask task2 = new RibbonTask("Two", band2);
The previous code let us at least see something:

Adding buttons (at last!)
Even if the previous compiles and runs, it still holds no interest. Now is the time to add some buttons!
JCommandButton button1 = new JCommandButton("Square", null);
JCommandButton button2 = new JCommandButton("Circle", null);
JCommandButton button3 = new JCommandButton("Triangle", null);
JCommandButton button4 = new JCommandButton("Star", null);
band1.addCommandButton(button1, TOP);
band1.addCommandButton(button2, MEDIUM);
band1.addCommandButton(button3, MEDIUM);
band1.addCommandButton(button4, MEDIUM);
Too bad there’s no result! Where are our buttons? Well, they are well hidden. Remember the resize policies? There’s only one, the iconified one and its goal is only to display the iconified state. Just update the policies line with the code:
band1.setResizePolicies((List) Arrays.asList(new CoreRibbonResizePolicies.None(band1.getControlPanel()), new IconRibbonBandResizePolicy(band1.getControlPanel())));
The result looks the same at first, but when you resize the frame, it looks like this:

Even if it’s visually not very attractive, it looks much better than before. We see the taks, the name of the band and the labels on our four buttons.
Resizable icons
The JCommandButton‘s constructor has 2 parameters: one for the label, the other for a special Flamingo class, the ResizableIcon. Since Flamingo is all about displaying the same button in different sizes, that’s no surprise. Resizable icons can be constructed from Image, ico resources or even SVG.
Let’s add an utility method to our frame, and spice up our UI:
public static ResizableIcon getResizableIconFromResource(String resource) {
return ImageWrapperResizableIcon.getIcon(MainFrame.class.getClassLoader().getResource(resource), new Dimension(48, 48));
}
...
JCommandButton button1 = new JCommandButton("Square", getResizableIconFromResource("path"));
JCommandButton button2 = new JCommandButton("Circle", getResizableIconFromResource("to"));
JCommandButton button3 = new JCommandButton("Triangle", getResizableIconFromResource("the"));
JCommandButton button4 = new JCommandButton("Star", getResizableIconFromResource("resource"));
band1.addCommandButton(button1, TOP);
band1.addCommandButton(button2, MEDIUM);
band1.addCommandButton(button3, MEDIUM);
band1.addCommandButton(button4, MEDIUM);
This is somewhat more satisfying:
![]()
Choosing policies
Now we’re ready to tackle Flamingo’s core business, resizing management. If you have Office, and played with it, you saw that the resizing policies are very rich. And we also saw previously that with only two meager policies, we can either see the iconified display or the full display.
Let’s see how we could go further. You probably noticed that the addCommandButton() of JRibbonBand has 2 parameters: the button to add and a priority. It is this priority and the policy that Flamingo use to choose how to display the band.
Priorities are the following: TOP, MEDIUM and LOW.
Policies are:
| Policy | Description |
|---|---|
CoreRibbonResizePolicies.None |
Command buttons will be represented in the TOP state (big button with label and icon) |
CoreRibbonResizePolicies.Mid2Mid |
Command buttons that have MEDIUM priority will be represented in the MEDIUM state (small button with label and icon) |
CoreRibbonResizePolicies.Mid2Low |
Command buttons that have MEDIUM priority will be represented in the LOW state (small button only icon) |
CoreRibbonResizePolicies.High2Mid |
Command buttons that have HIGH priority will be represented in the MEDIUM state |
CoreRibbonResizePolicies.High2Low |
Command buttons that have HIGH priority will be represented in the LOW state |
CoreRibbonResizePolicies.Low2Mid |
Command buttons that have LOW priority will be represented in the MEDIUM state |
CoreRibbonResizePolicies.Mirror |
Command buttons will be represented in the priority they were assigned to |
IconRibbonBandResizePolicy |
Command buttons will be not represented. The entire band will be represented by a command button that when pressed will show a popup of the unconstrained band |
Now, you have all elements to let you decide which policies to apply. There’s one rule though: when setting policies, the width of the band must get lower and lower the higher the index of the policy (and it must end with the IconRibbonBandResizePolicy) let you’ll get a nasty IllegalStateException: Inconsistent preferred widths (see above).
Let’s apply some policies to our band:
band1.setResizePolicies((List) Arrays.asList( new CoreRibbonResizePolicies.None(band1.getControlPanel()), new CoreRibbonResizePolicies.Mirror(band1.getControlPanel()), new CoreRibbonResizePolicies.Mid2Low(band1.getControlPanel()), new CoreRibbonResizePolicies.High2Low(band1.getControlPanel()), new IconRibbonBandResizePolicy(band1.getControlPanel())));
This will get us the following result:



Note: there won’t be any iconified state in my example since the band does not compete for space with another one.
More features
Flamingo’s ribbon feature let you also:
- add standard Swing components to the ribbon
- add a menu on the top left corner

- integration with standard Look and Feels

- tight integration with Substance L&F
Those are also undocumented but are much easier to understand on your own.
It also has other features:
- Breadcrumb bar
- Command button strips and panels
Conclusion
Flamingo is a nice and powerful product, hindered by a big lack of documentation. I hope this article will go one step toward documenting it.
Here are the sources for this article in Eclipse/Maven format.
To go further:
- The Flamingo site
- Some demo applications
- The latest release (4.2) download page
- Kirill Grouchnivkov (Flamingo’s father) site, where he blogs about Flamingo and other products
– Edit on 28th june 2010: feedback from Kirill –
- Version 5.0 no longer requires “iconified” policy to be present
- I strongly suggest not using image-based icons. The recommended way is to transcode SVG files to Java2D-based classes with an offline process and use those classes at runtime. This is what i do in the BasicCheckRibbon class.

Great tutorial, helped me a lot with integrating flamingo into a project. Only thing i missed is how to use a JCommandButton with a JCommandPopupMenu (button.setPopupCallback(your PopupPanelCallback etc.).
Cheers Yves
I still can not put an icon in JRibbonButton in all the blogs I look for help, people do not explain clearly how this can be done. The project documentation is very poor and not very helpful. I do not know if I can use JPEG files as I do with the SWING component. None of this seems well explained. Do i need to create a class to be able to insert an icon in JRibbonButton? I already tried this, but without success. How do I do that? Can someone exeplificar this clearly.
nullException in thread “AWT-EventQueue-0″ java.lang.NullPointerException
at org.pushingpixels.flamingo.common.icon.ImageWrapperResizableIcon.getIcon(ImageWrapperResizableIcon.java:71)
at MainFrame.getResizableIconFromResource(MainFrame.java:33)
at MainFrame$1.run(MainFrame.java:58)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
at
When i try to use Icons on it, a get this exceptions: ImageWrapperResizableIcon.getIcon(MainFrame.class.getClassLoader().getResource(resource), new Dimension(48, 48));
I think it´s in the class loader, or maybe in the resource, can you help with that ? Explain how it works ?
java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
something is wrong in method
@Renato Clemente
In order to get a resizable icon, you should use the following line:
ResizableIcon icon = ImageWrapperResizableIcon.getIcon(MainFrame.class.getClassLoader().getResource(resource), new Dimension(48, 48));
Then, most constructors (including JCommandButton) use a ResizableIcon as a parameter.
This have been extremly helpfull but can you explain how to put the menu?
Really really thanks for this.
@omarenm
Forget it, i did it.
You’re welcome
Great article to help me get started using JRibbon. Please could you guide me on more resources to learn JRibbon.
Thanks.
Hi Sid,
One of the main reason I wrote this article is because documentation on Flamingo is lacking. Kirill Grouchnikov (Flamingo’s developer) explains it here: http://www.pushing-pixels.org/?p=1043. I can’t redirect you anywhere beside here and the code itself. Sorry…
//I follow the step you write
//and this is the code but with exception
import java.awt.Dimension;
import java.util.Arrays;
import java.util.List;
import javax.swing.SwingUtilities;
import org.pushingpixels.flamingo.api.common.JCommandButton;
import org.pushingpixels.flamingo.api.common.icon.ImageWrapperResizableIcon;
import org.pushingpixels.flamingo.api.common.icon.ResizableIcon;
import org.pushingpixels.flamingo.api.ribbon.JRibbonBand;
import org.pushingpixels.flamingo.api.ribbon.JRibbonFrame;
import org.pushingpixels.flamingo.api.ribbon.RibbonElementPriority;
import org.pushingpixels.flamingo.api.ribbon.RibbonTask;
import org.pushingpixels.flamingo.api.ribbon.resize.CoreRibbonResizePolicies;
import org.pushingpixels.flamingo.api.ribbon.resize.IconRibbonBandResizePolicy;
public class test2 extends JRibbonFrame {
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
test2 frame = new test2();
frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
frame.pack();
JRibbonBand band1 = new JRibbonBand(“Hello”, null);
JRibbonBand band2 = new JRibbonBand(“world!”, null);
band1.setResizePolicies((List) Arrays.asList( new CoreRibbonResizePolicies.None(band1.getControlPanel()), new CoreRibbonResizePolicies.Mirror(band1.getControlPanel()), new CoreRibbonResizePolicies.Mid2Low(band1.getControlPanel()), new CoreRibbonResizePolicies.High2Low(band1.getControlPanel()), new IconRibbonBandResizePolicy(band1.getControlPanel())));
band2.setResizePolicies((List) Arrays.asList( new CoreRibbonResizePolicies.None(band1.getControlPanel()), new CoreRibbonResizePolicies.Mirror(band1.getControlPanel()), new CoreRibbonResizePolicies.Mid2Low(band1.getControlPanel()), new CoreRibbonResizePolicies.High2Low(band1.getControlPanel()), new IconRibbonBandResizePolicy(band1.getControlPanel())));
RibbonTask task1 = new RibbonTask(“One”, band1);
RibbonTask task2 = new RibbonTask(“Two”, band2);
frame.getRibbon().addTask(task1);
frame.getRibbon().addTask(task2);
JCommandButton button1 = new JCommandButton(“Square”, getResizableIconFromResource(“path”));
JCommandButton button2 = new JCommandButton(“Circle”, getResizableIconFromResource(“to”));
JCommandButton button3 = new JCommandButton(“Triangle”, getResizableIconFromResource(“the”));
JCommandButton button4 = new JCommandButton(“Star”, getResizableIconFromResource(“resource”));
band1.setResizePolicies((List) Arrays.asList(new CoreRibbonResizePolicies.None(band1.getControlPanel()),
new IconRibbonBandResizePolicy(band1.getControlPanel())));
band2.setResizePolicies((List) Arrays.asList(new CoreRibbonResizePolicies.None(band1.getControlPanel()),
new IconRibbonBandResizePolicy(band1.getControlPanel())));
band1.addCommandButton(button1, RibbonElementPriority.TOP);
band1.addCommandButton(button1, RibbonElementPriority.MEDIUM);
band1.addCommandButton(button1, RibbonElementPriority.LOW);
band2.addCommandButton(button1, RibbonElementPriority.TOP);
band2.addCommandButton(button1, RibbonElementPriority.MEDIUM);
band2.addCommandButton(button1, RibbonElementPriority.LOW);
} }); }
public static ResizableIcon getResizableIconFromResource(String resource) {
return ImageWrapperResizableIcon.getIcon(test2.class.getClassLoader().getResource(resource), new Dimension(48, 48)); }
}
// the exception i get
Exception in thread “AWT-EventQueue-0″ java.lang.IllegalStateException: Inconsistent preferred widths
Ribbon band ‘Hello’ has the following resize policies
org.pushingpixels.flamingo.api.ribbon.resize.CoreRibbonResizePolicies$None with preferred width -2
org.pushingpixels.flamingo.api.ribbon.resize.CoreRibbonResizePolicies$Mirror with preferred width -2
org.pushingpixels.flamingo.api.ribbon.resize.CoreRibbonResizePolicies$Mid2Low with preferred width -2
org.pushingpixels.flamingo.api.ribbon.resize.CoreRibbonResizePolicies$High2Low with preferred width -2
org.pushingpixels.flamingo.api.ribbon.resize.IconRibbonBandResizePolicy with preferred width 42
org.pushingpixels.flamingo.api.ribbon.resize.CoreRibbonResizePolicies$High2Low with pref width -2 is followed by resize policy org.pushingpixels.flamingo.api.ribbon.resize.IconRibbonBandResizePolicy with larger pref width
at org.pushingpixels.flamingo.internal.utils.FlamingoUtilities.checkResizePoliciesConsistency(FlamingoUtilities.java:579)
at org.pushingpixels.flamingo.api.ribbon.AbstractRibbonBand.setRibbonTask(AbstractRibbonBand.java:539)
at org.pushingpixels.flamingo.api.ribbon.RibbonTask.(RibbonTask.java:90)
at test2$1.run(test2.java:34)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
———————————————————————————————————
please help me
Hello
Is there an Api for Flamingo? And how can I get the source code of the .class folder from
.
https://flamingo.dev.java.net/servlets/ProjectDocumentList?folderID=11909
(Flamingo 5.0 test applications) .. there are only .class folder
My main reason is to use resizeable icons. Can you give me a hint, i want to use .svg icons. But there are problems if I set Look&Feels (substance) ..
Then I tried your Code from above, but I get an exception.
Thanks in Advance
You can get the whole package (source and jars) there. With the sources, you can build the javadoc with the javadoc tool. Hope it helps.
Hello Nicolas,
I’m glad to get any explanation.
Maybe you can help me again. If I set the icons on your code, my button shows a free place where the icon should be, but it isn’t shown. Do you know about problem?
Thanks in Advance!
Claudia
@Claudia K
Please show me the code so that I can test. To be frank, I have never tried .svg images in Flamingo’s buttons.
public class MainFrame extends JRibbonFrame
{
public static void main(String[]args)
{
SwingUtilities.invokeLater(new Runnable()
{
@Override
public void run()
{
MainFrame frame = new MainFrame();
// frame.setSize(new Dimension(500,500));
frame.setDefaultCloseOperatio(EXIT_ON_CLOSE);
frame.setResizable(true);
frame.pack();
frame.setVisible(true);
JRibbonBand band1 = new JRibbonBand(“Hello”, null);
JRibbonBand band2 = new JRibbonBand(“world!”, null);
band1.setResizePolicies((List) Arrays.asList(new IconRibbonBandResizePolicy(band1.getControlPanel())));
band2.setResizePolicies((List) Arrays.asList(new IconRibbonBandResizePolicy(band1.getControlPanel())));
RibbonTask task1 = new RibbonTask(“One”, band1);
RibbonTask task2 = new RibbonTask(“Two”, band2);
frame.getRibbon().addTask(task1);
frame.getRibbon().addTask(task2);
// C:\Dokumente und Einstellungen\Claudia\Desktop\svgicons\black // “src\\gui\\rightblack.svg”
JCommandButton button1 = new JCommandButton(“Square”, getResizableIconFromResource(“src\\gui\\rightblack.svg”));
JCommandButton button2 = new JCommandButton(“Circle”, null);
JCommandButton button3 = new JCommandButton(“Triangle”, null);
JCommandButton button4 = new JCommandButton(“Star”, null);
band1.addCommandButton(button1, RibbonElementPriority.TOP);
band1.addCommandButton(button2, RibbonElementPriority.MEDIUM);
band1.addCommandButton(button3, RibbonElementPriority.MEDIUM);
band1.addCommandButton(button4, RibbonElementPriority.MEDIUM);
band1.setResizePolicies((List) Arrays.asList(new CoreRibbonResizePolicies.None(band1.getControlPanel()), new IconRibbonBandResizePolicy(band1.getControlPanel())));
band1.setResizePolicies((List) Arrays.asList( new CoreRibbonResizePolicies.None(band1.getControlPanel()), new CoreRibbonResizePolicies.Mirror(band1.getControlPanel()), new CoreRibbonResizePolicies.Mid2Low(band1.getControlPanel()), new CoreRibbonResizePolicies.High2Low(band1.getControlPanel()), new IconRibbonBandResizePolicy(band1.getControlPanel())));
}
});
}
public static ResizableIcon getResizableIconFromResource(String resource)
{
File right = new File(resource);
URL url;
try
{
url = right.toURI().toURL();
} catch (MalformedURLException e)
{
// cannot do anything, stop program/thread with RuntimeException
throw new RuntimeException(e);
}
// URL u = MainFrame.class.getClassLoader().getResource(“leftblack”);
return ImageWrapperResizableIcon.getIcon(/*u*/ url, new Dimension(18, 18));
}
}
Here is the current code. Please excuse about the format. -.-
Thank you very much for your work!!!
I think I understand the problem: you reference your SVG resource under as
src\\gui\\rightblack.svg. But you should use the classpath of the resource, not its source path. You should locate your compiled classes root (depending on your IDE and your configuration) and reference your image from the root.For example, in Maven, if my source is
src/main/resources/gui/rightblack.svg, I would referencegui/rightblack.svgsince Maven will putsrc/main/resourcesat the root of my classpath.Hi, i would like to know how implement the two last topics:
– Add standard Swing components to the ribbon
– Add a menu on the top left corner
I don’t find any information about it. Excellent tutorial!
The download links are missing.
Do you know where I can get Flamingo?
can anyone direct me to their documentation? or main website? thanks!
@eoko
Hello,
You can find the reason why nothing is available anymore on java.net as well as the new project’s place at the author’s blog
thanks! but ive been trying to figure out how to change the icon/image of the application menu. could you help me out? thanks again!
hi. i was able to find your post. silly me. quick question again..
in your example, BasicCheckRibbon.java, you were able to set the application icon using this code:
setApplicationIcon(new applications_internet());
and in your article, you said that:
JRibbonFrame.setApplicationIcon(ResizableIcon) API.
my question is:
In site, https://github.com/kirillcool, does the flamingo downloadable file is version 5?
coz the code im using is not working:
JRibbonFrame.setsetApplicationIcon(getResizableIconFromResource(“someicon.png”));
doesnt work. thanks again! thanks!!
i dont understand how to add ApplicationMenu primary,secondary, and footer..
can you give the tutorial…
thanks before
Hi; Thx for the tutorial.
How Can I change RibbonApplicationMenue Icon?
Hi….. flamingo jar not supporting org.jvnet.flamingo.ribbon.JRibbonBand class
java.lang.ClassCastException: org.officelaf.OfficeBandControlPanelUI cannot be cast to org.jvnet.flamingo.ribbon.ui.BandControlPanelUI
Check out link Having all jar file with tutorial
http://javaswingcomponents.blogspot.com/2011/12/jribbon.html
@Ash Khote
Thank. Rally nice stuff…
@Ash Khote
Nice Stuff………
running program with source code and all necessary jar files.
Thanks…….
Hi,
i know it is possible to use an own frame inheriting from JFrame and add a JRibbon component e.g. with BorderLayout.NORTH to this frame.
The ribbon is painted well and works except the application menu button. When the user presses it, there occurs the ClassCastException (see below).
Is there a workaround for this?
Regards René
Exception in thread “AWT-EventQueue-0″ java.lang.ClassCastException: de.lambdamoo.aha.client.main.MainFrame cannot be cast to org.pushingpixels.flamingo.api.ribbon.JRibbonFrame
at org.pushingpixels.flamingo.internal.ui.ribbon.appmenu.BasicRibbonApplicationMenuButtonUI$1.getPopupPanel(BasicRibbonApplicationMenuButtonUI.java:118)
at org.pushingpixels.flamingo.internal.ui.common.BasicCommandButtonUI.processPopupAction(BasicCommandButtonUI.java:1103)
at org.pushingpixels.flamingo.internal.ui.common.BasicCommandButtonUI$4.actionPerformed(BasicCommandButtonUI.java:1075)
at org.pushingpixels.flamingo.api.common.JCommandButton$DefaultPopupButtonModel.firePopupActionPerformed(JCommandButton.java:314)
at org.pushingpixels.flamingo.api.common.JCommandButton$DefaultPopupButtonModel.setPressed(JCommandButton.java:346)
at org.pushingpixels.flamingo.internal.ui.common.BasicCommandButtonListener.mousePressed(BasicCommandButtonListener.java:122)
Your
MainFrameclass should extendJRibbonFrame, notJFrame. That should solve your problem.@MuthuAnanth
Get all suppoerted Jar file here
http://javaswingcomponents.blogspot.com/2011/12/jribbon.html
Hello, I tried to add a change listener to my Ribbon but it doesn’t work. How can I detect the change of tab in my Ribbon ?
Thank you for your help.
After running the following code i can only see a blank frame… can some one help me out by finding the errors in this and please send me the code if anyone got the right output displayed
import java.awt.Dimension;
import java.util.Arrays;
import java.util.List;
import javax.swing.SwingUtilities;
import org.pushingpixels.flamingo.api.common.JCommandButton;
import org.pushingpixels.flamingo.api.common.icon.ImageWrapperResizableIcon;
import org.pushingpixels.flamingo.api.common.icon.ResizableIcon;
import org.pushingpixels.flamingo.api.ribbon.*;
import org.pushingpixels.flamingo.api.ribbon.resize.CoreRibbonResizePolicies;
import org.pushingpixels.flamingo.api.ribbon.resize.IconRibbonBandResizePolicy;
;
public class NewFrame extends JRibbonFrame {
/** Serial version unique id. */
private static final long serialVersionUID = 1L;
public static ResizableIcon getResizableIconFromResource(String resource) {
return ImageWrapperResizableIcon.getIcon(NewFrame.class
.getClassLoader().getResource(resource), new Dimension(48, 48));
}
/**
* Entry point method.
*
* @param args
* Application arguments
*/
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
private RibbonElementPriority TOP;
private RibbonElementPriority MEDIUM;
@Override
public void run() {
NewFrame frame = new NewFrame();
frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
JRibbonBand band1 = new JRibbonBand(“Hello”,getResizableIconFromResource(“48px-Crystal_Clear_app_Staroffice.png”));
JRibbonBand band2 = new JRibbonBand(“world!”, null);
JCommandButton button1 = new JCommandButton(“Square”,getResizableIconFromResource(“48px-Crystal_Clear_app_kthememgr.png”));
JCommandButton button2 = new JCommandButton(“Circle”,getResizableIconFromResource(“48px-Crystal_Clear_app_ksame.png”));
JCommandButton button3 = new JCommandButton(“Triangle”,getResizableIconFromResource(“48px-Crystal_Clear_app_error.png”));
JCommandButton button4 = new JCommandButton(“Star”,getResizableIconFromResource(“48px-Crystal_Clear_action_bookmark.png”));
band1.addCommandButton(button1, TOP);
band1.addCommandButton(button2, MEDIUM);
band1.addCommandButton(button3, MEDIUM);
band1.addCommandButton(button4, MEDIUM);
band1.setResizePolicies((List) Arrays.asList(
new CoreRibbonResizePolicies.None(band1.getControlPanel()),
new CoreRibbonResizePolicies.Mirror(band1.getControlPanel()),
new CoreRibbonResizePolicies.Mid2Low(band1.getControlPanel()),
new CoreRibbonResizePolicies.High2Low(band1.getControlPanel()),
new IconRibbonBandResizePolicy(band1.getControlPanel())));
band2.setResizePolicies((List) Arrays
.asList(new IconRibbonBandResizePolicy(band2
.getControlPanel())));
RibbonTask task1 = new RibbonTask(“One”, band1);
RibbonTask task2 = new RibbonTask(“Two”, band2);
frame.getRibbon().addTask(task1);
frame.getRibbon().addTask(task2);
frame.getRibbon().setApplicationMenu(new RibbonApplicationMenu());
}
});
}
}
After running the following code i can only see a blank frame… can some one help me out by finding the errors in this and please send me the code if anyone got the right output displayed
exception:
Exception in thread “AWT-EventQueue-0″ java.lang.IllegalStateException: Inconsistent preferred widths
Ribbon band ‘Hello has the following resize policies
org.pushingpixels.flamingo.api.ribbon.resize.CoreRibbonResizePolicies$None with preferred width 4
org.pushingpixels.flamingo.api.ribbon.resize.CoreRibbonResizePolicies$Mirror with preferred width 4
org.pushingpixels.flamingo.api.ribbon.resize.CoreRibbonResizePolicies$Mid2Low with preferred width 4
org.pushingpixels.flamingo.api.ribbon.resize.CoreRibbonResizePolicies$High2Low with preferred width 4
org.pushingpixels.flamingo.api.ribbon.resize.IconRibbonBandResizePolicy with preferred width 46
org.pushingpixels.flamingo.api.ribbon.resize.CoreRibbonResizePolicies$High2Low with pref width 4 is followed by resize policy org.pushingpixels.flamingo.api.ribbon.resize.IconRibbonBandResizePolicy with larger pref width
at org.pushingpixels.flamingo.internal.utils.FlamingoUtilities.checkResizePoliciesConsistency(FlamingoUtilities.java:579)
at org.pushingpixels.flamingo.api.ribbon.AbstractRibbonBand.setRibbonTask(AbstractRibbonBand.java:539)
at org.pushingpixels.flamingo.api.ribbon.RibbonTask.(RibbonTask.java:90)
at NewFrame$1.run(NewFrame.java:80)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:641)
at java.awt.EventQueue.access$000(EventQueue.java:84)
at java.awt.EventQueue$1.run(EventQueue.java:602)
at java.awt.EventQueue$1.run(EventQueue.java:600)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:611)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
CODE:
import java.awt.Dimension;
import java.util.Arrays;
import java.util.List;
import javax.swing.SwingUtilities;
import org.pushingpixels.flamingo.api.common.JCommandButton;
import org.pushingpixels.flamingo.api.common.icon.ImageWrapperResizableIcon;
import org.pushingpixels.flamingo.api.common.icon.ResizableIcon;
import org.pushingpixels.flamingo.api.ribbon.*;
import org.pushingpixels.flamingo.api.ribbon.resize.CoreRibbonResizePolicies;
import org.pushingpixels.flamingo.api.ribbon.resize.IconRibbonBandResizePolicy;
;
public class NewFrame extends JRibbonFrame {
/** Serial version unique id. */
private static final long serialVersionUID = 1L;
public static ResizableIcon getResizableIconFromResource(String resource) {
return ImageWrapperResizableIcon.getIcon(NewFrame.class
.getClassLoader().getResource(resource), new Dimension(48, 48));
}
/**
* Entry point method.
*
* @param args
* Application arguments
*/
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
private RibbonElementPriority TOP;
private RibbonElementPriority MEDIUM;
@Override
public void run() {
NewFrame frame = new NewFrame();
frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
JRibbonBand band1 = new JRibbonBand(“Hello”,getResizableIconFromResource(“48px-Crystal_Clear_app_Staroffice.png”));
JRibbonBand band2 = new JRibbonBand(“world!”, null);
JCommandButton button1 = new JCommandButton(“Square”,getResizableIconFromResource(“48px-Crystal_Clear_app_kthememgr.png”));
JCommandButton button2 = new JCommandButton(“Circle”,getResizableIconFromResource(“48px-Crystal_Clear_app_ksame.png”));
JCommandButton button3 = new JCommandButton(“Triangle”,getResizableIconFromResource(“48px-Crystal_Clear_app_error.png”));
JCommandButton button4 = new JCommandButton(“Star”,getResizableIconFromResource(“48px-Crystal_Clear_action_bookmark.png”));
band1.addCommandButton(button1, TOP);
band1.addCommandButton(button2, MEDIUM);
band1.addCommandButton(button3, MEDIUM);
band1.addCommandButton(button4, MEDIUM);
band1.setResizePolicies((List) Arrays.asList(
new CoreRibbonResizePolicies.None(band1.getControlPanel()),
new CoreRibbonResizePolicies.Mirror(band1.getControlPanel()),
new CoreRibbonResizePolicies.Mid2Low(band1.getControlPanel()),
new CoreRibbonResizePolicies.High2Low(band1.getControlPanel()),
new IconRibbonBandResizePolicy(band1.getControlPanel())));
band2.setResizePolicies((List) Arrays
.asList(new IconRibbonBandResizePolicy(band2
.getControlPanel())));
RibbonTask task1 = new RibbonTask(“One”, band1);
RibbonTask task2 = new RibbonTask(“Two”, band2);
frame.getRibbon().addTask(task1);
frame.getRibbon().addTask(task2);
frame.getRibbon().setApplicationMenu(new RibbonApplicationMenu());
}
});
}
}
i really love this tutorial , btw i’ve question how to make the JCommandButton to have sub-menu , for example like “paste” button in microsoft word, if we click on that button it’ll open another sub menu.. thanks buddy
Hi,
I really liked this tutorial.But I have few queries regarding ribbon components
1.How can I set the font color for the ribbon buttons?
2.How to change the height and width of the divider bar(divider used to separate the groups in ribbon band)?
3.How to set the icon size and padding criteria?
4.How to create border for entire ribbon bar and how to change he dimensions of it?
Please reply me asap.
Waiting for ur reply
Hi all,
please check the test package in the flamingo sources for BasicCheckRibbon an most of your questions will be answered
Hi,
Please tell me where can i get the flamingo sources ,while i can not get from the told website.
i really appreciate if some body can send me .thanks
my e-mail is 609944616@qq.com ,thank you !@kuer
Hi,
I used the API, every thing looks OK in my code, but sometimes the menu bar stop working, i mean their menu and sub menus disapare or disable, I NEED HELP PLZZZZ????
I am currently using this API in my project and its just awesome,but I don’t know how to give shortcuts to JcommandButton….Please help me out….. and Thnx in advance
@Khaled El-Khaldi
getRibbon().setApplicationIcon
@kuer
If you still need it here are the last source of it :
http://repo1.maven.org/maven2/com/github/insubstantial/