this.buttons = new JCommandToggleButton[4][10];
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 10; j++) {
this.buttons[i][j] = new JCommandToggleButton("Button " + i
+ ":" + j, new DecoratedResizableIcon(
new DisabledResizableIcon(RibbonElementPriority.TOP,
32, 32), new TopLeftDecoration(i),
new BottomRightDecoration(j)));
}
}
this.ribbonBand = new JRibbonBand("Band", new EmptyResizableIcon(32));
Map<RibbonElementPriority, Integer> visibleButtonCounts = new HashMap<RibbonElementPriority, Integer>();
visibleButtonCounts.put(RibbonElementPriority.LOW, 4);
visibleButtonCounts.put(RibbonElementPriority.MEDIUM, 5);
visibleButtonCounts.put(RibbonElementPriority.TOP, 6);
List<StringValuePair<List<JCommandToggleButton>>> galleryButtons = new ArrayList<StringValuePair<List<JCommandToggleButton>>>();
for (int i = 0; i < 4; i++) {
List<JCommandToggleButton> galleryButtonsList = new ArrayList<JCommandToggleButton>();
for (int j = 0; j < 10; j++) {
galleryButtonsList.add(this.buttons[i][j]);
}
galleryButtons.add(new StringValuePair<List<JCommandToggleButton>>(
"Group " + i, galleryButtonsList));
}
this.ribbonBand.addRibbonGallery(GALLERY_NAME, galleryButtons,
visibleButtonCounts, 6, 4, RibbonElementPriority.TOP);
this.gallery = this.ribbonBand.getControlPanel().getRibbonGallery(
GALLERY_NAME);
this.getRibbon().addTask(new RibbonTask("Task 1", this.ribbonBand));
JPanel controlPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
JButton addToGroup0 = new JButton("Add one to 0");
addToGroup0.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JCommandToggleButton toAdd = new JCommandToggleButton(
"Button 0 new", new DecoratedResizableIcon(
new DisabledResizableIcon(
RibbonElementPriority.TOP, 32, 32),
new TopLeftDecoration(0),
new BottomRightDecoration(99)));
ribbonBand.addRibbonGalleryButtons(GALLERY_NAME, "Group 0",
toAdd);
}
});
controlPanel.add(addToGroup0);
JButton addToGroup2 = new JButton("Add two to 2");
addToGroup2.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JCommandToggleButton toAdd = new JCommandToggleButton(
"Button 2 new", new DecoratedResizableIcon(
new DisabledResizableIcon(
RibbonElementPriority.TOP, 32, 32),
new TopLeftDecoration(2),
new BottomRightDecoration(99)));
JCommandToggleButton toAdd2 = new JCommandToggleButton(
"Button 2 new 2", new DecoratedResizableIcon(
new DisabledResizableIcon(
RibbonElementPriority.TOP, 32, 32),
new TopLeftDecoration(2),
new BottomRightDecoration(66)));
ribbonBand.addRibbonGalleryButtons(GALLERY_NAME, "Group 2",