BalloonTip display problem

This forum is used by users to request and discuss new product features. Please do not use this forum for technical support including bug reports.

Moderator: JIDE Support

Forum rules
Product suggestions only. Please do not use this forum for technical support including bug reports.

BalloonTip display problem

Postby karstrom » Tue Nov 25, 2008 4:46 am

First time i display a balloon tip it is not shown in the correct location:
balloon.png
first display
balloon.png (129.12 KiB) Viewed 31881 times


display code:
Code: Select all
                        System.out.println("Component: "+eventText.getText()+" x=" + e.getX() + ", y=" + e.getY());
                        balloon.show(eventText, e.getX(), e.getY());

output from console: Component: Betalt 25/11/08 x=43, y=0
witch shows it is supposed to be rendered
correct.png
correct display
correct.png (17.56 KiB) Viewed 31880 times


all subsequent shows will render it correctly.

balloon creating code:
Code: Select all
            final BalloonTip balloon = new BalloonTip();
            //set up balloon
            {
                final ShadowSettings settings = balloon.getShadowSettings();
                final RoundedRectangularBalloonShape shape = new RoundedRectangularBalloonShape();
                final LeftBottomDrop shadowStyle = new LeftBottomDrop();
                final ZPanel balloonContent = new ZPanel();
                //shadowStyle.setScale(0.8d);
                shadowStyle.setXOffset(19);
                shadowStyle.setYOffset(19);
                shape.setPosition(SwingConstants.RIGHT);
                balloon.setShadowStyle(shadowStyle);
                settings.setColor(Color.BLACK);
                settings.setOpacity(0.25f);
                balloon.setBalloonShape(shape);

                balloonText.setWrapStyleWord(true);
                balloonText.setLineWrap(true);
                balloonText.setEditable(false);
                balloonText.setFocusable(false);
                balloonText.setOpaque(false);
                balloonContent.add(balloonText);
                balloon.setContent(balloonContent);
            }



The component it is supposed to be rendered on is a JLabel placed in a JPanel with a GirdLayout that again is wrapped north in a BorderLayout and then put inside a JSplitPane


any suggestions to what could cause this? Could this be fixed?
karstrom
 
Posts: 207
Joined: Wed Sep 07, 2005 4:56 am

Re: BalloonTip display problem

Postby JIDE Support » Sat Nov 29, 2008 9:31 am

Sorry for the late reply as it is thanksgiving holiday in US.

Could you please send us a complete test case so that we can look further? Your posted code uses ZPanel which we are not sure where to get it. The other thing is JTextArea could be problematic (as always). You may set the number of columns first before displaying it so that it gets a definite size.

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Re: BalloonTip display problem

Postby karstrom » Tue Jan 20, 2009 4:09 am

Sorry for the very late reply =)


ZPanel is a simple JPanel wrapper class that sets the panel to opaque


I'll test if textarea is the problem as soon as i find the time, the project has been mothballed for a few months so i had completly forgotten about it.

/**
* Standard JPanel set to opaque and borderLayout unless another layout is selected
* @author petter
*/
public class ZPanel extends javax.swing.JPanel {

public ZPanel() {
this(new java.awt.BorderLayout(0,0));
}
public ZPanel(java.awt.LayoutManager layout) {
this(layout,true);
}
public ZPanel(java.awt.LayoutManager layout, boolean isDoubleBuffered) {
super(layout,isDoubleBuffered);
this.setOpaque(false);
}

}
karstrom
 
Posts: 207
Joined: Wed Sep 07, 2005 4:56 am

Re: BalloonTip display problem

Postby JIDE Support » Tue Jan 20, 2009 12:20 pm

Could you send me a complete test case? Your code still won't compile. We really want a complete test case before looking further on this bug report.

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Re: BalloonTip display problem

Postby natit » Fri Jan 08, 2010 5:26 am

Code: Select all
package com.tubasoft.gui.components.alert;

import com.jidesoft.swing.MultilineLabel;
import com.jidesoft.tooltip.BalloonTip;
import com.jidesoft.tooltip.ShadowSettings;
import com.jidesoft.tooltip.shadows.LeftBottomBackward;
import com.jidesoft.tooltip.shapes.RectangularShape;
import java.awt.Color;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.util.HashMap;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;
import javax.swing.AbstractAction;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JPanel;

/**
 *
 * @author Petter Holone <petter@tubasoft.org>
 */
public class SimpleAlert {

    private static final ShadowSettings shadowSettings = new ShadowSettings();
    private static final RectangularShape balloonShape = new RectangularShape();
    private static final LeftBottomBackward shadowStyle = new LeftBottomBackward();
    private static final Timer killScheduler = new Timer();
    private static Map<String, AlertKiller> killerMap = new HashMap();
    private static Map<String, BalloonTip> balloonMap = new HashMap();
    private static int defaultTimeout = 3000;
    private static int defaultX = 0;
    private static int defaultY = 0;

