Customizing BalloonTip

This is the forum for JIDE Common Layer which is open sourced at https://github.com/jidesoft/jide-oss. Please note, JIDE technical support doesn't monitor this forum as often as other forums. Please consider subscribe for technical support for JIDE Common Layer so that you can use customer only forum to get a timely response.

Moderator: JIDE Support

Forum rules
Community driven forum for open source JIDE Common Layer. JIDE technical support doesn't monitor this forum as often as other forums. If you only use JIDE Common Layer, please consider subscribing for technical support for JIDE Common Layer so that you can use customer only forum to get a timely response.

Customizing BalloonTip

Postby td84 » Tue Jun 21, 2016 1:28 am

Hello,

i would like to use BalloonTip in a project. It works good. I would like to modify 2 things:
1) the arrow should have another location, like on the image
2) if someone clicks somewhere in the application, the baloon closes. I would like to prohibit this.

For the 1) i created a class that implements BalloonShape, and returned from the function getHotSpot() some other values, but the arrow didn't change.

Can you help me?

Thanx in advance,
Daniel
Attachments
balloon.png
balloon.png (953 Bytes) Viewed 33990 times
td84
 
Posts: 32
Joined: Tue Dec 08, 2015 4:02 pm

Re: Customizing BalloonTip

Postby JIDE Support » Tue Jun 21, 2016 4:48 am

1) A quick way to figure out what BalloonTip can do is to run BalloonTipDemo and select different options and click on the show button to see what balloon tip looks like. Then you can see the source code to find out what API to use to get what you want. It looks like to me all you need to do is to set the balloon position to bottom (the setPosition method on RoundedRectangularBalloonShape).
2) You can do this. You can add a component to the popup so that when user clicks on that components, the popup will not be hidden. Since you want it to apply to all components, I had to override isExcludedComponent method to always return true.

Code: Select all
       _balloonTip = new BalloonTip(createToolTipContent()) {
            @Override
            protected JidePopup createPopup() {
                return new JidePopup() {
                    @Override
                    public boolean isClickOnPopup(MouseEvent e) {
                        Point p = e.getPoint();
                        Point point = SwingUtilities.convertPoint((Component) e.getSource(), p, getContent().getParent());
                        return getContent().getParent().contains(point);
                    }

                    @Override
                    public boolean isExcludedComponent(Component component) {
                        return true;
                    }
                };
            }
        };
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Re: Customizing BalloonTip

Postby td84 » Tue Jun 21, 2016 6:37 am

Thank you for the answeer.
1) It worked. Nice :-) I had to disassemble the java code to find out the value of BOTTOM. It seems, there is no public field in the class RoundedRectangularBalloonShape.

2) This didn't work for me. If i click outside of the balloon, it still get's closed.
I tryed also to overwrite hide() and setVisible() in the codeblock "return new JidePopup() {}" but this also not worked.
Is there a function in JidePopup(), that get's called, if it's closing?
Maybe each time reopen the balloon, if this fucntion get's called?
td84
 
Posts: 32
Joined: Tue Dec 08, 2015 4:02 pm

Re: Customizing BalloonTip

Postby JIDE Support » Tue Jun 21, 2016 2:53 pm

2) I used the same code in BalloonTipDemo and it works for me.
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Re: Customizing BalloonTip

Postby td84 » Wed Jun 22, 2016 4:56 am

JIDE Support wrote:2) I used the same code in BalloonTipDemo and it works for me.


I used an older release, and therefore it didn't work.
Thanx again, it works :-)
It closes only if i move the window by dragging with the mouse or i set it to full-window mode.
But this is absolutely no problem for me :-)
td84
 
Posts: 32
Joined: Tue Dec 08, 2015 4:02 pm

Re: Customizing BalloonTip

Postby td84 » Tue Jun 28, 2016 8:46 am

Dear Developers,

thanx again for your support.
The Balloon works fine. Sometimes it overlaps other GUI elements.
Is there a way to reduce the padding between the edges of the Balloon and the text (as marked with arrows on the attachment)?

Thank you again,
Daniel
Attachments
ballonshape.png
ballonshape.png (5.02 KiB) Viewed 33969 times
td84
 
Posts: 32
Joined: Tue Dec 08, 2015 4:02 pm

Re: Customizing BalloonTip

Postby td84 » Wed Jun 29, 2016 2:26 am

td84 wrote:Is there a way to reduce the padding between the edges of the Balloon and the text (as marked with arrows on the attachment)?


I figured out, how to do it :-)
The function "public Insets getInsets(Dimension contentSize)@BalloonShape" had to be overridden:
Code: Select all
msg = new BalloonTip( lbl ) {      
    @Override public BalloonShape getBalloonShape() {
      RoundedRectangularBalloonShape bshape = new RoundedRectangularBalloonShape() {
         @Override public Insets getInsets(Dimension contentSize) {
            return new Insets(a,b,c,d); //a,b,c,d  must be replaced
         }
      };
      return bshape;
     }
};
td84
 
Posts: 32
Joined: Tue Dec 08, 2015 4:02 pm

Re: Customizing BalloonTip

Postby JIDE Support » Wed Jun 29, 2016 5:28 am

Sorry I missed your original post. I am glad you figured out yourself.
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am


Return to JIDE Common Layer Open Source Project Discussion (Community Driven)

Who is online

Users browsing this forum: No registered users and 13 guests

cron