Flamingo, How to put Jtooltips on JCommandbuttons

96 Views Asked by At

When you put the tool tip to the Jcommandbutton, using the settooltiptext function, UnsupportedOperation exception occurs

enter code here

band declare

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

Properties of the band && task

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

I think there seems to be a problem in the part of the list to change the arrangement.

0

There are 0 best solutions below