
|
If you were logged in you would be able to see more operations.
|
|
|
|
Issue Links:
|
Reference
|
|
This issue relates to:
|
|
UBA-7594
Using EaSynthLookAndFeel with ULCTableTree with Java 6 u 10 results in NPE
|
|
|
|
|
|
|
|
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();
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 (!fCalledOnce) {
fCalledOnce = true;
return super.getForeground();
} else {
fCalledOnce = false;
return Color.black;
}
}
}
}
}
|
|
Description
|
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();
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 (!fCalledOnce) {
fCalledOnce = true;
return super.getForeground();
} else {
fCalledOnce = false;
return Color.black;
}
}
}
}
}
|
Show » |
| There are no comments yet on this issue.
|
|