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

Similar Messages

  • Need help for JTextPane as JTree node renderer and styling in JTextPane!!!

    hello,
    I have a tree which is loading from database. And in renderer i am using JTextPane. I am putting huge text around 500 words in each node. And this Text is formatting using StyledDocument in JTextPane.
    My problem is tree is taking very long time for loading because of this styleddocument. and also size and space of nodes are not proper. how can i solve this issue.
    here is my renderer code.
    public class TraditionalViewTreeRenderer  implements  TreeCellRenderer
            private JPanel jpRubricName;
            private JTextPane lblRubricName;
            private DefaultTreeCellRenderer defaultRenderer = new DefaultTreeCellRenderer();
            private Color backgroundSelectionColor;
            private Color backgroundNonSelectionColor;
            private FontMetrics fontMetrics;
            public TraditionalViewTreeRenderer(){
                jpRubricName=new JPanel();
                lblRubricName = new JTextPane();
                jpRubricName.add(lblRubricName);
                backgroundSelectionColor    = defaultRenderer.getBackgroundSelectionColor();
                backgroundNonSelectionColor = defaultRenderer.getBackgroundNonSelectionColor();
            @Override
            public Component getTreeCellRendererComponent(JTree tree, Object value,boolean selected,boolean expanded, boolean leaf, int row,boolean hasFocus){
                Component returnVal=null;
                if(value!=null && value instanceof DefaultMutableTreeNode){  
                    Object userObj = ((DefaultMutableTreeNode)value).getUserObject();
                    if(userObj instanceof RubricNode){
                        try {
                            RubricNode node = (RubricNode) userObj;
                            if(node!=null && !node.getRubricName().equalsIgnoreCase("")){
                                if(node.getRemedyList()!=null){
                                    lblRubricName.setText("");
                                    highlightContent(lblRubricName,node.getRemedyList(),node);
    //                                fontMetrics = lblRubricName.getFontMetrics(lblRubricName.getFont());
    //                                int prefHit = fontMetrics.getHeight() * node.getRemedyList().toString().length();
    //                                if(prefHit!=tree.getRowHeight()){
    //                                    lblRubricName.setPreferredSize(new Dimension(Short.MAX_VALUE,prefHit   ) );
    lblRubricName.setPreferredSize(new Dimension(900,getContentHeight(node.getRemedyList().toString())   ) );
                            if (selected) {
                              jpRubricName.setBackground(backgroundSelectionColor);
                            } else {
                              jpRubricName.setBackground(backgroundNonSelectionColor);
                            lblRubricName.validate();
                            jpRubricName.validate();
                            returnVal = jpRubricName;
                            tree.expandRow(row);
                        } catch (Exception ex) {
                            Logger.getLogger(RepertoryTradView.class.getName()).log(Level.SEVERE, null, ex);
    //            if(returnVal==null){
    //                returnVal = defaultRenderer.getTreeCellRendererComponent(tree, value, leaf, expanded, leaf, row, hasFocus);
                return returnVal;
        private void highlightContent(JTextPane comp,List l,RubricNode rubric) throws BadLocationException{
            for(int i=l.size()-1;i>=0;i--){
                comp.getStyledDocument().insertString(0, "., ", ((Remedy)l.get(i)).getRemedyStyle());
                comp.getStyledDocument().insertString(0, l.get(i).toString(), ((Remedy)l.get(i)).getRemedyStyle());
            if(l.size()>0){
                comp.getStyledDocument().insertString(0,rubric.getRubricName()+":",rubric.getRubricStyle());
            }else{
                comp.getStyledDocument().insertString(0,rubric.getRubricName(),rubric.getRubricStyle());
        } Remedy List is the list of 300-500 words..
    see above .. n suggest me something.
    My problem is about the size and spacing of each tree node and insertString() of styled document which is taking huge time to load.

    Main performance issue there is comp.getStyledDocument().insertString(...) calls.
    Each time you call this your comp which listens model updates layout.
    Instead of using the same Document create a new instance of the Document (e.g. by kit.createDefaultDocument()). Pass the newly created document in the method to insert all the content and after the insert completed call comp.setDocument(newDocInstance)
    Also check this http://java-sl.com/JEditorPanePerformance.html

  • 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...

  • Combobox and button renderer

    Hi all,
    I read the documentation about JTables but couldn't figure out how to solve my problem. I want to render combobox and button in the same JTable cell like in Netbeans. How can I do this? Any suggestions?

    Anyone with ideas?

  • 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.

  • What happens to the rendered animated buttons on sub-menus

    I am on a 3GB of memory MacBook Pro using Encore (CS3). Here is a description of how I have produced a working DVD...so far 3 out of 5 DVDs I have tried to render have worked.
    ANYWAY...seems that Encore implodes when I try to render the same project more than one at a time. Encore chokes and I am back in the MAC OS.
    HERE is my main question...every time it blows it seems to blow away the RENDERED ANIMATED BUTTONS on the secondary menu. SO each time I try this again I have to re-render the buttons taking about 1.5 hours. Why do I have to re-render...why aren't the rendered 2nd level menus SAVED.
    To make it clear...after I rendered the menus...previewed...saw the buttons are animated...SAVED...try to write a DVD Disc from the Current Project...succeed...try to burn another DVD...it aborts (why...I have no idea)...I empty trash...bring up Encore again...try to preview the secondary menu...NO ANIMATION there so have to rerender and start all over.
    I have been reading about compatibility of DVD disc, computer players and DVD players...what a PILE...without all the techies our there we can't make a dependable environment to create, burn and play DVDs...these companies should be ashamed...all they are doing is producing a whole bunch of frustrated producers (or lack of producing producers).
    Can anyone shed a light on my problem!?!?
    Thanks, --bill
    p.s. Are there better forums than here at Adobe? Seems I don't get many if any replies to queries.

    Bill,
    A couple of questions, mainly to make sure that I understand what is happening.
    1.) There are two files (an audio and a MOV), that show in the Orphanage, when you Check Project. Do they appear there BEFORE you Check Project, or only AFTER?
    2.) Do they appear BEFORE in your Project Panel, or only AFTER you Check Project?
    3.) Since they are Orphans, I assume that you do not intend to use them in this Project - right? Were they ever in the Project (Imported as Assets, or Timelines)?
    4.) Was this Project started fresh, or did you modify an existing Project, to create it, say using a Save_As, etc.?
    5.) If they were not Imported into this Project, were they Imported into another Project, that is/was being worked on coincidental to this one?
    6.) Can you find these files on your system? Where are they located?
    If 1.) is After and 2.) is After, then your Project might be corrupt. The Assets/Timelines/etc. are linked to the Project by XML. This can become corrupt for many reasons, most are often unknown - power dip, or hardware issue on Save, etc..
    Two ways to check this theory, is to start the Project from scratch, and see what happens. Another is to use a freeware program, XML Wrench, and run the Project file through it. Aside from pointing out broken links, and other problems, it should also allow you to search for these files names in the body. Save a copy of the Project file, so you will have it untouched, and then remove any lines, that reference these files. Save_As (new Project name) and open that in Encore. Being on MAC, doesnt every data file have a finder file, associated with it? Could this finder file be cross-linked, in some way, to your real Assets?
    It could be that there is a hardware issue, and this causes the links to the Rendered files to become broken, and also to link to files, that should not be included. Any other strange things with your system lately? I do not know the MAC folder/file structure, but can you do the equivalent of Windows Check Disk? If so, set it to find lost clusters, or whatever MAC calls them.
    Also, being on PC, I do not know what utilities might be available for your OS, or what other programs might be causing a problem. On PCs, other DVD burning software, especially if their packet-writing applet is installed, can cause havoc with Encore and are discouraged. Anything else installed, and/or running, that you can think of?
    Sorry to play twenty questions, but Id like to be as clear, as I can, on exactly what is happening, before I make too many more guesses.
    Hunt

  • 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

  • Menu and Buttons not showing up!?!

    OK. I was trying to burn a iDVD project on my dual G5 desktop w/iDVD5. I would get "there's an error while rendering". After fiddling with it for a day and getting no where, I switched to my laptop (G4/1.25ghz/10.4.8) with iDVD6.0.3. I started to re-assemble the project and the Themes button appears with the themes, the Media button appears with the media, but both the Menu and Buttons buttons show up with nothing but a empty white area! I need to reposition some buttons, but I can't.
    Please help.

    This frequently helps solve some problems. Quit iDVD. Search for the file named com.apple.iDVD.plist and trash it. (A new one will be created next launch of iDVD.) Or look in: User/Library/Preferences. This may solve project loading errors too. Restart and use Disk Utility to Repair Permissions.
    You'll need to reset some Preferences.

  • Not rendering create button(solved)

    Dear JHeadstart team,
    I'm on JHeadstart 10.1.3.1.26 and
    Jdeveloper 10.1.3.2.1
    I have a parent Product (key is id) and a child Appeal with foreign key the product_id.
    I'm using a form layout. If checkmarked the Single-row insert allowed property.
    The functionality I would like to have is that if no row is found in the Appeal table(product_id) that the insert row button is rendered and if an Appeal row is found that the insert button is not rendered.
    I also can use a table layout but I don't know of an EL expression which helps me with my situation.
    Some help would be appreciated.
    Also a good EL tutorial/overview would be helpful to me.
    I found this one: http://download-uk.oracle.com/docs/html/B25947_01/appendixb001.htm
    and this one:
    http://developers.sun.com/docs/jscreator/help/2update1/jsp-jsfel/jsf_expression_language_intro.html#syntax
    but they are to theoretical for me.
    thanks in advance,
    Marcel.
    Message was edited by:
    MarcelM

    Hi Steven,
    I've tried your suggestion.
    I've put the EL #{!((bindings.RecensieAanvraagIterator.currentRowIndexInRange!=-1 and bindings.RecensieAanvraagIterator.findMode!='true'))} in the 'Insert allowed EL Expression' property. This generates the input button. But when I press the button, the form is completely read-only.
    The functionality i want is that for, the "RecensieAanvraag" table, I can add one row or update this row when the insert is committed. Or update an already existing row from this table. This table has a foreign key ProdId and is the child of Product table in the form layout.
    I've tried a lot of EL possibilities in both the 'Insert allowed EL Expression' and 'update allowed EL Expression' properties but without any luck (I don't have the complete understand for these properties although I've read the JHeadstartDevGuide RELEASE 10.1.3 (october 2006).pdf.).
    May be you can point me in the right direction?
    And perhaps you know of a good tutorial about EL which I don't know of?
    regards,
    Marcel

  • When I render my project to a NTSC file for Computer play back, the audio is not rendered and the file has no sound. How do I fix it?

    I build my project using videos and photos and I add sound at the end for a few photos. I then render the project to a NTSCDVD Standard file so I can play it on a Computer. Once the file is rendered and I play it, there is no sound at all. I am using Premiere Elements 13, recently installed on 12/29/2015. Previously, I had a trial copy and before I could uninstall it, it disappeared. I don't know if that had any thing to do with my full version.

    richardson
    On what computer operating system is your Premiere Elements 13 running? For now I will assume Windows 7, 8, or 8.1 64 bit.
    What are the properties of your source video and photos and what project preset did you (manually) or the project (automatically) set as the project preset
    to match those source properties? In this regard, please tell us the readings that you see under Edit Menu/Project Settings/General
    Editing Mode
    Timebase
    Frame Size
    Pixel Aspect Ratio
    even if the fields look grayed out.
    What is your choice under Publish+Share/Computer/ which is using the NTSC DVD Standard preset? Are you using Publish+Share/Computer/MPEG with the NTSC DVD Standard preset? If so, are you using the default export settings or customizing them in anyway under the Advanced Button/Video Tab or Audio Tab? If you export your Timeline to Publish+Share/Computer/QuickTime with a preset = NTSC DV, does your file have sound in the export with your player?
    What are you using as the player for this export?
    Let us start here and then decide what next?
    Thanks.
    ATR

  • HDR PRO in tool image has a large white block through it and buttons are unresponsive. How do I fix this?

    When I open images in HDR Pro I am met with a washed out image with a big white block through the middle about a third of the size of the image.
    This disappears when I export the image, which would be fine, but the buttons and sliders are not working in the app.
    This means The tool is useless. Any fixes?
    Cheers

    The symptoms you describe sound like there is an application-modal popup message box covering over the main HDR tool area but for some reason the message box is not fully rendered and you can only see the background, not the message it contains.
    This could be a transient condition that would be remedied by rebooting, or it could be a video-driver incompatibility that might be resolved by updating your video drivers from the manufacturer’s website, or perhaps changing the Graphics Processor Settings in the Performance tab of Photoshop Preferences.  You can uncheck Use Graphics Processor and restart Photoshop and see if things are different.  If so, then turn it back on, but adjust the level of acceleration in the Advance Settings from Advanced to Basic or in between and also turn on and off the other settings in Advanced Settings area to see which ones make a difference.
    If none of these grpahics system changes make any different, perhaps change the amount of memory that is being used in the PS / Prefs / Performance area, adjust it both more and less from what it is currently set to.

  • Help on Renderer and Editor

    Hi All,
    I am new to Swing and get really confused with the concepts of Renderer and Editor. I don' t really understand what Renderer is, why/when use it and how to use it. Similarly questions for Editor. There are a lot of classes related to renderer, such as TableCellRenderer, DefaultCellRenderer etc and they make me crazy. What makes different when we use Renderer and Editor?
    Thanks.

    Read "Concepts: Editors and Renderers" for JTable at http://java.sun.com/docs/books/tutorial/uiswing/components/table.html#editrender and "Customizing a Tree's Display " for JTree "http://java.sun.com/docs/books/tutorial/uiswing/components/tree.html#display

  • Rendering and Persistence

    Hi,
    I have implemented a creation form based on one view object. I have realized that some input fields only render if you click on a certain button.
    My problem is, that only those prompted values are transfered to the database where the appropriate input fields were loaded at the beginning.
    The values inserted in the input fields which are only rendered by clicking a button are not transfered.
    I am working with JDev Vers. 10 and ADF BC
    Thanks in advance

    Actually, there is no differnce between the two groups of fields. I will give you an example to make it coherent.
    I have a view object person with the following attributes: name, last name, phone number, job and hobby.
    Now I have created a creation form based on this view object.
    The input fields for the attributes job and hobby should only be rendered, if a button named "further particulars" will be clicked.
    Because of this I've created a managed bean with a state variable which is set to true if the button is clicked.
    The rendered property of the attributes job and hobby is set to #{BEAN_ONE.state==true}
    Starting the page:
    If I start the page the input fields for the attributes name, last name and phone number are rendered and values could be filled in.
    Then I click the button "further particulars" and the input fields for hobby and job are rendered.
    After I filled in the values to all input fields and clicked the commit button, only the values of name, last name and phone are committed to the database.

  • Rendering and playback issues

    Hey guys, I'm sorry if this kind of topic has been discussed before, but I could not find any help with search. I don't really know how to describe my problem. I has After Effects CS4 first and when I first got it, it was giving me the same problem. I came here and got some help and everything worked fine after that, but now I upgraded to CS5 and I'm having problems again and I can't for the life of me remember what I did to fix the problem.
    Here is what is going on. I'll uploaded a video that is an mpeg or AVCHD and while trying to preview it in anyway, it will only render some of it and then it will start depleting what has been rendered to render the rest of the clip. It is hard for me to explain. It just won't fully preview a clip as a whole.
    Also, when I make a movie or finish a clip, they are coming out incredibly choppy. CS4 worked great on my computer, but I'm guessing I don't have the seeings perfect for CS5. I would go back to CS4, but I use AVCHD now and I'm scared CS4 will start having issues like CS5 is having.
    I have a Studio XPS 435MT
    Intel Core i7 2.67 ghz
    4gb of RAM
    ATI Radeon 4800
    Do I just have on the wrong settings or something? Because like I said, CS4 was working without a problem for years. It was doing the same thing CS5 is doing now, but something I did fixed it and now I can't remember what it was.

    Please state exactly what buttons you are pressing, what icons you are clicking, and what commands you're choosing. It's hard to help you to figure out what's going on when your description of what you're doing and seeing isn't clear.
    My guess about your preview issue is that you're expecting either standard preview (spacebar play) or RAM preview to work differently than they do. For explanations of what these preview methods are and how to use them, start on this page and then read the pages that it links to: "FAQ: Why does RAM preview only play part of my composition?"
    Regarding the stuttering of movies that you've rendered and exported: My guess is that you've just rendered and exported at the default settings, which create losslessly compressed movies, which are huge and are not intended for playback. (They're intended as intermediate files for additional post-production work.) Such huge files won't play back smoothly on a less powerful computer because the hard disk can't even serve the frames from the disk fast enough. The solution is to render and export using a codec that actually compresses the files significantly. You have to keep in mind the crucial difference between formats intended for playback and formats intended for intermediate files. See this thread for a somewhat more full explanation: http://forums.adobe.com/message/2958839#2958839
    I recommend that you start here and work your way through the materials to get a good foundation in After Effects:
    "Getting started with After Effects"

  • HT5012 I am having difficulty XMIT/REC text messages to family members using Android phones?  I have a 3GB data plan and all switches and buttons are set properly.  Any suggestions?

    I am having difficulty XMIT/REC text messages to family members using Android phones?  I have a 3GB data plan and all switches and buttons are set properly.  Any suggestions?

        Hello APVzW, we absolutely want the best path to resolution. My apologies for multiple attempts of replacing the device. We'd like to verify the order information and see if we can locate the tracking number. Please send a direct message with the order number so we can dive deeper. Here's steps to send a direct message: http://vz.to/1b8XnPy We look forward to hearing from you soon.
    WiltonA_VZW
    VZW Support
    Follow us on twitter @VZWSupport

Maybe you are looking for

  • Products needed for XML Support

    One simple question: If I want to store a XML document into a ORACLE database, which additional Products do I have to install beside the Oracle 8i server.

  • Safe guarding an email form

    Is there a way to safe guard your email address in a form you have on an iWeb site. Something that checks if your are dealing with a real person. Something that checks if the user's email address is valid Something that keeps crawlers from harvesting

  • How to eliminate having to put in my password every time I open the I Pad

    How do I eliminate  having to put in my password in order to open my I Pad

  • CS6 Clip/track editing question, zooming question

    Hi folks, I had another account here but it won't let me log in. I've just done my first tracking session in CS6 after using AA3 for years. I liked a lot of features such as the intelligent snapping when I'm resizing overdub clips, but there's a few

  • Wsif EJB Invoke From BPEL

    Hello Friends, I am doing Wsif Ejb Demo. I did followings things 1. I created the Ejb Project , then i deployed that Ejb project in Oracle App Server. 2. I created the Ejb Wsdl file as per suggest by following link http://www.oracle.com/technology/pu