Hi Markus,

Could you please tell me which version of ULC are you using and which JRE?

I assumed that you are using ULC 6.0.4 and hence tested your samples with
that version.

>- Using a custom renderer extended from
>DefaultTreeCellRenderer/DefaultTableTreeCellRenderer on ULCTree /
>ULCTableTree results in the lost of the default icons provided by
>the current look&feel. Using Swing's JTree the default icons are
>drawn. (See classes SimpleULCTree and SimpleJTree at the bottom of
>the mail)

I ran both the classes, I see no difference. The icon defined by the
renderer is drawn in both cases.

However, say I specify only the openIcon. Then the behavior is different in
Swing and ULC.

For closed nodes, Swing shows default icons while ULC shows no icon at all.

So, when you set a renderer in ULCTree which does not specify any icons,
ULCTree should draw default icons.

Is this the problem you are talking about?

The DefaultTreeCellRenderer in Swing takes default icons from L&F and sets
them on the renderer.

The DefaultTreeCellRenderer in ULC does not take default icons from L&F.

You will need an extension to overcome this problem.

I.e. you will have to define MyDefaultTreeCellRenderer extends MyULCLabel
and MyULCLabel extends ULCLabel.

Then in MyUILabel extends UILabel override getTreeCellRendererComponent and
set the default icons for leaf, open, close if no icon is specified.

>- On a ULCTree with a custom cell renderer (or on the tree column
>of ULCTableTree) the focus is drawn differently than the Swing
>counterpart. In ULC the icon is inside the focus border.

In Swing, on the DefaultTreeCellRenderer, there is a property
"drawsFocusBorderAroundIcon" which is defined by L&F
UIManager.get("Tree.drawsFocusBorderAroundIcon"). For Metal it is false.

DefaultTreeCellRenderer extends JLabel and overrides the paint() method in
which it considers this property.

This property is not being considered in case of ULC.

You will need an extension to overcome this problem.

I.e. you will have to define MyDefaultTreeCellRenderer extends MyULCLabel
and MyULCLabel extends ULCLabel.

Then in MyUILabel extends UILabel create your own JLabel in
createBasicObject() and override its paint method.

See Swing's DefaultTreeCellRenderer.paint()

>- On a ULCTableTree with a custom cell renderer: The lines of the
>tree are not drawn on the selected row(s). (See class ULCTableTreeTest)

I did setSelectionBackground(Color.white).

I can see the line connecting parent node with child node if that is what
you meant by "lines of the tree".

The color of the lines and the selectionBackground color are the same and
that is the reason you don't see them.

I hope I understood your problem.

>- Setting a default tree icon of the look and feel to null (e.q.
>UIManager.put("Tree.leafIcon", null) ) results in a
>NullPointerException in the TableTree-Widget.

Can you please send me a small snippet and the stack trace?

Doing the above in your ULCTableTreeTest did not give any error.

Thanks and regards,

Janak

