Hi Markus,

Thanks for pointing out the problem.

This is a bug. I have created an issue:
https://www.canoo.com/jira/browse/UBA-7048

DefaultTreeCellRenderer.getLeafIcon() is null because it has been removed
from UIDefaults but TableTreeTree.getTableCellOffset does not check for
null.

I cannot think of a workaround.

Thanks and regards,

Janak

>-----Original Message-----
>From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
>Sent: Thursday, September 07, 2006 6:57 PM
>To: [EMAIL PROTECTED]
>Subject: RE: [ULC-developer] DefaultRenderer on Tree / TableTree
>
>
>Hi Janak
>
>To reproduce the problem please see and run the class
>ULCTableTreeTest below.
>We are using ULC 6.1.1. and (Sun) JRE 1.4.2_06.
>
>Regards,
>Markus
>
>
>import javax.swing.UIDefaults;
>import javax.swing.UIManager;
>
>import com.ulcjava.base.application.AbstractApplication;
>import com.ulcjava.base.application.ULCFrame;
>import com.ulcjava.base.application.ULCScrollPane;
>import com.ulcjava.base.application.ULCTableTree;
>import com.ulcjava.base.application.tabletree.DefaultMutableTableTreeNode;
>import com.ulcjava.base.application.tabletree.DefaultTableTreeModel;
>import com.ulcjava.base.development.DevelopmentRunner;
>
>
>public class ULCTableTreeTest extends AbstractApplication {
>
>    public void start() {
>
>        DefaultMutableTableTreeNode root = new DefaultMutableTableTreeNode(
>                new Object[] { "node", "abs", "per" }, false);
>        DefaultMutableTableTreeNode node1 = new
>DefaultMutableTableTreeNode(
>                new Object[] { "node1", "total",
>                        "total % " }, true);
>        DefaultMutableTableTreeNode node2 = new
>DefaultMutableTableTreeNode(
>                new Object[] { "AAAA", "13605", "16.84" }, false);
>        DefaultMutableTableTreeNode node3 = new
>DefaultMutableTableTreeNode(
>                new Object[] { "BBBBB", "xx", "yy" }, true);
>        DefaultMutableTableTreeNode node4 = new
>DefaultMutableTableTreeNode(
>                new Object[] { "CCCC", "11", "0.01" }, false);
>        DefaultMutableTableTreeNode node5= new DefaultMutableTableTreeNode(
>                new Object[] { "DDDD", "zz", "vv" }, true);
>
>        node1.add(node2);
>        node4.add(node5);
>
>        root.add(node1);
>        root.add(node3);
>        root.add(node4);
>
>        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);
>
>        ULCFrame frame = new ULCFrame();
>        frame.setDefaultCloseOperation(ULCFrame.TERMINATE_ON_CLOSE);
>        frame.add(new ULCScrollPane(tree));
>        frame.pack();
>        frame.setSize(700, 300);
>        frame.setVisible(true);
>    }
>
>    public static void main(String[] args) {
>
>        UIDefaults uiDefaults = UIManager.getDefaults();
>        uiDefaults.remove("Tree.leafIcon");
>
>        DevelopmentRunner.setApplicationClass(ULCTableTreeTest.class);
>        DevelopmentRunner.run();
>    }
>}
>
>-----Original Message-----
>From: Janak Mulani [mailto:[EMAIL PROTECTED]
>Sent: Donnerstag, 7. September 2006 14:42
>To: Wyss, Markus
>Cc: [email protected]
>Subject: RE: [ULC-developer] DefaultRenderer on Tree / TableTree
>
>Hi Markus,
>
>
>>We tried to set the Tree.leafIcon to null in our customized
>>look&Feel class in the defaults table and get a
>>nullpointerexception. Putting the snippet
>>
>>        UIDefaults uiDefaults = UIManager.getDefaults();
>>        uiDefaults.put("Tree.leafIcon", null);
>>
>>in the main-method of the ULCTableTreeTest you get the same
>>behaviour and the follwing stacktrace:
>
>I tried the above, i.e., specifying null icon, with ULC 6.1.1 and JRE
>1.4.2_05. I am not getting any errors.
>
>I tried putting a particular leaf icon and that is displayed correctly.
>
>When I specify a custom renderer, no icon is displayed for leaf.
>
>When I do not specify a custom renderer then:
>If icon is specified in uidefaults, then that icon is displayed
>If icon is null in uidefaults, then default icon is displayed
>
>At no time I got an error.
>
>Am I missing something?
>
>You say that you have a customized L&F class. Which L&F do you set?
>
>It will help if you can send a small snippet with all the relevant classes.
>
>Thanks and regards,
>
>Janak
>
>
>>
>>java.lang.NullPointerException
>>      at
>>com.ulcjava.base.client.tabletree.TableTreeTree.getTableCellOffset(
>>TableTreeTree.java:4)
>>      at
>>com.ulcjava.base.client.tabletree.TreeColumnCellRenderer.getTableCe
>>llRendererComponent(TreeColumnCellRenderer.java:7)
>>      at
>>com.ubs.swidULF.v2.client.tabletree.UlfTreeColumnCellRenderer.getTa
>>bleCellRendererComponent(UlfTreeColumnCellRenderer.java:96)
>>      at javax.swing.JTable.prepareRenderer(JTable.java:3789)
>>      at
>>com.ubs.swidULF.v2.client.tabletree.UlfTableTreeTable.prepareRender
>>er(UlfTableTreeTable.java:52)
>>      at
>>javax.swing.plaf.basic.BasicTableUI.paintCell(BasicTableUI.java:1236)
>>      at
>>javax.swing.plaf.basic.BasicTableUI.paintCells(BasicTableUI.java:1138)
>>      at javax.swing.plaf.basic.BasicTableUI.paint(BasicTableUI.java:1061)
>>      at com.ubs.swidULF.v2.plaf.ulf.UlfTableUI.paint(UlfTableUI.java:65)
>>      at javax.swing.plaf.ComponentUI.update(ComponentUI.java:174)
>>      at javax.swing.JComponent.paintComponent(JComponent.java:576)
>>      at javax.swing.JComponent.paint(JComponent.java:843)
>>      at
>>com.ulcjava.base.client.tabletree.TableTreeTable.paint(TableTreeTab
>>le.java:43)
>>      at javax.swing.JComponent.paintChildren(JComponent.java:682)
>>      at javax.swing.JComponent.paint(JComponent.java:852)
>>      at javax.swing.JComponent.paintChildren(JComponent.java:682)
>>      at javax.swing.JComponent.paint(JComponent.java:852)
>>      at javax.swing.JViewport.paint(JViewport.java:753)
>>      at javax.swing.JComponent.paintChildren(JComponent.java:682)
>>      at javax.swing.JComponent.paint(JComponent.java:852)
>>      at javax.swing.JComponent.paintChildren(JComponent.java:682)
>>      at javax.swing.JComponent.paint(JComponent.java:852)
>>      at javax.swing.JComponent.paintChildren(JComponent.java:682)
>>      at javax.swing.JComponent.paint(JComponent.java:852)
>>      at javax.swing.JLayeredPane.paint(JLayeredPane.java:586)
>>      at javax.swing.JComponent.paintChildren(JComponent.java:682)
>>      at
>>javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4919)
>>      at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4865)
>>      at javax.swing.JComponent.paint(JComponent.java:833)
>>      at
>>java.awt.GraphicsCallback$PaintCallback.run(GraphicsCallback.java:63)
>>      at
>>sun.awt.SunGraphicsCallback.runOneComponent(SunGraphicsCallback.java:93)
>>      at
>>sun.awt.SunGraphicsCallback.runComponents(SunGraphicsCallback.java:130)
>>      at java.awt.Container.paint(Container.java:1349)
>>      at
>>java.awt.GraphicsCallback$PaintCallback.run(GraphicsCallback.java:54)
>>      at sun.awt.RepaintArea.paint(RepaintArea.java:216)
>>      at
>>sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:293)
>>      at java.awt.Component.dispatchEventImpl(Component.java:3774)
>>      at java.awt.Container.dispatchEventImpl(Container.java:1665)
>>      at java.awt.Window.dispatchEventImpl(Window.java:1653)
>>      at java.awt.Component.dispatchEvent(Component.java:3574)
>>      at java.awt.EventQueue.dispatchEvent(EventQueue.java:536)
>>      at
>>com.ulcjava.base.client.FilteringEventQueue.dispatchEvent(Filtering
>>EventQueue.java:25)
>>      at
>>java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatch
>>Thread.java:237)
>>      at
>>java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchTh
>>read.java:187)
>>      at
>>java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:181)
>>      at
>>java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:173)
>>      at java.awt.EventDispatchThread.run(EventDispatchThread.java:136)
>>
>>
>>Regards,
>>Markus
>>
>>-----Original Message-----
>>From: Janak Mulani [mailto:[EMAIL PROTECTED]
>>Sent: Montag, 4. September 2006 16:11
>>To: Wyss, Markus
>>Cc: [email protected]
>>Subject: RE: [ULC-developer] DefaultRenderer on Tree / TableTree
>>
>>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

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

Reply via email to