Issue Details (XML | Word | Printable)

Key: UBA-7591
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Janak Mulani
Reporter: Janak Mulani
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
ULCBase

Using EaSynthLookAndFeel with ULCTableTree results in StackOverFlowError

Created: 04/Nov/08 10:06 AM   Updated: 20/Jan/09 05:30 PM
Component/s: components
Affects Version/s: UltraLightClient '08
Fix Version/s: UltraLightClient '08 Update 2

Issue Links:
Reference
 


 Description  « Hide
ULCTableTree's client side widget JTablteTree is a JPanel which contains a JTable. The JTableTree.getForeground() delegates to Jtable.getForground(). In the case of EASynthLnF, JTable's foreground color is null therefore it tries to return the foreground color of its container (JTableTree) but this results in recursive calls leading to stack overflow.

This could also happen for getBackground and getFont if the defaults are null in a specified LnF. Therefore we need to apply similar fix to these methods too.

import java.awt.Color;

import javax.swing.UIManager;

import com.ulcjava.base.application.AbstractApplication;
import com.ulcjava.base.application.ULCBorderLayoutPane;
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.client.UITableTree;
import com.ulcjava.base.development.DevelopmentRunner;
import com.ulcjava.base.shared.internal.Anything;

public class PR7591 extends AbstractApplication {
    public void start() {

        ULCFrame frame = new ULCFrame();

        frame.setDefaultCloseOperation(ULCFrame.TERMINATE_ON_CLOSE);

        DefaultMutableTableTreeNode root = new DefaultMutableTableTreeNode(new Object[] { "root", "root", "root" },
                new boolean[] { false, false, true }, false);
        DefaultMutableTableTreeNode row1 = new DefaultMutableTableTreeNode(new Object[] { "AAA", "BBB", "CCC" },
                new boolean[] { false, false, true }, false);
        DefaultMutableTableTreeNode row1a = new DefaultMutableTableTreeNode(new Object[] { "aaa", "bbb", "ccc" },
                new boolean[] { false, false, true }, true);
        DefaultMutableTableTreeNode row2 = new DefaultMutableTableTreeNode(new Object[] { "DDD", "EEE", "FFF" },
                new boolean[] { false, false, true }, false);
        DefaultMutableTableTreeNode row2a = new DefaultMutableTableTreeNode(new Object[] { "ddd", "eee", "fff" },
                new boolean[] { false, false, true }, true);

        row1.add(row1a);
        row2.add(row2a);

        root.add(row1);
        root.add(row2);

        final DefaultTableTreeModel model = new DefaultTableTreeModel(root, new String[] { "As", "Bs", "Cs" });

        model.setRoot(root);

         final ULCTableTree tree = new ULCTableTree();
 
        // Work around
        //final ULCTableTree tree = new ULCMyTableTree();

        tree.setModel(model);
        tree.setRowSelectionAllowed(true);
        tree.setColumnSelectionAllowed(true);

        frame.add(new ULCScrollPane(tree), ULCBorderLayoutPane.NORTH);

        frame.setVisible(true);
    }

    public static void main(String[] args) {

        try {
            UIManager.setLookAndFeel("com.easynth.lookandfeel.EaSynthLookAndFeel");
        } catch (Exception e) {
            e.printStackTrace();
        }
        DevelopmentRunner.setApplicationClass(PR7591.class);
        DevelopmentRunner.run();
    }

    public static class ULCMyTableTree extends ULCTableTree {
        public ULCMyTableTree() {
            super();
        }

        protected String typeString() {
            return UIMyTableTree.class.getName();
        }
    }

    public static class UIMyTableTree extends UITableTree {
        protected Object createBasicObject(Anything args) {
            return new MyTableTree();
        }

        private class MyTableTree extends BasicTableTree {
            public boolean fCalledOnce = false;

            @Override
            public Color getForeground() {

                if (getBasicTable() == null) {
                    return null;
                }
                // if Table is not null, we want to be called only once
                if (!fCalledOnce) {
                    fCalledOnce = true;
                    return super.getForeground();
                } else { 
                    fCalledOnce = false;
                    return Color.black;
                }
            }
        }
    }
}


 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
There are no comments yet on this issue.