>Is there a workaround especially for the focus and line drawing issue ?
>
>Best Regards,
>Markus Wyss
>UBS AG
>
>Tel. +41-44-236 31 02
>Fax.+41-44-236 30 22
>
>public class SimpleULCTree extends AbstractApplication {
>
>    public void start() {
>        ULCFrame frame = new ULCFrame("ULCTree with
>DefaultTreeCellRenderer");
>
>        ULCBorderLayoutPane colorBox = new ULCBorderLayoutPane();
>        colorBox.add(new ULCScrollPane(createTree()));
>
>        frame.getContentPane().add(colorBox);
>        frame.pack();
>        frame.setSize(400, 400);
>        frame.setDefaultCloseOperation(ULCFrame.TERMINATE_ON_CLOSE);
>        frame.setVisible(true);
>    }
>
>    private ULCTree createTree() {
>        final ULCTree tree = new ULCTree(new MyTreeModel());
>        tree.setCellRenderer(new MyTreeRenderer());
>        return tree;
>    }
>
>    class MyTreeRenderer extends DefaultTreeCellRenderer {
>
>        public MyTreeRenderer() {
>            super();
>            ULCIcon icon = new
>ULCIcon(this.getClass().getResource("ampel_rot.gif"));
>            setClosedIcon(icon);
>            setOpenIcon(icon);
>            setLeafIcon(icon);
>        }
>
>    }
>
>    public static void main(String[] args) {
>            DevelopmentRunner.setApplicationClass(SimpleULCTree.class);
>            DevelopmentRunner.run();
>       }
>
>    public class MyTreeModel extends DefaultTreeModel {
>
>        public MyTreeModel() {
>            super( new DefaultMutableTreeNode("Customers"));
>
>            DefaultMutableTreeNode customers =
>(DefaultMutableTreeNode) getRoot();
>
>            DefaultMutableTreeNode bundle1234 = new
>DefaultMutableTreeNode("Bundle 1234");
>            customers.add(bundle1234);
>
>            DefaultMutableTreeNode brig = new
>DefaultMutableTreeNode("Brig");
>            bundle1234.add(brig);
>            brig.add(new DefaultMutableTreeNode("Account 11111111", true));
>            brig.add(new DefaultMutableTreeNode("Account 22222222", true));
>
>            DefaultMutableTreeNode ascona = new
>DefaultMutableTreeNode("Ascona");
>            bundle1234.add(ascona);
>            ascona.add(new DefaultMutableTreeNode("Account
>3333333", true));
>
>
>            DefaultMutableTreeNode bundle5678 = new
>DefaultMutableTreeNode("Bundle 5678");
>            customers.add(bundle5678);
>
>            DefaultMutableTreeNode zuerich = new
>DefaultMutableTreeNode("Zürich");
>            bundle5678.add(zuerich);
>            zuerich.add(new DefaultMutableTreeNode("Account
>4444444", true));
>        }
>    }
>}
>
>public class SimpleJTree extends JFrame {
>
>    public SimpleJTree() {
>        super("JTree with DefaultTreeCellRenderer");
>
>        JPanel colorBox = new JPanel(new BorderLayout());
>        colorBox.add(new JScrollPane(createTree()));
>
>        getContentPane().add(colorBox);
>        pack();
>        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
>        setSize(400, 400);
>    }
>
>    private JTree createTree() {
>        final JTree tree = new JTree(new MyTreeModel());
>        tree.setCellRenderer(new MyTreeRenderer());
>        return tree;
>    }
>
>
>    class MyTreeRenderer extends DefaultTreeCellRenderer {
>
>        public MyTreeRenderer() {
>            super();
>            Icon icon = new
>ImageIcon(this.getClass().getResource("ampel_rot.gif"));
>            setOpenIcon(icon);
>            setClosedIcon(icon);
>            setLeafIcon(icon);
>        }
>
>    }
>
>    public static void main(String[] args) {
>        SimpleJTree simpleTree = new SimpleJTree();
>        simpleTree.setVisible(true);
>       }
>
>    public class MyTreeModel extends DefaultTreeModel {
>
>        public MyTreeModel() {
>            super( new DefaultMutableTreeNode("Customers"));
>
>            DefaultMutableTreeNode customers =
>(DefaultMutableTreeNode) getRoot();
>
>            DefaultMutableTreeNode bundle1234 = new
>DefaultMutableTreeNode("Bundle 1234");
>            customers.add(bundle1234);
>
>            DefaultMutableTreeNode brig = new
>DefaultMutableTreeNode("Brig");
>            bundle1234.add(brig);
>            brig.add(new DefaultMutableTreeNode("Account 11111111", true));
>            brig.add(new DefaultMutableTreeNode("Account 22222222", true));
>
>            DefaultMutableTreeNode ascona = new
>DefaultMutableTreeNode("Ascona");
>            bundle1234.add(ascona);
>            ascona.add(new DefaultMutableTreeNode("Account
>3333333", true));
>
>
>            DefaultMutableTreeNode bundle5678 = new
>DefaultMutableTreeNode("Bundle 5678");
>            customers.add(bundle5678);
>
>            DefaultMutableTreeNode zuerich = new
>DefaultMutableTreeNode("Zürich");
>            bundle5678.add(zuerich);
>            zuerich.add(new DefaultMutableTreeNode("Account
>4444444", true));
>        }
>    }
>}
>
>public class ULCTableTreeTest extends AbstractApplication {
>    public void start() {
>        ULCFrame frame = new ULCFrame();
>        frame.setDefaultCloseOperation(ULCFrame.TERMINATE_ON_CLOSE);
>
>        DefaultMutableTableTreeNode root = new DefaultMutableTableTreeNode(
>                new Object[] { "root", "root", "root" }, false);
>        DefaultMutableTableTreeNode primaryOffering = new
>DefaultMutableTableTreeNode(
>                new Object[] { "Offer", "Total",
>                        "Total % " }, true);
>        DefaultMutableTableTreeNode ubsStrategy = new
>DefaultMutableTableTreeNode(
>                new Object[] { "AAAA", "13605", "16.84" }, false);
>        DefaultMutableTableTreeNode inUbsStrategy = new
>DefaultMutableTableTreeNode(
>                new Object[] { "BBBBB", "xx", "yy" }, true);
>        DefaultMutableTableTreeNode ubsXtra = new
>DefaultMutableTableTreeNode(
>                new Object[] { "CCCC", "11", "0.01" }, false);
>        DefaultMutableTableTreeNode inUbsXtra = new
>DefaultMutableTableTreeNode(
>                new Object[] { "DDDD", "zz", "vv" }, true);
>
>        ubsStrategy.add(inUbsStrategy);
>        ubsXtra.add(inUbsXtra);
>
>        root.add(primaryOffering);
>        root.add(ubsStrategy);
>        root.add(ubsXtra);
>
>        DefaultTableTreeModel model = new DefaultTableTreeModel(root,
>                new String[] { "col1", "col2", "col3" });
>
>        model.setRoot(root);
>        ULCTableTree tree = new ULCTableTree(model);
>        tree.setRootVisible(false);
>        tree.setShowsRootHandles(true);
>
>        tree.setTableTreeHeader(null);
>        ULCTableTreeColumnModel cm = tree.getColumnModel();
>
>        cm.getColumn(0).setCellRenderer(new
>MyCellRenderer(IDefaults.LEFT));
>        cm.getColumn(1).setCellRenderer(new
>MyCellRenderer(IDefaults.RIGHT));
>        cm.getColumn(2).setCellRenderer(new
>MyCellRenderer(IDefaults.RIGHT));
>
>        frame.add(new ULCScrollPane(tree));
>        frame.pack();
>        frame.setLocation(300, 400);
>        frame.setSize(700, 300);
>        frame.setVisible(true);
>    }
>
>    class MyCellRenderer extends DefaultTableTreeCellRenderer {
>        public MyCellRenderer(int alignment) {
>            super();
>            setHorizontalAlignment(alignment);
>        }
>    }
>
>    public static void main(String[] args) {
>        DevelopmentRunner.setApplicationClass(ULCTableTreeTest.class);
>        DevelopmentRunner.run();
>    }
>}
>_______________________________________________
>ULC-developer mailing list
>[email protected]
>http://lists.canoo.com/mailman/listinfo/ulc-developer

_______________________________________________
ULC-developer mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/ulc-developer

Reply via email to