Making JTree custom renderer panel scalable

Hi, everyone. I have made custom TreeCellRenderer which extends JPanel. Panel's background is in different color than JTree's backgound. I need to get my panel rendering the nodes to fill the whole space JTree has in it's parent panel horizontally. For now I have put static width to nodes and it looks fine, but it's not scalable. If I don't put any sizes the panel takes only the size it needs in cell and the outfit is crappy because of panel's different bgcolor. Is there any easy way to make rendering panel use the width which JTree has in it's container. I have implemented getPreferredSize() method in custom TreeCellRenderer and now it returns the static width and height of the rendering panel. Do I have to get JTrees container panel's width every time and pass it to renderer and get size somehow from there or is there some easier way.
-e

Yes, there is a reason. Different levels of nodes contain different components. Example main level nodes have print and save buttons on the most right of the panel. Only leafs have same bgcolor as the tree has and those are already now scalable, because size is not set for them.

Similar Messages

  • JTree custom renderer - JScrollPane

    Hi,
    I am building a JTree and need a custom renderer that will allow me to display the contents of certain leaf nodes in a JEditorPane that is contained in a scrollpane as the leaf may contain a varying amount of text.
    I have managed to get a renderer displaying the text as expected however the scrollbars do not work as I hoped - I cannot scroll down the editorpane.
    Has anyone got an example of a renderer that uses a scrollpane, any help/suggestions would be gratefully received.
    Thanks

    Return the size of your editor pane in customized cell renderer's getPreferredSize() method and set JTree rowHeight to zero. When row height is 0, it use renderer's getPreferredSize() to get size of the cell, I think. I have made custom cellrenderer which extends Jpanel and in getCellRendererComponent I add there another panel which contains buttons etc. I have used super.getPreferredSize() in my renderer's getPreferredSize() method.

  • Problem with JTree custom renderer when editing

    I have a JTree which uses a custom renderer to display my own icons for different types of nodes. The problem I am having is when I setEditable to true and then attept to edit a node the icon switches back to the default icon, as soon as I am done editing it goes back.
    What I am doing wrong?

    Here is my rendererer
    public class DeviceTreeRenderer extends DefaultTreeCellRenderer implements GuiConstants {
       public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
          JLabel returnValue = (JLabel)super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
          if (value != null) {
             returnValue.setToolTipText(value.toString());
          if (value instanceof Device) {
             returnValue.setIcon(TREE_DEVICE);
             if (!((Device)value).isAlive()) {
                returnValue.setEnabled(false);
          else if (value instanceof GuiPanelGroup) {
             if (expanded) {
                returnValue.setIcon(TREE_PANEL_GROUP_OPEN);
             else {
                returnValue.setIcon(TREE_PANEL_GROUP_CLOSED);
          else if (value instanceof GuiPanel && ((GuiPanel)value).isDirty()) {
             returnValue.setIcon(TREE_PANEL_DIRTY);
          return returnValue;
    }Here is my editor:
    public class WwpJTreeCellEditor extends DefaultTreeCellEditor implements GuiConstants {
          private WwpJTree tree;
           * Creates a new WwpJTreeCellEditor.
           * @param tree The WwpJTree to associate with this editor.
          public WwpJTreeCellEditor(WwpJTree tree) {
             super(tree, (DefaultTreeCellRenderer)tree.getCellRenderer());
             this.tree = tree;
           * Overrides the default isCellEditable so that we check the isEditable() method
           * of the WwpJTreeNodes.
           * @param e An EventObject.
          public boolean isCellEditable(EventObject e) {
             boolean returnValue = super.isCellEditable(e);
             if (returnValue) {
                WwpJTreeNode node = this.tree.getSelectedNode();
                if (node == null || !node.isEditable() || node.isDragging()) {
                   returnValue = false;
             return returnValue;
       }In my JTree I make these calls:
    super.setCellRenderer(new DeviceTreeRenderer());
    super.setCellEditor(new WwpJTreeCellEditor(this));
    super.setEditable(true);

  • JTree custom renderer setting selection background color problem

    Hi,
    I have a JTree with a custom icon renderer that displays an icon. The JTree is part of a TreeTable component. Iam having a problem setting the selection background uniformly for the entire row. There is no problem when there is no row selected in the JTable.
    My present code looks like this:
    Iam overriding paint in my renderer which extends DefaultCellRenderer.
           super.paint(g);
            Color bColor = null;
            if(!m_selected) {
                 if(currRow % 2 == 0) {
                      bColor = Color.WHITE;
                 } else {
                                                    bColor = backColor;
            } else {
                 bColor = table.getSelectionBackground();                  bColor = getRowSelectionColor();
         if(bColor != null) {
                           g.setColor(bColor);
             if(!m_selected) {
                   g.setXORMode(new Color(0xFF, 0xFF, 0xFF));
             } else {
                 g.setXORMode(new Color(0x00, 0x00, 0x00));
                  I have a color I arrive at using some algorithm that I want using method getRowSelectionColor(). The other cells in the row have this color. But the cell containing the tree node shows different color. Iam not able to arrive at the right combination of the color to set and the xor color so my tree node also looks like the other cells in the row.
    It is not a problem really as the table still looks good. Its just that the tree node looks like it has been highlighted and this might cause a problem when a table cell is highlighed later on in the application ( two cells in the row would be highlighted causing confusion).
    Any help would be appreciated.
    Regards,
    vidyut

    Hi Camickr,
    Thanks for the reply. Iam sorry I didn't include the sources the first time around. There were too many of them. I have created a small, self-contained, compilable program that demonstrates the problem and including it herewith. Still there's quite many files but they are all needed Iam afraid. The only one you will have to concern yourself fior this problem is the file IconRenderer.java. The treenode background and the other cells background are not in sync when table row is not selected in this example though. But they are in my real program. I just need them to be in sync i.e have the same background color when the row is selected.
    Your help would be very much appreciated.
    These are the files that are included below:
    1. AbstractTreeTableModel.java
    2. Bookmarks.java
    3. BookmarksModel.java
    4. DynamicTreeTableModel.java
    5. IconRenderer.java
    6. IndicatorRenderer.java
    7. JTreeTable.java
    8. TreeTableExample3.java (contains main)
    9. TreeTableModel.java
    10. TreeTableModelAdapter.java
    The copyright and javadocs information has been stripped for clarity.
    cheers,
    vidyut
    // AbstractTreeTableModel.java BEGIN
    import javax.swing.tree.*;
    import javax.swing.event.*;
    public abstract class AbstractTreeTableModel implements TreeTableModel {
        protected Object root;    
        protected EventListenerList listenerList = new EventListenerList();
        public AbstractTreeTableModel(Object root) {
            this.root = root;
        // Default implementations for methods in the TreeModel interface.
        public Object getRoot() {
            return root;
        public boolean isLeaf(Object node) {
            return getChildCount(node) == 0;
        public void valueForPathChanged(TreePath path, Object newValue) {}
        // This is not called in the JTree's default mode:
        // use a naive implementation.
        public int getIndexOfChild(Object parent, Object child) {
            for (int i = 0; i < getChildCount(parent); i++) {
             if (getChild(parent, i).equals(child)) {
                 return i;
         return -1;
        public void addTreeModelListener(TreeModelListener l) {
            listenerList.add(TreeModelListener.class, l);
        public void removeTreeModelListener(TreeModelListener l) {
            listenerList.remove(TreeModelListener.class, l);
        protected void fireTreeNodesChanged(Object source, Object[] path,
                                            int[] childIndices,
                                            Object[] children) {
            // Guaranteed to return a non-null array
            Object[] listeners = listenerList.getListenerList();
            TreeModelEvent e = null;
            // Process the listeners last to first, notifying
            // those that are interested in this event
            for (int i = listeners.length-2; i>=0; i-=2) {
                if (listeners==TreeModelListener.class) {
    // Lazily create the event:
    if (e == null)
    e = new TreeModelEvent(source, path,
    childIndices, children);
    ((TreeModelListener)listeners[i+1]).treeNodesChanged(e);
    protected void fireTreeNodesInserted(Object source, Object[] path,
    int[] childIndices,
    Object[] children) {
    // Guaranteed to return a non-null array
    Object[] listeners = listenerList.getListenerList();
    TreeModelEvent e = null;
    // Process the listeners last to first, notifying
    // those that are interested in this event
    for (int i = listeners.length-2; i>=0; i-=2) {
    if (listeners[i]==TreeModelListener.class) {
    // Lazily create the event:
    if (e == null)
    e = new TreeModelEvent(source, path,
    childIndices, children);
    ((TreeModelListener)listeners[i+1]).treeNodesInserted(e);
    protected void fireTreeNodesRemoved(Object source, Object[] path,
    int[] childIndices,
    Object[] children) {
    // Guaranteed to return a non-null array
    Object[] listeners = listenerList.getListenerList();
    TreeModelEvent e = null;
    // Process the listeners last to first, notifying
    // those that are interested in this event
    for (int i = listeners.length-2; i>=0; i-=2) {
    if (listeners[i]==TreeModelListener.class) {
    // Lazily create the event:
    if (e == null)
    e = new TreeModelEvent(source, path,
    childIndices, children);
    ((TreeModelListener)listeners[i+1]).treeNodesRemoved(e);
    protected void fireTreeStructureChanged(Object source, Object[] path,
    int[] childIndices,
    Object[] children) {
    // Guaranteed to return a non-null array
    Object[] listeners = listenerList.getListenerList();
    TreeModelEvent e = null;
    // Process the listeners last to first, notifying
    // those that are interested in this event
    for (int i = listeners.length-2; i>=0; i-=2) {
    if (listeners[i]==TreeModelListener.class) {
    // Lazily create the event:
    if (e == null)
    e = new TreeModelEvent(source, path,
    childIndices, children);
    ((TreeModelListener)listeners[i+1]).treeStructureChanged(e);
    // Default impelmentations for methods in the TreeTableModel interface.
    public Class getColumnClass(int column) { return Object.class; }
    public boolean isCellEditable(Object node, int column) {
    return getColumnClass(column) == TreeTableModel.class;
    public void setValueAt(Object aValue, Object node, int column) {}
    // Left to be implemented in the subclass:
    * public Object getChild(Object parent, int index)
    * public int getChildCount(Object parent)
    * public int getColumnCount()
    * public String getColumnName(Object node, int column)
    * public Object getValueAt(Object node, int column)
    // AbstractTreeTableModel.java END
    // Bookmarks.java BEGIN
    import java.io.*;
    import java.net.*;
    import java.util.*;
    import javax.swing.*;
    import javax.swing.tree.*;
    import javax.swing.text.*;
    import javax.swing.text.html.*;
    import javax.swing.text.html.parser.*;
    public class Bookmarks {
    /** The root node the bookmarks are added to. */
    private BookmarkDirectory root;
    * Creates a new Bookmarks object, with the entries coming from
    * <code>path</code>.
    public Bookmarks(String path) {
         root = new BookmarkDirectory("Bookmarks");
         if (path != null) {
         parse(path);
    * Returns the root of the bookmarks.
    public BookmarkDirectory getRoot() {
         return root;
    protected void parse(String path) {
         try {
         BufferedReader reader = new BufferedReader(new FileReader
                                       (path));
         new ParserDelegator().parse(reader, new CallbackHandler(), true);
         catch (IOException ioe) {
         System.out.println("IOE: " + ioe);
         JOptionPane.showMessageDialog(null, "Load Bookmarks",
                             "Unable to load bookmarks",
                             JOptionPane.ERROR_MESSAGE);
    private static final short NO_ENTRY = 0;
    private static final short BOOKMARK_ENTRY = 2;
    private static final short DIRECTORY_ENTRY = 3;
    private class CallbackHandler extends HTMLEditorKit.ParserCallback {
         /** Parent node that new entries are added to. */
         private BookmarkDirectory parent;
         /** The most recently parsed tag. */
         private HTML.Tag tag;
         /** The last tag encountered. */
         private HTML.Tag lastTag;
         * The state, will be one of NO_ENTRY, DIRECTORY_ENTRY,
    * or BOOKMARK_ENTRY.
         private short state;
         * Date for the next BookmarkDirectory node.
         private Date parentDate;
         * The values from the attributes are placed in here. When the
         * text is encountered this is added to the node hierarchy and a
    * new instance is created.
         private BookmarkEntry lastBookmark;
         * Creates the CallbackHandler.
         public CallbackHandler() {
         parent = root;
         lastBookmark = new BookmarkEntry();
         // HTMLEditorKit.ParserCallback methods
         * Invoked when text in the html document is encountered. Based on
         * the current state, this will either: do nothing
    * (state == NO_ENTRY),
         * create a new BookmarkEntry (state == BOOKMARK_ENTRY) or
    * create a new
         * BookmarkDirectory (state == DIRECTORY_ENTRY). If state is
    * != NO_ENTRY, it is reset to NO_ENTRY after this is
    * invoked.
    public void handleText(char[] data, int pos) {
         switch (state) {
         case NO_ENTRY:
              break;
         case BOOKMARK_ENTRY:
              // URL.
              lastBookmark.setName(new String(data));
    parent.add(lastBookmark);
    lastBookmark = new BookmarkEntry();
              break;
         case DIRECTORY_ENTRY:
              // directory.
              BookmarkDirectory newParent = new
                   BookmarkDirectory(new String(data));
              newParent.setCreated(parentDate);
              parent.add(newParent);
              parent = newParent;
              break;
         default:
              break;
    state = NO_ENTRY;
         * Invoked when a start tag is encountered. Based on the tag
         * this may update the BookmarkEntry and state, or update the
         * parentDate.
         public void handleStartTag(HTML.Tag t, MutableAttributeSet a,
                        int pos) {
         lastTag = tag;
         tag = t;
         if (t == HTML.Tag.A && lastTag == HTML.Tag.DT) {
    long lDate;
              // URL
              URL url;
              try {
              url = new URL((String)a.getAttribute(HTML.Attribute.HREF));
              } catch (MalformedURLException murle) {
              url = null;
              lastBookmark.setLocation(url);
              // created
              Date date;
              try {
    lDate = Long.parseLong((String)a.getAttribute("add_date"));
    if (lDate != 0l) {
    date = new Date(1000l * lDate);
    else {
    date = null;
              } catch (Exception ex) {
              date = null;
              lastBookmark.setCreated(date);
              // last visited
              try {
    lDate = Long.parseLong((String)a.
    getAttribute("last_visit"));
    if (lDate != 0l) {
    date = new Date(1000l * lDate);
    else {
    date = null;
              } catch (Exception ex) {
              date = null;
              lastBookmark.setLastVisited(date);
              state = BOOKMARK_ENTRY;
         else if (t == HTML.Tag.H3 && lastTag == HTML.Tag.DT) {
              // new node.
              try {
              parentDate = new Date(1000l * Long.parseLong((String)a.
                                  getAttribute("add_date")));
              } catch (Exception ex) {
              parentDate = null;
              state = DIRECTORY_ENTRY;
         * Invoked when the end of a tag is encountered. If the tag is
         * a DL, this will set the node that parents are added to the current
         * nodes parent.
         public void handleEndTag(HTML.Tag t, int pos) {
         if (t == HTML.Tag.DL && parent != null) {
              parent = (BookmarkDirectory)parent.getParent();
    public static class BookmarkDirectory extends DefaultMutableTreeNode {
         /** Dates created. */
         private Date created;
         public BookmarkDirectory(String name) {
         super(name);
         public void setName(String name) {
         setUserObject(name);
         public String getName() {
         return (String)getUserObject();
         public void setCreated(Date date) {
         this.created = date;
         public Date getCreated() {
         return created;
    public static class BookmarkEntry extends DefaultMutableTreeNode {
         /** User description of the string. */
         private String name;
         /** The URL the bookmark represents. */
         private URL location;
         /** Dates the URL was last visited. */
         private Date lastVisited;
         /** Date the URL was created. */
         private Date created;
         public void setName(String name) {
         this.name = name;
         public String getName() {
         return name;
         public void setLocation(URL location) {
         this.location = location;
         public URL getLocation() {
         return location;
         public void setLastVisited(Date date) {
         lastVisited = date;
         public Date getLastVisited() {
         return lastVisited;
         public void setCreated(Date date) {
         this.created = date;
         public Date getCreated() {
         return created;
         public String toString() {
         return getName();
    // Bookmarks.java END
    // BookmarksModel.java BEGIN
    import java.util.Date;
    public class BookmarksModel extends DynamicTreeTableModel {
    * Names of the columns.
    private static final String[] columnNames =
    { "Name", "Location", "Last Visited", "Created" };
    * Method names used to access the data to display.
    private static final String[] methodNames =
    { "getName", "getLocation", "getLastVisited","getCreated" };
    * Method names used to set the data.
    private static final String[] setterMethodNames =
    { "setName", "setLocation", "setLastVisited","setCreated" };
    private static final Class[] classes =
    { TreeTableModel.class, String.class, Date.class, Date.class };
    public BookmarksModel(Bookmarks.BookmarkDirectory root) {
         super(root, columnNames, methodNames, setterMethodNames, classes);
    public boolean isCellEditable(Object node, int column) {
         switch (column) {
         case 0:
         // Allow editing of the name, as long as not the root.
         return (node != getRoot());
         case 1:
         // Allow editing of the location, as long as not a
         // directory
         return (node instanceof Bookmarks.BookmarkEntry);
         default:
         // Don't allow editing of the date fields.
         return false;
    // BookmarksModel.java END
    // DynamicTreeTableModel.java BEGIN
    import java.lang.reflect.*;
    import javax.swing.tree.*;
    public class DynamicTreeTableModel extends AbstractTreeTableModel {
    /** Names of the columns, used for the TableModel getColumnName method. */
    private String[] columnNames;
    private String[] methodNames;
    private String[] setterMethodNames;
    /** Column classes, used for the TableModel method getColumnClass. */
    private Class[] cTypes;
    public DynamicTreeTableModel(TreeNode root, String[] columnNames,
                        String[] getterMethodNames,
                        String[] setterMethodNames,
                        Class[] cTypes) {
         super(root);
         this.columnNames = columnNames;
         this.methodNames = getterMethodNames;
         this.setterMethodNames = setterMethodNames;
         this.cTypes = cTypes;
    public int getChildCount(Object node) {
         return ((TreeNode)node).getChildCount();
    public Object getChild(Object node, int i) {
         return ((TreeNode)node).getChildAt(i);
    public boolean isLeaf(Object node) {
         return ((TreeNode)node).isLeaf();
    public int getColumnCount() {
         return columnNames.length;
    public String getColumnName(int column) {
         if (cTypes == null || column < 0 || column >= cTypes.length) {
         return null;
         return columnNames[column];
    public Class getColumnClass(int column) {
         if (cTypes == null || column < 0 || column >= cTypes.length) {
         return null;
         return cTypes[column];
    public Object getValueAt(Object node, int column) {
         try {
         Method method = node.getClass().getMethod(methodNames[column],
                                  null);
         if (method != null) {
              return method.invoke(node, null);
         catch (Throwable th) {}
         return null;
    * Returns true if there is a setter method name for column
    * <code>column</code>. This is set in the constructor.
    public boolean isCellEditable(Object node, int column) {
    return (setterMethodNames != null &&
         setterMethodNames[column] != null);
    // Note: This looks up the methods each time! This is rather inefficient;
    // it should really be changed to cache matching
    // methods/constructors
    // based on <code>node</code>'s class, and code>aValue</code>'s
    //class.
    public void setValueAt(Object aValue, Object node, int column) {
         boolean found = false;
         try {
         // We have to search through all the methods since the
         // types may not match up.
         Method[] methods = node.getClass().getMethods();
         for (int counter = methods.length - 1; counter >= 0; counter--) {
              if (methods[counter].getName().equals
              (setterMethodNames[column]) && methods[counter].
              getParameterTypes() != null && methods[counter].
              getParameterTypes().length == 1) {
              // We found a matching method
              Class param = methods[counter].getParameterTypes()[0];
              if (!param.isInstance(aValue)) {
                   // Yes, we can use the value passed in directly,
                   // no coercision is necessary!
                   if (aValue instanceof String &&
                   ((String)aValue).length() == 0) {
                   // Assume an empty string is null, this is
                   // probably bogus for here.
                   aValue = null;
                   else {
                   // Have to attempt some sort of coercision.
                   // See if the expected parameter type has
                   // a constructor that takes a String.
                   Constructor cs = param.getConstructor
                   (new Class[] { String.class });
                   if (cs != null) {
                        aValue = cs.newInstance(new Object[]
                                       { aValue });
                   else {
                        aValue = null;
              // null either means it was an empty string, or there
              // was no translation. Could potentially deal with these
              // differently.
              methods[counter].invoke(node, new Object[] { aValue });
              found = true;
              break;
         } catch (Throwable th) {
         System.out.println("exception: " + th);
         if (found) {
         // The value changed, fire an event to notify listeners.
         TreeNode parent = ((TreeNode)node).getParent();
         fireTreeNodesChanged(this, getPathToRoot(parent),
                        new int[] { getIndexOfChild(parent, node) },
                        new Object[] { node });
    public TreeNode[] getPathToRoot(TreeNode aNode) {
    return getPathToRoot(aNode, 0);
    private TreeNode[] getPathToRoot(TreeNode aNode, int depth) {
    TreeNode[] retNodes;
         // This method recurses, traversing towards the root in order
         // size the array. On the way back, it fills in the nodes,
         // starting from the root and working back to the original node.
    /* Check for null, in case someone passed in a null node, or
    they passed in an element that isn't rooted at root. */
    if(aNode == null) {
    if(depth == 0)
    return null;
    else
    retNodes = new TreeNode[depth];
    else {
    depth++;
    if(aNode == root)
    retNodes = new TreeNode[depth];
    else
    retNodes = getPathToRoot(aNode.getParent(), depth);
    retNodes[retNodes.length - depth] = aNode;
    return retNodes;
    // DynamicTreeTableModel.java END
    // IconRenderer.java BEGIN
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.tree.*;
    import javax.swing.plaf.basic.BasicTreeUI;
    class IconRenderer extends DefaultTreeCellRenderer
    // Color backColor = new Color(0xD0, 0xCC, 0xFF);
    Color backColor = new Color(0xF0, 0xF0, 0xE0);
    String tipText = "";
    JTree tree;
    int currRow = 0;
    boolean m_selected;
    JTable table;
    public IconRenderer(JTree tree, JTable table) {
    this.table = table;
    // setBackground(backColor);
    setBackground(Color.GREEN);
    setForeground(Color.black);
         this.tree = tree;
    public Component getTreeCellRendererComponent(JTree tree, Object value,
    boolean selected,
    boolean expanded, boolean leaf,
    int row, boolean hasFocus) {
         Object node = null;
         super.getTreeCellRendererComponent(
    tree, value, selected,
    expanded, leaf, row,
    hasFocus);
         TreePath treePath = tree.getPathForRow(row);
    if(treePath != null)
              node = treePath.getLastPathComponent();
    currRow = row;
    m_selected = selected;
    DefaultMutableTreeNode itc = null;
    if (node instanceof DefaultMutableTreeNode) {
    itc = (DefaultMutableTreeNode)node;
         setClosedIcon(closedIcon);
    setOpenIcon(openIcon);
    return this;
    /* Override the default to send back different strings for folders and leaves. */
    public String getToolTipText() {
    return tipText;
    * Paints the value. The background is filled based on selected.
    public void paint(Graphics g) {
         super.paint(g);
         Color bColor = null;
         if(!m_selected) {
              System.out.println(" iconren not sel currRow " + currRow);
              if(currRow % 2 == 0) {
                   bColor = Color.WHITE;
              } else {
              bColor = backColor;
         } else {
              bColor = table.getSelectionBackground();
              System.out.println("in else selbg = " + bColor);           
              bColor = new Color(0xF0, 0xCC, 0x92);
              System.out.println(" bColor aft = " + bColor);           
         int imageOffset = -1;
         if(bColor != null) {
         imageOffset = getLabelStart();
         g.setColor(bColor);
         if(!m_selected) {
              System.out.println(" not sel setting white ");
              g.setXORMode(new Color(0xFF, 0xFF, 0xFF));
         } else {
    //          g.setXORMode(new Color(0xCC, 0xCC, 0x9F));
              g.setXORMode(new Color(0x00, 0x00, 0x00));
              System.out.println(" using color = " + g.getColor());           
         if(getComponentOrientation().isLeftToRight()) {
         g.fillRect(imageOffset, 0, getWidth() - 1 - imageOffset,
                   getHeight());
         } else {
         g.fillRect(0, 0, getWidth() - 1 - imageOffset,
                   getHeight());
    private int getLabelStart() {
         Icon currentI = getIcon();
         if(currentI != null && getText() != null) {
         return currentI.getIconWidth() + Math.max(0, getIconTextGap() - 1);
         return 0;
    // IconRenderer.java END
    // IndicatorRenderer.java BEGIN
    // import java.awt.*;
    import javax.swing.*;
    import javax.swing.border.*;
    import javax.swing.event.*;
    import javax.swing.tree.*;
    import javax.swing.table.*;
    import javax.swing.table.*;
    import javax.swing.plaf.basic.*;
    import java.awt.event.*;
    import java.util.EventObject;
    import java.text.NumberFormat;
    import java.util.ArrayList;
    import java.util.HashMap;
    import java.util.StringTokenizer;
    import java.util.Arrays;
    class IndicatorRenderer extends DefaultTableCellRenderer {
    /** Makes sure the number of displayed in an internationalized
    * manner. */
    protected NumberFormat formatter;
    /** Row that is currently being painted. */
    protected int lastRow;
    protected int reloadRow;
    protected int reloadCounter;
    protected TreeTableModel treeTableModel;
    protected TreeTableModelAdapter treeTblAdapter;
    protected JTable table;
    Component renderer = null;
    Color backColor = new Color(0xF0, 0xF0, 0xE0);
    IndicatorRenderer(TreeTableModelAdapter treeTblAdapter, TreeTableModel treeTableModel) {
         setHorizontalAlignment(JLabel.RIGHT);
         setFont(new Font("serif", Font.BOLD, 12));
         this.treeTableModel = treeTableModel;
         this.treeTblAdapter = treeTblAdapter;
    * Invoked as part of DefaultTableCellRenderers implemention. Sets
    * the text of the label.
    public void setValue(Object value) {
    /* setText((value == null) ? "---" : formatter.format(value)); */
         setText((value == null) ? "---" : (String) value.toString());
    * Returns this.
    public Component getTableCellRendererComponent(JTable table,
    Object value, boolean isSelected, boolean hasFocus,
    int row, int column) {
         renderer = super.getTableCellRendererComponent(table, value, isSelected,
    hasFocus, row, column);
         lastRow = row;
         this.table = table;
              if(isSelected) {
                   doMask(hasFocus, isSelected);
              } else
              setBackground(table.getBackground());
    return renderer;
    * If the row being painted is also being reloaded this will draw
    * a little indicator.
    public void paint(Graphics g) {
         super.paint(g);
    private void doMask(boolean hasFocus, boolean selected) {
              maskBackground(hasFocus, selected);
    private void maskBackground(boolean hasFocus, boolean selected) {
              Color seed = null;
              seed = table.getSelectionBackground();
              Color color = seed;
              if (color != null) {
                   setBackground(
    new Color(0xF0, 0xCC, 0x92));
    // IndicatorRenderer.java END
    // JTreeTable.java BEGIN
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.border.*;
    import javax.swing.event.*;
    import javax.swing.tree.*;
    import javax.swing.table.*;
    import java.awt.event.*;
    import java.util.EventObject;
    public class JTreeTable extends JTable {
    /** A subclass of JTree. */
    protected TreeTableCellRenderer tree;
    protected IndicatorRenderer indicatorRenderer = null;
    public JTreeTable(TreeTableModel treeTableModel) {
         super();
         // Creates the tree. It will be used as a renderer and editor.
         tree = new TreeTableCellRenderer(treeTableModel);
         TreeTableModelAdapter tdap = new TreeTableModelAdapter(treeTableModel, tree);
         // Installs a tableModel representing the visible rows in the tree.
         super.setModel(tdap);
         // Forces the JTable and JTree to share their row selection models.
         ListToTreeSelectionModelWrapper selectionWrapper = new
         ListToTreeSelectionModelWrapper();
         tree.setSelectionModel(selectionWrapper);
         setSelectionModel(selectionWrapper.getListSelectionModel());
         // Installs the tree editor renderer and editor.
         setDefaultRenderer(TreeTableModel.class, tree);
         setDefaultEditor(TreeTableModel.class, new TreeTableCellEditor());
         indicatorRenderer = new IndicatorRenderer(tdap, treeTableModel);     
         // No grid.
         setShowGrid(false);
         // No intercell spacing
         setIntercellSpacing(new Dimension(0, 0));     
         // And update the height of the trees row to match that of
         // the table.
         //if (tree.getRowHeight() < 1) {
         // Metal looks better like this.
         setRowHeight(20);
    public TableCellRenderer getCellRenderer(int row, int col) {
              if(col == 0)
              return tree;
              else
              return indicatorRenderer;     
    public void updateUI() {
         super.updateUI();
         if(tree != null) {
         tree.updateUI();
         // Do this so that the editor is referencing the current renderer
         // from the tree. The renderer can potentially change each time
         // laf changes.
         setDefaultEditor(TreeTableModel.class, new TreeTableCellEditor());
         // Use the tree's default foreground and background colors in the
         // table.
    LookAndFeel.installColorsAndFont(this, "Tree.background",
    "Tree.foreground", "Tree.font");
    public int getEditingRow() {
    return (getColumnClass(editingColumn) == TreeTableModel.class) ? -1 :
         editingRow;
    private int realEditingRow() {
         return editingRow;
    public void sizeColumnsToFit(int resizingColumn) {
         super.sizeColumnsToFit(resizingColumn);
         if (getEditingColumn() != -1 && getColumnClass(editingColumn) ==
         TreeTableModel.class) {
         Rectangle cellRect = getCellRect(realEditingRow(),
                             getEditingColumn(), false);
    Component component = getEditorComponent();
         component.setBounds(cellRect);
    component.validate();
    public void setRowHeight(int rowHeight) {
    super.setRowHeight(rowHeight);
         if (tree != null && tree.getRowHeight() != rowHeight) {
    tree.setRowHeight(getRowHeight());
    public JTree getTree() {
         return tree;
    public boolean editCellAt(int row, int column, EventObject e){
         boolean retValue = super.editCellAt(row, column, e);
         if (retValue && getColumnClass(column) == TreeTableModel.class) {
         repaint(getCellRect(row, column, false));
         return retValue;
    public class TreeTableCellRenderer extends JTree implements
         TableCellRenderer {
         /** Last table/tree row asked to renderer. */
         protected int visibleRow;
         /** Border to draw around the tree, if this is non-null, it will
         * be painted. */
         protected Border highlightBorder;
         public TreeTableCellRenderer(Tr

  • JTree selection problem when using custom renderer and editor

    Hello:
    I created a JTree with custom renderer and editor.
    The customization makes JCheckBox to be the component
    responsible for editing and rendering.
    The problem is that when I click on the node with the checkbox
    the JTree selection model does not get updated.
    Without customizations of the editor and renderer the MouseEvent would be fired and BasicTreeUI$MouseHandler.mousePressed() method would call
    the selectPathForEvent() method which would be responsible for updating
    the selection model. At the same time if I attach a mouse listener to the JTree (customized) I see the events when clicking on the nodes. It seems like the MouseEvent gets lost and somehow as a result of which the selection model does not get updated.
    Am I missing something?
    Thanks
    Alexander

    You probably forgot to call super.getTreeCellRendererComponent(...) at the beginning of your getTreeCellRendererComponent(...) method in your custom renderer.
    Or maybe in the getTreeCellEditorComponent(...) of the TreeCellEditor...

  • Jtree cutom renderer and buttons

    I am trying something new in a jtree and have no idea where to start
    I have written a custom renderer that is a panel
    In this panel I have an Icon and some text (both labels) and 2 buttons (up and down)
    The renderer looks pretty but does nothing
    Is there any way I can make it so that when the up button is pressed the tree will move this node up and when the down button is pressed it moves the node down.
    Hope someone can help

    JTable JTrees and components that use renderers do not paste the renderer component at the desired location but only paint their picture . That means the place where u r expecting ur JPanel is occupied by its image .
    Now what u need to do will be
    1. Handle the mouse click on the component which has ur renders .
    2. use the mouse clicks to find out the component on which the mouse was clicked
    3. take appropriate action
    may be i'll post u an example in short while ..
    try ur luck

  • Bugs: open new doc, custom XMP panel crash

    When opening a new document after starting Photoshop, it appears with half a checkboard pattern:
    Drawing on it looks like below:
    I also had an issue where I closed the doc (without saving) after drawing, then opened a new doc. The previous drawing then appeared partially twice (large, and a small version in top left corner) in the new doc, this only happened once though.
    I added a custom XMP panel that works fine with CS5 to $user-dir\AppData\Roaming\Adobe\XMP\Custom File Info Panels\4.0\panels
    On selecting the custom panel, in the File Info window, the panel window / CS6 crashes. (The grey window in the sshot below is an imprint of the irfanview settings I used to take these screenshots, this imprinting behaviour (not sure if it has a proper name) is reasonably common with crashed programs).
    I am using the 64 bit version on Windows 7 business 64. 8GB RAM, Sys info from PS CS6 below:
    Adobe Photoshop Version: 13.0 (13.0 20120305.m.415 2012/03/05:21:00:00) x64
    Operating System: Windows 7 64-bit
    Version: 6.1 Service Pack 1
    System architecture: Intel CPU Family:6, Model:15, Stepping:6 with MMX, SSE Integer, SSE FP, SSE2, SSE3
    Physical processor count: 2
    Processor speed: 2666 MHz
    Built-in memory: 8191 MB
    Free memory: 4745 MB
    Memory available to Photoshop: 7256 MB
    Memory used by Photoshop: 60 %
    Image tile size: 128K
    Image cache levels: 4
    OpenGL Drawing: Enabled.
    OpenGL Drawing Mode: Advanced
    OpenGL Allow Normal Mode: True.
    OpenGL Allow Advanced Mode: True.
    OpenGL Allow Old GPUs: Not Detected.
    Video Card Vendor: NVIDIA Corporation
    Video Card Renderer: GeForce GT 240/PCIe/SSE2
    Display: 1
    Display Bounds:=  top: 0, left: 0, bottom: 960, right: 1280
    Video Card Number: 1
    Video Card: NVIDIA GeForce GT 240
    OpenCL Unavailable
    Driver Version: 8.17.12.9610
    Driver Date: 20120229000000.000000-000
    Video Card Driver: nvd3dumx.dll,nvwgf2umx.dll,nvwgf2umx.dll,nvd3dum,nvwgf2um,nvwgf2um
    Video Mode: 1280 x 960 x 4294967296 colors
    Video Card Caption: NVIDIA GeForce GT 240
    Video Card Memory: 512 MB
    Video Rect Texture Size: 8192
    Serial number: Tryout Version
    Application folder: C:\Program Files\Adobe\Adobe Photoshop CS6 (64 Bit)\
    Temporary file path: C:\Users\Rusty\AppData\Local\Temp\
    Photoshop scratch has async I/O enabled
    Scratch volume(s):
      Startup, 136.7G, 48.9G free
    Required Plug-ins folder: C:\Program Files\Adobe\Adobe Photoshop CS6 (64 Bit)\Required\
    Primary Plug-ins folder: C:\Program Files\Adobe\Adobe Photoshop CS6 (64 Bit)\Plug-ins\
    Additional Plug-ins folder: not set
    Installed components:
       A3DLIBS.dll   A3DLIB Dynamic Link Library   9.2.0.112  
       ACE.dll   ACE 2012/01/18-15:07:40   66.492997   66.492997
       adbeape.dll   Adobe APE 2012/01/25-10:04:55   66.1025012   66.1025012
       AdobeLinguistic.dll   Adobe Linguisitc Library   6.0.0  
       AdobeOwl.dll   Adobe Owl 2012/02/09-16:00:02   4.0.93   66.496052
       AdobePDFL.dll   PDFL 2011/12/12-16:12:37   66.419471   66.419471
       AdobePIP.dll   Adobe Product Improvement Program   6.0.0.1642  
       AdobeXMP.dll   Adobe XMP Core 2012/02/06-14:56:27   66.145661   66.145661
       AdobeXMPFiles.dll   Adobe XMP Files 2012/02/06-14:56:27   66.145661   66.145661
       AdobeXMPScript.dll   Adobe XMP Script 2012/02/06-14:56:27   66.145661   66.145661
       adobe_caps.dll   Adobe CAPS   5,0,10,0  
       AGM.dll   AGM 2012/01/18-15:07:40   66.492997   66.492997
       ahclient.dll    AdobeHelp Dynamic Link Library   1,7,0,56  
       aif_core.dll   AIF   3.0   62.490293
       aif_ocl.dll   AIF   3.0   62.490293
       aif_ogl.dll   AIF   3.0   62.490293
       amtlib.dll   AMTLib (64 Bit)   6.0.0.75 (BuildVersion: 6.0; BuildDate: Mon Jan 16 2012 18:00:00)   1.000000
       ARE.dll   ARE 2012/01/18-15:07:40   66.492997   66.492997
       AXE8SharedExpat.dll   AXE8SharedExpat 2011/12/16-15:10:49   66.26830   66.26830
       AXEDOMCore.dll   AXEDOMCore 2011/12/16-15:10:49   66.26830   66.26830
       Bib.dll   BIB 2012/01/18-15:07:40   66.492997   66.492997
       BIBUtils.dll   BIBUtils 2012/01/18-15:07:40   66.492997   66.492997
       boost_date_time.dll   DVA Product   6.0.0  
       boost_signals.dll   DVA Product   6.0.0  
       boost_system.dll   DVA Product   6.0.0  
       boost_threads.dll   DVA Product   6.0.0  
       cg.dll   NVIDIA Cg Runtime   3.0.00007  
       cgGL.dll   NVIDIA Cg Runtime   3.0.00007  
       CIT.dll   Adobe CIT   2.0.5.19287   2.0.5.19287
       CoolType.dll   CoolType 2012/01/18-15:07:40   66.492997   66.492997
       data_flow.dll   AIF   3.0   62.490293
       dvaaudiodevice.dll   DVA Product   6.0.0  
       dvacore.dll   DVA Product   6.0.0  
       dvamarshal.dll   DVA Product   6.0.0  
       dvamediatypes.dll   DVA Product   6.0.0  
       dvaplayer.dll   DVA Product   6.0.0  
       dvatransport.dll   DVA Product   6.0.0  
       dvaunittesting.dll   DVA Product   6.0.0  
       dynamiclink.dll   DVA Product   6.0.0  
       ExtendScript.dll   ExtendScript 2011/12/14-15:08:46   66.490082   66.490082
       FileInfo.dll   Adobe XMP FileInfo 2012/01/17-15:11:19   66.145433   66.145433
       filter_graph.dll   AIF   3.0   62.490293
       hydra_filters.dll   AIF   3.0   62.490293
       icucnv40.dll   International Components for Unicode 2011/11/15-16:30:22    Build gtlib_3.0.16615  
       icudt40.dll   International Components for Unicode 2011/11/15-16:30:22    Build gtlib_3.0.16615  
       image_compiler.dll   AIF   3.0   62.490293
       image_flow.dll   AIF   3.0   62.490293
       image_runtime.dll   AIF   3.0   62.490293
       JP2KLib.dll   JP2KLib 2011/12/12-16:12:37   66.236923   66.236923
       libifcoremd.dll   Intel(r) Visual Fortran Compiler   10.0 (Update A)  
       libmmd.dll   Intel(r) C Compiler, Intel(r) C++ Compiler, Intel(r) Fortran Compiler   10.0  
       LogSession.dll   LogSession   2.1.2.1640  
       mediacoreif.dll   DVA Product   6.0.0  
       MPS.dll   MPS 2012/02/03-10:33:13   66.495174   66.495174
       msvcm80.dll   Microsoft® Visual Studio® 2005   8.00.50727.6195  
       msvcm90.dll   Microsoft® Visual Studio® 2008   9.00.30729.1  
       msvcp100.dll   Microsoft® Visual Studio® 2010   10.00.40219.1  
       msvcp80.dll   Microsoft® Visual Studio® 2005   8.00.50727.6195  
       msvcp90.dll   Microsoft® Visual Studio® 2008   9.00.30729.1  
       msvcr100.dll   Microsoft® Visual Studio® 2010   10.00.40219.1  
       msvcr80.dll   Microsoft® Visual Studio® 2005   8.00.50727.6195  
       msvcr90.dll   Microsoft® Visual Studio® 2008   9.00.30729.1  
       pdfsettings.dll   Adobe PDFSettings   1.04  
       Photoshop.dll   Adobe Photoshop CS6   CS6  
       Plugin.dll   Adobe Photoshop CS6   CS6  
       PlugPlug.dll   Adobe(R) CSXS PlugPlug Standard Dll (64 bit)   3.0.0.383  
       PSArt.dll   Adobe Photoshop CS6   CS6  
       PSViews.dll   Adobe Photoshop CS6   CS6  
       SCCore.dll   ScCore 2011/12/14-15:08:46   66.490082   66.490082
       ScriptUIFlex.dll   ScriptUIFlex 2011/12/14-15:08:46   66.490082   66.490082
       tbb.dll   Intel(R) Threading Building Blocks for Windows   3, 0, 2010, 0406  
       tbbmalloc.dll   Intel(R) Threading Building Blocks for Windows   3, 0, 2010, 0406  
       TfFontMgr.dll   FontMgr   9.3.0.113  
       TfKernel.dll   Kernel   9.3.0.113  
       TFKGEOM.dll   Kernel Geom   9.3.0.113  
       TFUGEOM.dll   Adobe, UGeom©   9.3.0.113  
       updaternotifications.dll   Adobe Updater Notifications Library   6.0.0.24 (BuildVersion: 1.0; BuildDate: BUILDDATETIME)   6.0.0.24
       WRServices.dll   WRServices Friday January 27 2012 13:22:12   Build 0.17112   0.17112
       wu3d.dll   U3D Writer   9.3.0.113  
    Required plug-ins:
       3D Studio 13.0 (13.0 20120305.m.415 2012/03/05:21:00:00)
       Accented Edges 13.0
       Adaptive Wide Angle 13.0
       ADM 3.11x01
       Angled Strokes 13.0
       Average 13.0 (13.0 20120305.m.415 2012/03/05:21:00:00)
       Bas Relief 13.0
       BMP 13.0
       Camera Raw 7.0
       Chalk & Charcoal 13.0
       Charcoal 13.0
       Chrome 13.0
       Cineon 13.0 (13.0 20120305.m.415 2012/03/05:21:00:00)
       Clouds 13.0 (13.0 20120305.m.415 2012/03/05:21:00:00)
       Collada 13.0 (13.0 20120305.m.415 2012/03/05:21:00:00)
       Color Halftone 13.0
       Colored Pencil 13.0
       CompuServe GIF 13.0
       Conté Crayon 13.0
       Craquelure 13.0
       Crop and Straighten Photos 13.0 (13.0 20120305.m.415 2012/03/05:21:00:00)
       Crop and Straighten Photos Filter 13.0
       Crosshatch 13.0
       Crystallize 13.0
       Cutout 13.0
       Dark Strokes 13.0
       De-Interlace 13.0
       Dicom 13.0
       Difference Clouds 13.0 (13.0 20120305.m.415 2012/03/05:21:00:00)
       Diffuse Glow 13.0
       Displace 13.0
       Dry Brush 13.0
       Eazel Acquire 13.0 (13.0 20120305.m.415 2012/03/05:21:00:00)
       Embed Watermark 4.0
       Entropy 13.0 (13.0 20120305.m.415 2012/03/05:21:00:00)
       Extrude 13.0
       FastCore Routines 13.0 (13.0 20120305.m.415 2012/03/05:21:00:00)
       Fibers 13.0
       Film Grain 13.0
       Filter Gallery 13.0
       Flash 3D 13.0 (13.0 20120305.m.415 2012/03/05:21:00:00)
       Fresco 13.0
       Glass 13.0
       Glowing Edges 13.0
       Google Earth 4 13.0 (13.0 20120305.m.415 2012/03/05:21:00:00)
       Grain 13.0
       Graphic Pen 13.0
       Halftone Pattern 13.0
       HDRMergeUI 13.0
       IFF Format 13.0
       Ink Outlines 13.0
       JPEG 2000 13.0
       Kurtosis 13.0 (13.0 20120305.m.415 2012/03/05:21:00:00)
       Lens Blur 13.0
       Lens Correction 13.0
       Lens Flare 13.0
       Liquify 13.0
       Matlab Operation 13.0 (13.0 20120305.m.415 2012/03/05:21:00:00)
       Maximum 13.0 (13.0 20120305.m.415 2012/03/05:21:00:00)
       Mean 13.0 (13.0 20120305.m.415 2012/03/05:21:00:00)
       Measurement Core 13.0 (13.0 20120305.m.415 2012/03/05:21:00:00)
       Median 13.0 (13.0 20120305.m.415 2012/03/05:21:00:00)
       Mezzotint 13.0
       Minimum 13.0 (13.0 20120305.m.415 2012/03/05:21:00:00)
       MMXCore Routines 13.0 (13.0 20120305.m.415 2012/03/05:21:00:00)
       Mosaic Tiles 13.0
       Multiprocessor Support 13.0 (13.0 20120305.m.415 2012/03/05:21:00:00)
       Neon Glow 13.0
       Note Paper 13.0
       NTSC Colors 13.0 (13.0 20120305.m.415 2012/03/05:21:00:00)
       Ocean Ripple 13.0
       Oil Paint 13.0
       OpenEXR 13.0
       Paint Daubs 13.0
       Palette Knife 13.0
       Patchwork 13.0
       Paths to Illustrator 13.0
       PCX 13.0 (13.0 20120305.m.415 2012/03/05:21:00:00)
       Photocopy 13.0
       Photoshop 3D Engine 13.0 (13.0 20120305.m.415 2012/03/05:21:00:00)
       Picture Package Filter 13.0 (13.0 20120305.m.415 2012/03/05:21:00:00)
       Pinch 13.0
       Pixar 13.0 (13.0 20120305.m.415 2012/03/05:21:00:00)
       Plaster 13.0
       Plastic Wrap 13.0
       PNG 13.0
       Pointillize 13.0
       Polar Coordinates 13.0
       Portable Bit Map 13.0 (13.0 20120305.m.415 2012/03/05:21:00:00)
       Poster Edges 13.0
       Radial Blur 13.0
       Radiance 13.0 (13.0 20120305.m.415 2012/03/05:21:00:00)
       Range 13.0 (13.0 20120305.m.415 2012/03/05:21:00:00)
       Read Watermark 4.0
       Reticulation 13.0
       Ripple 13.0
       Rough Pastels 13.0
       Save for Web 13.0
       ScriptingSupport 13.0
       Shear 13.0
       Skewness 13.0 (13.0 20120305.m.415 2012/03/05:21:00:00)
       Smart Blur 13.0
       Smudge Stick 13.0
       Solarize 13.0 (13.0 20120305.m.415 2012/03/05:21:00:00)
       Spatter 13.0
       Spherize 13.0
       Sponge 13.0
       Sprayed Strokes 13.0
       Stained Glass 13.0
       Stamp 13.0
       Standard Deviation 13.0 (13.0 20120305.m.415 2012/03/05:21:00:00)
       Sumi-e 13.0
       Summation 13.0 (13.0 20120305.m.415 2012/03/05:21:00:00)
       Targa 13.0
       Texturizer 13.0
       Tiles 13.0
       Torn Edges 13.0
       Twirl 13.0
       U3D 13.0 (13.0 20120305.m.415 2012/03/05:21:00:00)
       Underpainting 13.0
       Vanishing Point 13.0
       Variance 13.0 (13.0 20120305.m.415 2012/03/05:21:00:00)
       Variations 13.0 (13.0 20120305.m.415 2012/03/05:21:00:00)
       Water Paper 13.0
       Watercolor 13.0
       Wave 13.0
       Wavefront|OBJ 13.0 (13.0 20120305.m.415 2012/03/05:21:00:00)
       WIA Support 13.0 (13.0 20120305.m.415 2012/03/05:21:00:00)
       Wind 13.0
       Wireless Bitmap 13.0 (13.0 20120305.m.415 2012/03/05:21:00:00)
       ZigZag 13.0
    Optional and third party plug-ins: NONE
    Plug-ins that failed to load: NONE
    Flash:
       Mini Bridge
       Kuler
    Installed TWAIN devices: NONE

    According to Nvidia's website, I already have the latest drivers installed (I updated them just a few days ago). I turned off hardware acceleration as you suggested, and that fixed the problem.
    You can download the XMP panel that causes the crash from: http://www.iliveinabin.com/image-xmpPanel%20v2.zip That contains the source for the panel and also the compiled panel I'm using, which is in the target folder.

  • JTree Custom TreeCellRenderer problem on Mac OS + Firefox

    Hi,
    I have a JApplet containing a JTree component with custom renderer that implements TreeCellRenderer to display CheckBox along the tree nodes.
    Everything works fine on Window and Linux OS (firefox browser)
    Problem is with :
    Firefox + Mac: applet fails to load because getTreeCellRendererComponent() does not seem to get invoked.
    Appreciate you time and thoughts on the problem.
    Edited by: rg18mar on Nov 27, 2007 10:31 PM

    Our only other environment we could set up was on Mac OS 10.7.5, and we could not reproduce the issue.  Based on that it would appear to be something new with Mac OS 10.8.

  • Using a repeater in a custom FileInfo Panel --data binding error

    When I developed a custom FileInfo panel in Flex Builder 3, I could use an array to populate a checkBox control inside a repeater, and it worked.
    Now, using Flash Builder 4, data binding with <mx:Repeater> doesn't seem to work, resulting in an empty fileInfo panel.
    When I remove the dataProvider from the <mx:Repeater> tag, my panel displays, but without the repeater. How can I specify the dataProvider in a different way that works?
    Thanks
    The code:
    <fi:XMPForm
              xmlns:mx="http://www.adobe.com/2006/mxml"
              xmlns:fi="com.adobe.xmp.components.*" width="100%" height="100%"
              label="TestPanel2_1" xmlns:s="library://ns.adobe.com/flex/spark" >
         <!-- Each namespace prefix that is used within an xmpPath-attribute,
              MUST BE registered at the top of EACH panel where it is referenced -->
         <fi:XMPNamespaces>
              <fi:XMPNamespace prefix="dc" value="http://purl.org/dc/elements/1.1/"/>
         </fi:XMPNamespaces>
         <mx:Script>
              <![CDATA[
                   import mx.collections.ArrayCollection;
                   [Bindable] public var newArray:Array =["One", "Two", "Three", "Four", "Five"];         
              ]]>
         </mx:Script>
         <fi:XMPFormItem>
              <mx:VBox id="primaryFrame" width="800">    
                   <mx:Repeater id="myRep" dataProvider="{newArray}">
                        <mx:Label text="{myRep.currentItem}"/>                  
                   </mx:Repeater>
              </mx:VBox>
         </fi:XMPFormItem
    </fir:XMPForm>

    Okay, I may have been making a rookie mistake. I see online reports that you can't bind an array to a repeater (even though it has worked for me).
    I've added the following variable to make my array an array collection:
    [Bindable] public var newArray2:ArrayCollection = new ArrayCollection(newArray);
    After changing the binding of the repeater to the new array and running the build, the fileInfo panel still does not function.
    Any thoughts?

  • Jtable custom renderer

    how to set or create custom renderer for a Jtable ?.. i want have following components in each cell of jtable.
    1)checkbox
    2)icon
    3)combobox
    i know how to render these components for Jtree, but i didn't get any method like setCellRendere() for Jtable.
    plz help !!

    You can use the both:
    JTable method:
    +Sets a default cell renderer to be used if no renderer has been set in a TableColumn.+
    public void setDefaultRenderer(Class<?> columnClass, TableCellRenderer renderer)TableColumn method:
    +Sets the TableCellRenderer used by JTable to draw individual values for this column.+
    public void setCellRenderer(TableCellRenderer cellRenderer)

  • h:form in customized rendering of jsps

    But i am facing another problem.
    i am rendering two jsp pages
    index.jsp<-1.jsp
    <- 2.jsp
    (rendering the two pages based on selection in tabbedpane custom component)
    I have a <h:form> tag with unique ID in index.jsp .
    I have my custom tabbedpane component in it.
    Now using this component i am calling other two pages and renderering them in the same component's workspace.
    When i use another <h:form> tag in either of the 1.jsp or 2.jsp the tabs work for only one time.

    As in a Standard Shell i have header,footer, navigation area ,workspace area.
    I am making a custom tabbedPane component that controls both navigation and workspace area simultaneously.
    Also the url that i return ,is being rendered by method
    getRequestDispatcher(display).include(request, response);
    <html>
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
    <%@ taglib uri="http://corejsf.com/tabbedpane" prefix="corejsf"%>
    <f:loadBundle basename="com.corejsf.messages" var="msgs" />
    <f:view>
         <head>
         <link href="css/styles.css" rel="stylesheet" type="text/css" />
         <title><h:outputText value="#{msgs.windowTitle}" /></title>
         </head>
         <body>
         <h:form>
         <f:subview id="tabbedpane">
                   <corejsf:tabbedPane resourceBundle="com.corejsf.messages">
                        <corejsf:select label="polarBears"
                             default_workspace="/polarBears.jsp" navigation="/bears_nav.jsp" />
                        <corejsf:select label="grizzlyBears"
                             default_workspace="/grizzlyBears.jsp" navigation="/bears_nav.jsp" />
                        <corejsf:select label="teddyBears"
                             default_workspace="/teddyBears.jsp" navigation="/bears_nav.jsp" />
                        <corejsf:select label="pandaBears"
                             default_workspace="/pandaBears.jsp" navigation="/bears_nav.jsp" />
                        <corejsf:select label="blackBears"
                             default_workspace="/blackBears.jsp" navigation="/bears_nav.jsp" />
                   </corejsf:tabbedPane>
         </f:subview>
         </h:form>
         </body>
    </f:view>
    </html>
    now this pages which i am rendering ,if they contain <h:form> tag even with distinct ID --the component works for only one time .                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Help! Using a custom renderer to display an image

    I have a JTable where I want to set the renderer of one column to a custom renderer. And I want this renderer to show either a play button image, or a stop button image, depending on the status, which is a Boolean value. However, the image won't show up when I run the application. Here's the code from the renderer...
    public class StatusRenderer extends DefaultTableCellRenderer {
    private ImageIcon playIcon = new ImageIcon("C:/play.jpg");
    private ImageIcon stopIcon = new ImageIcon("C:/stop.jpg");
    public StatusRenderer() {
    setHorizontalAlignment(JLabel.CENTER);
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col) {
    Boolean b = (Boolean) value;
    setIcon(b.booleanValue() ? playIcon : stopIcon);
    return this;
    The application runs, but no icon shows up in the table cell. I'd really appreciate any help on this. Thanks.

    look at http://www2.gol.com/users/tame/swing/examples/JTableExamples1.html
    for some great table examples (they may need minor mods to work on 1.3/1.4)
    Basically I think you need something more like:
    public class StatusRenderer extends JLabel
      implements DefaultTableCellRenderer
        public StatusRenderer() {
            super();
            setHorizontalAlignment(JLabel.CENTER);
        public Component getTableCellRendererComponent(JTable table,
                                           Object value, boolean sSelected,
                                           boolean hasFocus, int row,
                                           int col)
            Boolean b = (Boolean) value;
            setIcon(b.booleanValue() ? playIcon : stopIcon);
            return this;
    }Don't forget to add the renderer to the column you want it in !

  • '...' not appearing in obscured table cell when using custom renderer.

    Hello all -
    I am using a custom JPanel as a cell renderer in a JTable to display two icons per cell. Unfortunately, I am running into a problem that occurs when resizing a column such that the width of the column is less than the size of the cell content. Normally, when resizing a cell in this manner, it will start to cut off the text within the cell and add '...' to signify that some material is obscured. However, using my cell renderer, the text simply cuts off with no indication whatsoever there is more content that is being hidden. I have tried looking through the JComponent code to find a function to overload but I haven't had much luck. Does anyone have any suggestions?
    For a simple example, compile and run the following code and try resizing the two columns. You should be able to notice the difference.
    Thanks,
    - Alex
    import java.awt.*;
    import java.awt.image.*;
    import java.util.*;
    import javax.swing.*;
    import javax.swing.table.*;
    public class TwoIcons extends JFrame {
         public static void main(String[] args){
              createIcons();
              SwingUtilities.invokeLater
                   new Runnable()
                        public void run() {
                             new TwoIcons();
         public TwoIcons(){
              super("Test");
              DefaultTableModel tm = new DefaultTableModel(
                   new Object[][]{
                        {new IconPair("cross", "cross"), "just a string"},
                        {new IconPair("circle", "cross"),"just another string"},
                        {new IconPair("String", "circle"),"yet another string"}
                   }, new String[]{"Two Icons","String"}){
                   public Class getColumnClass(int columnIndex){
                        if(columnIndex==0){
                             return IconPair.class;
                        else
                             return super.getColumnClass(columnIndex);
              JTable table = new JTable(tm);
              final Color bg = table.getBackground();
              table.setDefaultRenderer(IconPair.class, new TableCellRenderer(){
                        RendererPanel renderer = new RendererPanel(bg);
                        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
                             renderer.setIcons((IconPair)value);
                             return  renderer;
              JScrollPane scp = new JScrollPane(table);
              add(scp);
              setSize(400,100);
              setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              pack();
              setVisible(true);
         class RendererPanel extends JPanel{
              JLabel icon1, icon2;
              RendererPanel(Color bg){
                   setLayout(new BoxLayout(this,BoxLayout.LINE_AXIS) );
                   icon1=new JLabel();
                   icon2=new JLabel();
                   add(icon1);
                   add(icon2);
                   setBackground(bg);
              public void setIcons(IconPair value) {
                   icon1.setIcon(value.i1);
                   icon1.setToolTipText("Icon 1");
                   icon2.setIcon(value.i2);
                   icon2.setToolTipText("Icon 2");
                   //uncomment next 2 lines if you want text as well
                   icon1.setText(value.s1);
                   icon2.setText(value.s2);
         class IconPair {
              public Icon i1,i2;
              public String s1,s2;
              IconPair(String s1, String s2){
                   this.i1=(Icon)icons.get(s1);
                   this.i2=(Icon)icons.get(s2);
                   this.s1=s1;
                   this.s2=s2;
         static Map icons = new HashMap();
         public static  void createIcons(){
              Image img = new BufferedImage(10,10, BufferedImage.TYPE_INT_ARGB);
              Graphics2D g2=(Graphics2D)(img.getGraphics());
              g2.setColor(Color.BLUE);
              g2.drawLine(0,0,10,10);
              g2.drawLine(0,10,10,0);
              icons.put("cross",new ImageIcon(img));
              img = new BufferedImage(10,10, BufferedImage.TYPE_INT_ARGB);
              g2=(Graphics2D)(img.getGraphics());
              g2.setColor(Color.ORANGE);
              g2.drawOval(1,1,8,8);
              icons.put("circle",new ImageIcon(img));
    }

    Things aren't resizable in your layout for the custom renderer. Here's your code working as you want (I think)
    import java.awt.*;
    import java.awt.image.*;
    import java.util.*;
    import javax.swing.*;
    import javax.swing.table.*;
    public class TwoIcons extends JFrame {
         public static void main(String[] args){
              createIcons();
              SwingUtilities.invokeLater
                   new Runnable()
                        public void run() {
                             new TwoIcons();
         public TwoIcons(){
              super("Test");
              DefaultTableModel tm = new DefaultTableModel(
                   new Object[][]{
                        {new IconPair("cross", "cross"), "just a string"},
                        {new IconPair("circle", "cross"),"just another string"},
                        {new IconPair("String", "circle"),"yet another string"}
                   }, new String[]{"Two Icons","String"}){
                   public Class getColumnClass(int columnIndex){
                        if(columnIndex==0){
                             return IconPair.class;
                        else
                             return super.getColumnClass(columnIndex);
              JTable table = new JTable(tm);
              final Color bg = table.getBackground();
              table.setDefaultRenderer(IconPair.class, new TableCellRenderer(){
                        RendererPanel renderer = new RendererPanel(bg);
                        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
                             renderer.setIcons((IconPair)value);
                             return  renderer;
              JScrollPane scp = new JScrollPane(table);
              getContentPane().add(scp);
              setSize(400,100);
              setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              pack();
              setVisible(true);
         class RendererPanel extends JPanel{
              JLabel icon1, icon2;
              RendererPanel(Color bg){
                   setLayout(new BoxLayout(this,BoxLayout.LINE_AXIS) );
                   icon1=new JLabel();
                   icon2=new JLabel();
                   add(icon1);
                   add(icon2);
                   icon1.setMinimumSize(new Dimension(0, 0));
                   icon2.setMinimumSize(new Dimension(0, 0));
                   icon1.setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));
                   icon2.setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));
                   setBackground(bg);
              public void setIcons(IconPair value) {
                   icon1.setIcon(value.i1);
                   icon1.setToolTipText("Icon 1");
                   icon2.setIcon(value.i2);
                   icon2.setToolTipText("Icon 2");
                   //uncomment next 2 lines if you want text as well
                   icon1.setText(value.s1);
                   icon2.setText(value.s2);
         class IconPair {
              public Icon i1,i2;
              public String s1,s2;
              IconPair(String s1, String s2){
                   this.i1=(Icon)icons.get(s1);
                   this.i2=(Icon)icons.get(s2);
                   this.s1=s1;
                   this.s2=s2;
         static Map icons = new HashMap();
         public static  void createIcons(){
              Image img = new BufferedImage(10,10, BufferedImage.TYPE_INT_ARGB);
              Graphics2D g2=(Graphics2D)(img.getGraphics());
              g2.setColor(Color.BLUE);
              g2.drawLine(0,0,10,10);
              g2.drawLine(0,10,10,0);
              icons.put("cross",new ImageIcon(img));
              img = new BufferedImage(10,10, BufferedImage.TYPE_INT_ARGB);
              g2=(Graphics2D)(img.getGraphics());
              g2.setColor(Color.ORANGE);
              g2.drawOval(1,1,8,8);
              icons.put("circle",new ImageIcon(img));
    }Note that the ... is a function of the JLabel when it is too small to render its text.

  • Adding a custom rendering extension to SQL Server Reporting Services 2012 for SharePoint 2010 integrated mode

    We are attempting to add OfficeWriter report rendering extensions for SSRS 2012 in SharePoint (2010) integrated mode through powershell. The documentation for “New-SPRSExtension” is rather
    sparse and we have not found any clear examples on the internet. With SSRS 2012 in native mode, we make the following two changes to the config files:
    We add the following report rendering extension declaration to
    RSReportServer.config:
    <Configuration>
        <Extensions>
            <Render>
                <Extension Name="XLTemplate" Type="SoftArtisans.OfficeWriter.ReportingServices.ExcelTemplateRenderer,
    SoftArtisans.OfficeWriter.RS2008"/>
                <Extension Name="WordTemplate" Type="SoftArtisans.OfficeWriter.ReportingServices.WordTemplateRenderer,
    SoftArtisans.OfficeWriter.RS2008"/>
            </Render>
        </Extensions>
    </Configuration>
    We add the following security trust codegroup to
    RSSvrPolicy.config:
    <configuration>
        <mscorlib>
            <security>
                <policy>
                    <PolicyLevel version="1">
                  <CodeGroup version="1" PermissionSetName="Nothing">
                    <CodeGroup
                                version="*"
                                PermissionSetName="FullTrust"
                                Name="SoftArtisans_OfficeWriter_Strong_Name"
                                Description="This
    code group grants SoftArtisans OfficeWriter code full trust.">
                              <IMembershipCondition
                                class="StrongNameMembershipCondition"
                                version="*"
                                PublicKeyBlob="00240000048000009400000006020000002400005253413100040000010001004779CB207F11
                                5E86EF9DD3233F9F130F8891911345176650F72330F84CA3F54C96DEB08439680660F02872EEF5DA3955
                                A14C63F96E57DFB71B1535280C37DA2CB5BA37D78A9882414DB11F67FD66DEBC4AD93DD34F4A587D34D
                                B4D23D9C6AF83431D88A7EF42BB01082913F3560DCB50129C5BBA7ECA0DE8BC286DA74F58FADE"/>
                  </CodeGroup>
              </CodeGroup>
           </PolicyLevel>
        </policy>
       </security>
      </mscorlib>
    </configuration>
    What would be the equivalent syntax for “New-SPRSExtension” to do the above for SSRS 2012 in SharePoint (2010) integrated mode?
    Alison Bird SoftArtisans Technical Services www.softartisans.com

    Hi Alison,
    Unlike the deployment of other custom extensions such as custom delivery extension and data processing extension, it is not necessary to add a code group for the custom assembly that grants FullTrust permission for the extension during the deployment of
    custom rendering extension. If you have copy the custom assembly to the %ProgramFiles%\Microsoft SQL Server\MSRS11.<InstanceName>\Reporting Services\ReportServer\Bin folder, and modify the RSreportserver.config file to add the extention entry properly,
    please open the SSRS Service Application created on the SharePoint and verify that your extension is included in the list of available export types for a report.
    Reference:
    Deploying a Rendering Extension
    Regards,
    Mike Yin
    TechNet Community Support

  • Best Practice : Creating Custom Renderer for Standard Component

    I've been reading the docs and a few threads about Custom Renderers. The best practice seems to be to create a Custom Component where you need a Custom Renderer. Is this the case?
    See [this post|http://forums.sun.com/thread.jspa?forumID=427&threadID=520422]
    I've created several Custom Renderers to override the HTML provided by the Standard Components, however I can't see the benefit in also creating a Custom Component when the behaviour of the standard component is just fine.
    Thanks,
    Damian.

    It all depends on what you are trying to accomplish. Generally speaking if all you need is for the user interface output to be changed then a renderer will work just fine. A new component is usually made in order to provide some fundamental change in server side functionality not related to the user interface. - Ponderator

Maybe you are looking for

  • Does anyone know how to delete Videos from an iPhone 5? iphoto won't do it and the phone provides no option.

    Hi, I keep running out of space on my iphone 5 because there is a bunch of video content on there that I can't get rid of. I imported these videos into iPhoto sometime ago, however I think I probably didn't select to delete them once imported at the

  • Updating a table using cursor is taking long time in oracle

    Hi, I am working on the oracle database 11gR2. I am trying update a table column which is newly added through cursor. below is the cursor. BEGIN      FOR lcur_tab IN (select l.LOGIN_ID as login_id, lt.ERROR_CODE as error_code from LOGIN l INNER JOIN

  • Requisition Import is taking long time to complete

    Hi, I'm working with EBS 11.5.10 CU2, I have Requisition Import program scheduled, usually it's completing normal in around 5minutes; but sometimes it's taking around 30 minutes to complete. I compared the output files of program completing normal an

  • Can't install a downloaded app

    Through Safari, I purchased and downloaded an app from Hallmark.  It downloaded OK into my Downloads folder.  When I clicked on it to install, I got the following message: "xxxxxx.pkg" can't be opened because it is from an unidentified developer.  Yo

  • Need help on configuration in 1:N mapping

    hi experts, i doing idoc to multiple file scenario,.... using 1:N multimapping without BPM... i am following the bolg https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/3115... [original link is broken] [original link is broken] [original link is