christmo / macwidgets

Automatically exported from code.google.com/p/macwidgets
0 stars 0 forks source link

support UI delegate style iappscrollbars #37

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Great little lib.

One thing that would make it way more usable for me would be support for Swing 
UI delegate. I.e., 
I want to be able to use something like this

UIManager.put("ScrollBarUI", IAppScrollBarUI.class.getName());

instead of makeIAppScrollPane(...);

That way all the scrollbars in my app were instantly iApp ones... Plus, I could 
dynamically reset the 
value and change the look... Currently, makeIAppScrollPane(..) doesn't really 
supply an "undo".

Thanks!

Original issue reported on code.google.com by supp...@beatunes.com on 15 Dec 2008 at 12:29

GoogleCodeExporter commented 8 years ago
You can in fact access the iApp style scoll bar delegates via the following 
methods:

IAppWidgetFactory.createVerticalScrollBarButtonsTogetherUI()
IAppWidgetFactory.createHorizontalScrollBarButtonsTogetherUI()

Does this meet your needs?

Original comment by kenneth....@gmail.com on 22 Dec 2008 at 12:25

GoogleCodeExporter commented 8 years ago
I haven't heard back on this one, and I think I'm meeting this use-case, so I'm 
closing this issue.

Original comment by kenneth....@gmail.com on 30 Dec 2008 at 6:27

GoogleCodeExporter commented 8 years ago
Sorry for not getting back earlier.

What's needed is a class that inherits from BasicScrollBarUI and does all the 
iapp scrollbar stuff magically. That 
way one only registers it with UIManager and is done. Right now I have to find 
every place in my code where I 
might use a scrollbar and call those methods.

Original comment by hendrik....@gmail.com on 30 Dec 2008 at 6:41

GoogleCodeExporter commented 8 years ago
IAppWidgetFactory.createVerticalScrollBarButtonsTogetherUI() and 
IAppWidgetFactory.createHorizontalScrollBarButtonsTogetherUI() do return 
ScrollBarUIs. How were you going 
to register the UI delegates with the UIDefaults? I'm not aware of a clean way 
in Swing to specify an alternate 
UI delegate for a particular type of JComponent that already has a UI provided 
by the L&F. You could of course 
delve into the Multi-L&F, though I don't know if even that would work.

Note that I don't plan on providing a full L&F.

Have I missed something? 

Original comment by kenneth....@gmail.com on 30 Dec 2008 at 7:01

GoogleCodeExporter commented 8 years ago
Not that it looks particularly pretty, but the following code should illustrate 
what I have in mind. It basically substitutes the 
system specific ScrollBars with the metal ones.

import javax.swing.*;
import javax.swing.plaf.metal.MetalScrollBarUI;
//import javax.swing.plaf.metal.MetalScrollPaneUI;
import java.awt.*;

public class ScrollBarUIDemo extends JFrame {

    public ScrollBarUIDemo() throws HeadlessException {
        getContentPane().setLayout(new BorderLayout());
        getContentPane().add(new JScrollPane(new JTable(),
                JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
                JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS),
                BorderLayout.CENTER);
        getContentPane().add(new JScrollBar(JScrollBar.HORIZONTAL), BorderLayout.SOUTH);
        setBounds(100, 100, 200, 200);
        setVisible(true);
    }

    public static void main(String[] args) throws IllegalAccessException, UnsupportedLookAndFeelException, 
InstantiationException, ClassNotFoundException {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        UIManager.put("ScrollBarUI", MetalScrollBarUI.class.getName());
        //UIManager.put("ScrollPaneUI", MetalScrollPaneUI.class.getName());
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                new ScrollBarUIDemo();
            }
        });
    }
}

Original comment by hendrik....@gmail.com on 31 Dec 2008 at 9:44

GoogleCodeExporter commented 8 years ago
OK...I got it!

I will pull out the iApp ScrollBarUIs out into there own delegates. This will 
actually be more in line with the new 
HUD UI delegates coming in 0.9.4.

