我正在使用火烈鸟色带,但是当我尝试放入菜单时,它没有出现。
我使用了这段代码:
RibbonApplicationMenuEntryPrimary menu1 = new RibbonApplicationMenuEntryPrimary(getResizableIconFromResource("/prog/Imagenes/Algo.png"), "Prueba 1", new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("Menu secundario");
}
}, JCommandButton.CommandButtonKind.POPUP_ONLY);
menu1.setActionKeyTip("P");
menu1.setPopupKeyTip("W");
RibbonApplicationMenuEntrySecondary menu2 = new RibbonApplicationMenuEntrySecondary(getResizableIconFromResource("/prog/imagenes/rs1.png"), "Prueba 2",null, JCommandButton.CommandButtonKind.POPUP_ONLY);
menu2.setDescriptionText("seleccione algo");
menu2.setActionKeyTip("P");
RibbonApplicationMenuEntrySecondary menu3 = new RibbonApplicationMenuEntrySecondary(getResizableIconFromResource("/prog/imagenes/dp1.png"), "Prueba 3",null, JCommandButton.CommandButtonKind.ACTION_ONLY);
menu3.setDescriptionText("algo");
menu3.setActionKeyTip("Q");
RibbonApplicationMenu menuPrinicpal = new RibbonApplicationMenu();
RibbonApplicationMenuEntryPrimary salir = new RibbonApplicationMenuEntryPrimary(null, "Salir", new ActionListener() {
public void actionPerformed(ActionEvent e) {
dispose();
}
}, CommandButtonKind.ACTION_AND_POPUP_MAIN_ACTION);
salir.setActionKeyTip("S");
salir.setPopupKeyTip("X");
menuPrinicpal.addMenuEntry(salir);
cintaOmicronJRibbon.updateUI();
menu1.addSecondaryMenuGroup("Compuesto", menu2,menu3);
menuPrinicpal.addMenuEntry(menu1);
menuPrinicpal.addMenuSeparator();
cintaOmicronJRibbon.setApplicationMenu(menuPrinicpal);
cintaOmicronJRibbon.updateUI();
请帮助我谢谢。
答案 0 :(得分:3)
最后我找到了解决方案,代码显示错误,我在我的JRibbonFrame中添加了一个Jribbon属性,但默认情况下,当一个类继承自JRibbonFrame时,它会包含JRibbon元素。
代码需要this.getRibbon()而不是cintaOmicronJRibbon。