Custom Icon on right side for CollapsiblePane

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.

Custom Icon on right side for CollapsiblePane

Postby gedeffe » Thu Jul 17, 2014 8:01 am

Hello,

I have tried to use a custom Icon for a CollapsiblePane header. It is only available for styles PLAIN and TREE, but the icon is located on the left.
And the tricky part is that I would like to have it on right side. What I get is an icon after the text, however when I have several collapsible panes, I am not able to have a correct alignement of these icons.

Any idea to solve this ?
(a custom icon on right side like DropDown style)

Here is the code I have used so far to populate a CollapsiblePanes parent :

Code: Select all
// eventually, pad provided title with spaces to force icon location on the right ... doesn't work very well
            final String title = String.format("%1$-25s", this.parentTitle);
            this.collapsiblePanel = new CollapsiblePane(title);
            this.collapsiblePanel.collapse(true);
            this.collapsiblePanel.setEmphasized(true);
            this.collapsiblePanel.setBackground(new Color(54, 71, 96));
            // try to change the icon
            this.collapsiblePanel.setIcon(new ImageIcon(this.getClass().getResource(
                    "/icons/arrow-bleu-xl.png")));
            this.collapsiblePanel.setHorizontalTextPosition(SwingConstants.LEFT);
            // hide Jide icon, because we can't customize it.
            this.collapsiblePanel.setShowExpandButton(false);
            // add a listener to update the icon
            this.collapsiblePanel.addCollapsiblePaneListener(new CollapsiblePaneAdapter() {

                @Override
                public void paneExpanded(final CollapsiblePaneEvent arg0) {
                    ParentMenuItemPanel.this.collapsiblePanel.setIcon(new ImageIcon(this.getClass()
                            .getResource("/icons/arrow-noir-xl.png")));
                    ParentMenuItemPanel.this.collapsiblePanel.setBackground(new Color(67, 183, 255));
                }

                @Override
                public void paneCollapsed(final CollapsiblePaneEvent arg0) {
                    ParentMenuItemPanel.this.collapsiblePanel.setIcon(new ImageIcon(this.getClass()
                            .getResource("/icons/arrow-bleu-xl.png")));
                    ParentMenuItemPanel.this.collapsiblePanel.setBackground(new Color(54, 71, 96));
                }
            });
gedeffe
 
Posts: 3
Joined: Thu Aug 22, 2013 4:18 am

Re: Custom Icon on right side for CollapsiblePane

Postby JIDE Support » Thu Jul 17, 2014 9:19 am

Have you tried setExpandedIcon and setCollapsedIcon under DROPDOWN style?
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Re: Custom Icon on right side for CollapsiblePane

Postby gedeffe » Fri Jul 18, 2014 1:04 am

Hello,

I have tried this:
Code: Select all
            this.collapsiblePanel.setStyle(CollapsiblePane.DROPDOWN_STYLE);
            this.collapsiblePanel.setExpandedIcon(new ImageIcon(this.getClass().getResource(
                    "/icons/arrow-black_17x17.png")));
            this.collapsiblePanel.setCollapsedIcon(new ImageIcon(this.getClass().getResource(
                    "/icons/arrow-white_17x17.png")));


But the icon displayed does not change (its always the default icon).
gedeffe
 
Posts: 3
Joined: Thu Aug 22, 2013 4:18 am

Re: Custom Icon on right side for CollapsiblePane

Postby JIDE Support » Fri Jul 18, 2014 10:37 am

My mistake. This icon is not used for dropdown style. The only way I find is to change UIDefault "CollapsiblePane.upIcon" and "CollapsiblePane.downIcon".

Code: Select all
                LookAndFeelFactory.addUIDefaultsCustomizer(new LookAndFeelFactory.UIDefaultsCustomizer() {
                    @Override
                    public void customize(UIDefaults defaults) {
                        defaults.put("CollapsiblePane.upIcon", your icon here);
                        defaults.put("CollapsiblePane.downIcon", your icon here);
                    }
                });
                LookAndFeelFactory.installDefaultLookAndFeelAndExtension();
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Re: Custom Icon on right side for CollapsiblePane

Postby gedeffe » Tue Aug 26, 2014 12:09 am

Thank you.
It works as expected.
:D
gedeffe
 
Posts: 3
Joined: Thu Aug 22, 2013 4:18 am


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

Who is online

Users browsing this forum: No registered users and 7 guests