Original comment by kenneth....@gmail.com on 31 Dec 2008 at 12:18

GoogleCodeExporter commented 8 years ago
Great! Thanks.

Original comment by hendrik....@gmail.com on 31 Dec 2008 at 12:21

GoogleCodeExporter commented 8 years ago
I've added the following new classes:

 com.explodingpixels.macwidgets.plaf.IAppHorizontalScrollBarUI
 com.explodingpixels.macwidgets.plaf.IAppVerticalScrollBarUI

Hendrik,

Do you have access to the Subversion repository? If so, update the project and 
give the UI delegates a try. 
Otherwise, I can email you a jar file.

I'll leave this issue open until you confirm that the changes do in fact meet 
your needs.

-Ken

Original comment by kenneth....@gmail.com on 2 Jan 2009 at 5:19

GoogleCodeExporter commented 8 years ago
Thanks, Ken, for working on this.

Why two classes? Why not use something like in 
BasicScrollBarUI.installComponents(), where you simply ask the 
JScrollBar, which orientation it has?

Original comment by supp...@beatunes.com on 2 Jan 2009 at 7:40

GoogleCodeExporter commented 8 years ago
I loathe the switching BasicScrollBarUI does based on the orientation, but to 
fully meet your needs, I guess I'll 
have to collapse this down to one class.

I'll do that and have you give it a try.

Original comment by kenneth....@gmail.com on 2 Jan 2009 at 7:48

GoogleCodeExporter commented 8 years ago
I've combined

 com.explodingpixels.macwidgets.plaf.IAppHorizontalScrollBarUI
 com.explodingpixels.macwidgets.plaf.IAppVerticalScrollBarUI

into

com.explodingpixels.macwidgets.plaf.IAppScrollBarUI

which required some refactoring to the SkinnableScrollBarUI class.

Hendrik,

Can you try this out and let me know if it works as desired?

Thanks,
-Ken

Original comment by kenneth....@gmail.com on 2 Jan 2009 at 9:25

GoogleCodeExporter commented 8 years ago
I'll try this tomorrow. Thanks.

Original comment by supp...@beatunes.com on 5 Jan 2009 at 9:09

GoogleCodeExporter commented 8 years ago
Hm - doesn't seem to work quite right.
Did this work with the code I posted above on your machine?

Original comment by supp...@beatunes.com on 7 Jan 2009 at 10:20

Attachments:

GoogleCodeExporter commented 8 years ago
Hi Hendrick,

I didn't try the code you supplied, rather I verified I could install the UI 
delegate as a typical Swing scroll bar UI 
delegate (no supplied information at construction time).

Does your supplied code work with other ScrollBarUI delegates?

-Ken

Original comment by kenneth....@gmail.com on 7 Jan 2009 at 12:41

GoogleCodeExporter commented 8 years ago
Ken,

did some digging. Just add:

    public static ComponentUI createUI(JComponent c)    {
        return new IAppScrollBarUI();
    }

to IAppScrollBarUI and it looks great.

Thanks for adding this. Makes it much easier to use the lib!

-hendrik

Original comment by supp...@beatunes.com on 7 Jan 2009 at 6:44

GoogleCodeExporter commented 8 years ago
Thanks for digging that up Hendrik. I've added the createUI method, so it 
should be all set now! Give me the 
thumbs up when you update and verify the fix and I'll close this issue.

Feel free to let me know about other API usability issues.

Thanks for helping out with this one.
-Ken

Original comment by kenneth....@gmail.com on 7 Jan 2009 at 6:51

GoogleCodeExporter commented 8 years ago
Works. Close it.

Thanks, Ken.

Original comment by supp...@beatunes.com on 7 Jan 2009 at 7:00

GoogleCodeExporter commented 8 years ago
Great...thanks.

Original comment by kenneth....@gmail.com on 7 Jan 2009 at 7:31