当你把工具提示放到Jcommandbutton上,使用settooltiptext函数,出现UnsupportedOperation异常
enter code here
乐队宣布
JRibbonBand band = new JRibbonBand("File", null);
J命令按钮
JCommandButton btn_open = new JCommandButton("Open",
getResizableIcon("Open.png"));
btn_open.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if (text_change) {
open();
} else {
int i = save_check();
if (i == 0) {
save();
} else if (i == 1) {
open();
}
}
}
});
Action Ac_Open = new AbstractAction() {//hot key
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if (text_change) {
open();
} else {
int i = save_check();
if (i == 0) {
save();
} else if (i == 1) {
open();
}
}
}
};
Ac_Open.putValue(Action.ACCELERATOR_KEY,
KeyStroke.getKeyStroke("control O"));
btn_open.getActionMap().put("Open", Ac_Open);
btn_open.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
(KeyStroke) Ac_Open.getValue(Action.ACCELERATOR_KEY), "Open");
JToolTip tip = new JToolTip();
tip.setTipText("O");
btn_open.add(tip);
btn_open.setToolTipText("O");
带 && 任务的属性
band.addCommandButton(btn_open, RibbonElementPriority.MEDIUM);
band.setResizePolicies((List) Arrays.asList(
new CoreRibbonResizePolicies.None(band.getControlPanel()),
new IconRibbonBandResizePolicy(band.getControlPanel())));
RibbonTask task1 = new RibbonTask("Menu", band);
this.getRibbon().addTask(task1);
我认为列表中更改排列的部分似乎存在问题。