Flamingo,如何将Jtooltips放在JCommandbuttons上

时间:2015-05-21 21:21:35

标签: java swing radiance-flamingo

当您将工具提示放入Jcommandbutton时,使用settooltiptext函数,会发生UnsupportedOperation异常

enter code here

乐队声明

    JRibbonBand band = new JRibbonBand("File", null);

Jcommandbutton

    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);

我认为列表中的部分似乎存在改变安排的问题。

0 个答案:

没有答案