    static {
        shadowSettings.setColor(new Color(128, 128, 0));
        shadowSettings.setOpacity(0.25f);
        shadowStyle.setXRatio(0.77);
        shadowStyle.setYRatio(0.4);
        balloonShape.setCornerSize(5);

    }

    public static void showAlert(String message, JComponent owner) {
        showAlert(message, owner, defaultTimeout);
    }

    public static void showAlert(String message, JComponent owner, int timeoutInMs) {
        showAlert(message, owner, timeoutInMs, defaultX, defaultY);
    }

    private static BalloonTip createAlert(String message) {
        final BalloonTip simpleAlert = new BalloonTip();
        simpleAlert.setShadowSettings(shadowSettings);
        simpleAlert.setBalloonShape(balloonShape);
        simpleAlert.setShadowStyle(shadowStyle);
        final MultilineLabel label = new MultilineLabel(message);
        label.setLineWrap(true);
        label.setWrapStyleWord(true);
        label.setOpaque(false);
        simpleAlert.setContent(label);
        simpleAlert.packPopup();
        return simpleAlert;
    }

    public static synchronized void showAlert(String message, JComponent owner, int timeoutInMs, int x, int y) {
        if (balloonMap.containsKey(message)) {
            if (killerMap.containsKey(message)) {
                killerMap.get(message).shouldKill = false;
            }
            final BalloonTip simpleAlert = balloonMap.get(message);
            simpleAlert.show(owner, x, y);
            scheduleKill(timeoutInMs, simpleAlert, message);

        } else {
            BalloonTip simpleAlert = createAlert(message);

            simpleAlert.show(owner, x, y);
            scheduleKill(timeoutInMs, simpleAlert, message);
            balloonMap.put(message, simpleAlert);
        }
    }

    private static void scheduleKill(int timeoutInMs, BalloonTip simpleAlert, String alertId) {
        if (timeoutInMs > 0) {
            AlertKiller killer = new AlertKiller(simpleAlert, alertId);
            killScheduler.schedule(killer, timeoutInMs);
            killerMap.put(alertId, killer);
        }
    }

    static class AlertKiller extends TimerTask {

        private final BalloonTip tip;
        boolean shouldKill = true;
        private final String key;

        public AlertKiller(BalloonTip tip, String key) {
            this.tip = tip;
            this.key = key;
        }

        @Override
        public void run() {
            if (shouldKill) {
                tip.hide();
                balloonMap.remove(key);
                killerMap.remove(key);
            }
        }
    }

    public static void main(String[] args) {
        final JPanel panel = new JPanel(new GridLayout(5, 5, 5, 5));
        for (int i = 0; i < 25; i++) {
            final String id = java.util.UUID.randomUUID().toString();
            panel.add(new JButton(new AbstractAction(id) {

                public void actionPerformed(ActionEvent e) {
                    showAlert(id, (JComponent) e.getSource());
                }
            }));
        }

        panel.setPreferredSize(new java.awt.Dimension(1024, 768));
        final javax.swing.JDialog dialog = new javax.swing.JDialog();
        dialog.getContentPane().add(panel);
        dialog.setDefaultCloseOperation(javax.swing.JDialog.DISPOSE_ON_CLOSE);
        dialog.pack();
        dialog.setVisible(true);
    }
}


this produces the same bug.
natit
 
Posts: 4
Joined: Thu Nov 13, 2008 4:04 am

Re: BalloonTip display problem

Postby natit » Fri Jan 08, 2010 5:31 am

The first time you push a button it will render the tip about 20-30 pixels down on the button, if you push again (before the 3 second timeout), it will move it to the top of the button.

i would expect it always to render it to the top of the button.
natit
 
Posts: 4
Joined: Thu Nov 13, 2008 4:04 am

Re: BalloonTip display problem

Postby JIDE Support » Fri Jan 08, 2010 11:23 am

Try not to call packPopup.

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Re: BalloonTip display problem

Postby natit » Mon Jan 11, 2010 1:15 am

The problem persists without a call to packPopup aswell
natit
 
Posts: 4
Joined: Thu Nov 13, 2008 4:04 am

Re: BalloonTip display problem

Postby JIDE Support » Mon Jan 11, 2010 12:46 pm

Thanks for bug report. We will fix it in 2.8.3. For now, please try to invoke simpleAlert.show() twice to work around.

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Re: BalloonTip display problem

Postby JIDE Support » Fri Jan 29, 2010 12:27 pm

Just so you know, this is fixed in 2.8.3.

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am


Return to Product Suggestions

Who is online

Users browsing this forum: No registered users and 9 guests

cron