How to make a Jtree expandable

Hi have a JTree and when I expand the tree and catch an exption hence not adding any children I would like the node that I have expanded to autamatically be collapsed, and ready for a future expand, as I have a situation were a node in the tree might not yet have any children (the children will be added dynamically).
I would like to handel the 9iexeption in such a way that the tree is ready for use and has the "+ sign available" to the user,
at the moomemt it thincks there are no chldren and has no "+ " or "-" sign so no future expand is posible
please help !!!!

hentchocan wrote:
I want to make a JTree that has a TextArea nodes. So each child when expanded shows a text area containing some information . Can any one provide example of such behaviour .
Best Regards,Here the reply button works.

Similar Messages

  • How to make a JTree respond to changes in the Hashtable

    Hi,
    Can anyone give the classes and methods from which I can make the JTree reflect to changes in the Hashtable. Im using the hashtable to construct a JTree but changes in hashtable are not reflected to the JTree.
    I used tree.updateUI(). It works if I insert to a collapsed node. In case a node is expanded and if I add a node to it through the Hashtable it does not reflect.
    Thanking u,
    Karan.

    A JTree will reflect changes made to its model if this model does fire the appropriate events. So, make sure to update the tree's model whenever necessary. See also [How to Use Trees|http://java.sun.com/docs/books/tutorial/uiswing/components/tree.html].

  • Can't figure out how to make a graphic expand in an animated gif (CS4)

    I'm trying to make an animated gif where two of my graphics expand to the outer edges of the picture. However all that I can manage to accomplish is to have the opacity fade in or out. Is it possible to make a graphic expand in CS4?
    Thanks for any help!

    I'm not very familiar with animation using Photoshop. I have a small amount of experience using Illustrator, but not much. I'm not sure what a normal timeline is.
    What I'm trying to do should be very simple. I want to emulate a tv screen flickering on, using 2 white bars that expand outwards from the center of a blackish background.

  • How to make a subform expand AND contract?

    Newbie here. Maybe I'm approaching this from the wrong direction. Hopefully someone can provide me with the proper method.
    I have created a series of subforms which I'd like to initially display as hidden with only a "header/button" visible for each subform. Each subform visible/invisible header object is a button which, when run, should give the form a cascading tab effect. What I'd LIKE to see happen is this: When the user clicks the button, the subform becomes visible, pushing all other header object buttons further down. However, when the visible subform button is pushed again, the subform content becomes invisible and the subform collapses back to the original form (with all user provided content remaining intact, but that's not the issue here). The problem is that I can "sort of" get this to work using the xxx.presence = "visible"/"invisible" method, but upon invoking the "invisible" part, the space where the content was showing still remains; the subform doesn't collapse.
    A related issue with this is: If I use a checkbox, the result is as I described above. But if I use a button, the subform opens but all the objects in it remain invisible.
    Is that the proper way to achieve this? Indeed, can a collapsible subform retain input data? I haven't even got that far yet. :-)
    Thanks!
    Graham

    I have figure out a way of doing what I wanted to achieve, a tab which would open and close the subform... basically two identical buttons, one aligned on top of the other. When the top button fires, it hides itself and unhides the other as well as unhiding the subforms, the other button, when fired hides itself, unhides the first button and hides the subforms.
    I have a related question though.
    Identical if/else statement is not very elegent, for sure, and I am wondering if there was another way to do this.
    Here is what my JS code looks like:
    I included hashmarks here because this is the first time I've put JS code in a forum message, and I'm not sure how it needs to be delivered in order to be displayed correctly.
    //if (this.rawValue == 1)
    //Btn1.presence = "invisible", Btn2.presence = "visible", SEC_01.presence = "visible", SEC_01A.presence = "visible";
    //else
    //Btn1.presence = "invisible", Btn2.presence = "visible", SEC_01.presence = "visible", SEC_01A.presence = "visible";

  • How to make homepage always expanded

    everytime i open my homepage i have to always expand it to view full scren. Is there a way to have it always open full screen?

    Open Safari.    Adjust page to meet your needs.  Go to Safari preferences > General > Homepage and click on set to current page.   Close (red button) Safari.
    Next time you start your computer it should start at Safari and the size of the page when you last closed it.

  • How to make all nodes in a detailed navigation tree open automatically??

    Dear All,
    I have added some iViews to two folders and add these two folders to a workset "Time" and then add "Time" to the role of Employee portal user.
    How to make all nodes expanded automatically when this workset is clicked in EP??
    thanks,
    Zita

    Not surprising...it does not work even if you follow the exact way...
    Role ->
             Workset 1
                          -> Page 1
                          -> Workset 2
                                           -> Page 2
                          -> Workset 3
                                           -> Page 3
    When the user clicks on Role which is the Entry Point, I want the user to see Page1 (works alright) and want the tree node Workset 2 open (doesn't work)...I want tree node Workset 3 closed (which is what happens...)
    The thing is Workset 2 has to be open...
    This is what I've done...I've made the Initial State of Navigation Panel set to "Open"...
    What else is to be done????
    Thanks a lot.
    JP

  • How to make a PDF form with expanding tabel or expanding fields, like in Word.

    How to make a PDF form with expanding tabel or expanding fields, like in Word.

    This is currently not possible in Formscentral. It is something we are working on for the future. Please stay tuned.
    Andrew Yarborough

  • How to make expandable field in pdf forms?

    Does anyone here know how to make expandable field in a PDF form?
    I want the field, originally appear to be a 1-liner, to expands when you put in more text and everything that is underneath the expandable field shifts or moves down.
    pls help.
    Thanks!

    No, LiveCycle Designer is not included in Creative Cloud and is available only for Windows. It was included with the Windows version of Acrobat Pro before Acrobat 11 but is now a separate program and about $300.

  • How to make the APEX tree in the "Expand All" shape by default?

    Could anybody please enlighten me on how to make the APEX tree in the "Expand All" shape by default please? I created an APEX tree and by default it's in the "Collapse All" shape. I am using APEX 4.1.0.00.21

    Hi,
    you can check the view source of html and check the onclick code written on that plus sign(Expand All), just copy that onclick javascript code and put it on page javascript event.
    Thanks,
    Jaydip Bosamiya
    +91-76000 23053
    http://jbosamiya.blogspot.com

  • How to make portlet expandable?

    Dear all,
    how can i make the portlet expands depending on its content without making vertical/horizontal scrolls?

    Thats a CSS question. Identify the div and class which applies tp it (use firebug and firefox or develper tools and ie). You have a scroll or overflow , probably auto and an explicit hieght. customise the css to remove this or modify it as you want.

  • How to make a Tree Node invisible?

    Hi
    I have got a JTree where I have created a DefaultTreeModel and a DefaultTreeCellRenderer. The JTree is filled to data from data base. These nodes after are used to do querys to a data base. But when in tree's level 2 has got only a child, this node I want to set like not visible. because this node i need it do querys.
    I have found a thread to explain something:
    http://forum.java.sun.com/thread.jsp?forum=57&thread=126031
    a) A kind to do, it is so
    I make a new Class extends DefaultTreeCellRenderer, but it doesn't work, the code is here
    public class SegnalarNodoRender extends DefaultTreeCellRenderer {
      public SegnalarNodoRender() {
      public Component getTreeCellRendererComponent(JTree tree, Object value,
                                                    boolean sel, boolean expanded, boolean leaf,
                                                    int row, boolean hasFocus) {
               Component comp;
              DefaultMutableTreeNode nodo = (DefaultMutableTreeNode) value;
              DefaultMutableTreeNode padreNodo = (DefaultMutableTreeNode) nodo.getParent();
               if (leaf && sel)  {
                 return super.getTreeCellRendererComponent(tree,value,sel,
                                                           expanded,leaf,row,hasFocus);}
               else
                 if (!leaf && nodo.getLevel()==2 && padreNodo.getChildCount()==1 ) {
                 //Set not visible
                   this.setVisible(false);
                   return  super.getTreeCellRendererComponent(tree, value, false,
                                                             expanded, leaf, row, hasFocus);
                 else {
                   return super.getTreeCellRendererComponent(tree, value, false,
                                                             expanded, leaf, row, hasFocus);
    }b) the anoher kinds it explains how to make it. It is extended a class from DefaultTreeModel, But it is in this function the this class(botton), where I don't know how the node sets to invisible. Why NodoPadre hasn't any function to set invisible.
    public Object getChild(Object parent, int index) {
      // DefaultMutableTreeNode NodoPadre = (DefaultMutableTreeNode) parent;
      // TreeNode p;
      // p = NodoPadre.getParent();
       return parent;
    }I hope somebody can help me.
    thanks in advanced.

    Hi,
    I have the same problem and would realy like to know how to do this´, using ADF Faces 11G with the up to date JDeveloper.
    I've found some blog entries in the web showing how to do this with a POJO-based approach. They insert Data programmatically based on a view object's result set, reading all data and inserting the data to the POJO.
    However, I like to
    1) Drag-And-Drop the data-control (based on one master and one details - view object and a view link) to a page and add it as tree table
    2) Get the folder icon only displayed when there are children
    3) get the last child (=leaf) displayed without folder icon.
    To make this possible, we should somehow extend the TreeModel Class and override the function isContainer
    @Override
    public boolean isContainer() {
      if (getRowData() != null) {
         MyRowImpl value = (MyRowImpl) getRowData();
        if (value.getChildValues() != null &&
           value.getChildValues().size() > 0) {
          return true;
        return false;
    }Can somehow please give me a hint how to extend the tree model base class (What class?) and how to get the framework to use this model class?
    Maybe there is a sample application for 11g somewhere?
    Thanks,
    Stefan
    Edited by: Stefan1979 on 04.11.2009 18:10

  • How to make my dynamic form pages flow correctly?

    I have created a dynamic form which has multiple questions with expandable text fields that will take multiple pages once completed.  I do not know how to make the form flow correctly past the first page.  I can attach the form if I knew how to do that.

    Thank you Paul.  Your editing assistance was greatly appreciated. I think I now understand that there should be only one page subform that is flowed, regardless of how many text box objects I have in my questionnaire. This did the trick.

  • How to make my wifi work . I'm using HP PAvilion G series Windows 7

    can somebody teach me how to make my wifi work. The guy from the place where i asked them to fix my laptop told me to download drivers from sites. and he gave me a list of drivers. But i lost it.. but then. I have downloaded almost all except for the LAN and WLAN. how do i make my wifi work. help me. thank you very much. i don't know the specific details of the laptop that's why i'm sorry if i provided little information..
    i saw someone asking for hardware IDs and this is the only i can post now. 
    PCI\VEN_1814&DEV_5390&SUBSYS_1636103C&REV_00
    PCI\VEN_1814&DEV_5390&SUBSYS_1636103C
    PCI\VEN_1814&DEV_5390&CC_028000
    PCI\VEN_1814&DEV_5390&CC_0280
    thank you!!

    I understand you need a wifi driver for your G series notebook.
    What is the product number?
    NOTE: Do NOT provide the serial number.
    What is the hardware ID of the wifi adapter?
    Go to start, search for device manager, and open this result.  
    Expand the network adapters category.
    Open the wifi card.
    Select the details tab and change the category to Hardware IDs.
    Report back the hardware IDs reported for it.  
    ↙-----------How do I give Kudos?| How do I mark a post as Solved? ----------------↓

  • How to make a clipping mask in this particular case?

    Okay, Just to begin I know how to make a clipping mask, but for the case that I'm going to present right now I just can't figure out what mistake I am doing (if any). However I am a beginner.
    http://vector.tutsplus.com/tutorials/illustration/how-to-create-a-medieval-paper-scroll/
    In the link to above tutorial on how to make a medieval scrol I'm stuck at step 25 and would be glad to anyone who helped.
    As said in step 25 that expand the appearance of the scroll and select the two then clip the mask. In th above picture I have just selected the scroll to show how it looks.
    Now as you can see in the image below I have expanded the appearance of the paper scroll. Then I selected the paper scrol and the yellowish green grunge background placed below it. And the moment I hit Ctrl+7 (in windows) or Command+7 (in Mac) to make a clipping mask the error that showed up has been highlighted.
    One more thing, I have clipped masks before too in the same tutorial given above but I don't know what has gone wrong for me in this step.
    Please help.
    Signed,
    Awais Rauf

    Why would you want a clipping mask? I don’t see a reason for it.
    However, for what you want I would use the Pathfinder panel to combine all the paths into one shape. First use the ungroup and release compound commands a few times each, to make sure you have nothing grouped. Then press the top left button in the Pathfinder p[panel. This should produce one closed path that just surrounds the scroll.

  • How to make treetable transparent

    hi,
    Does anyone have idea how to make the treetable transparent so that the background image can be shown?
    Pls provide sample code if possible,thanks!

    I don't know if I can come up with some code example
    for you since I don't know what treetable your are
    using... but... Transparency is always going to relate
    to the whether your components are opaque or not.
    Opaque = Not Transparent, so setting opaque = false
    will hopefully make your table transparent. You may
    need to do this on your CellRenderer's as well.
    Hope this helps,
    Josh Castagno
    http://www.jdc-software.com
    hi,
    i am using JTreeTable provided fron Sun swing connection article,by Scott Violet and Kathy Walrath.
    The situation i am facng now is jtree able to be transparent, but jtable still using it default background.
    Below are excerpt from sample, setOpaque(false) to jtable seem doesn't take effect.
    As i an newbie to swing,kindly point out where part shd i modified on the code. Thz!
    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;
    * This example shows how to create a simple JTreeTable component,
    * by using a JTree as a renderer (and editor) for the cells in a
    * particular column in the JTable.
    * @version 1.2 10/27/98
    * @author Philip Milne
    * @author Scott Violet
    public class JTreeTable extends JTable {
    /** A subclass of JTree. */
    protected TreeTableCellRenderer tree;
    public JTreeTable(TreeTableModel treeTableModel) {
         super();
         // Creates the tree. It will be used as a renderer and editor.
         tree = new TreeTableCellRenderer(treeTableModel);
         // Installs a tableModel representing the visible rows in the tree.
         super.setModel(new TreeTableModelAdapter(treeTableModel, tree));
         // 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());
         // No grid.
         setShowGrid(false);
    //added
    setOpaque(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);
    * Overridden to message super and forward the method to the tree.
    * Since the tree is not actually in the component hierarchy it will
    * never receive this unless we forward it in this manner.
    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");
    * Workaround for BasicTableUI anomaly. Make sure the UI never tries to
    * resize the editor. The UI currently uses different techniques to
    * paint the renderers and editors; overriding setBounds() below
    * is not the right thing to do for an editor. Returning -1 for the
    * editing row in this case, ensures the editor is never painted.
    public int getEditingRow() {
    return (getColumnClass(editingColumn) == TreeTableModel.class) ? -1 :
         editingRow;
    * Returns the actual row that is editing as <code>getEditingRow</code>
    * will always return -1.
    private int realEditingRow() {
         return editingRow;
    * This is overridden to invoke super's implementation, and then,
    * if the receiver is editing a Tree column, the editor's bounds is
    * reset. The reason we have to do this is because JTable doesn't
    * think the table is being edited, as <code>getEditingRow</code> returns
    * -1, and therefore doesn't automatically resize the editor for us.
    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();
    * Overridden to pass the new rowHeight to the tree.
    public void setRowHeight(int rowHeight) {
    super.setRowHeight(rowHeight);
         if (tree != null && tree.getRowHeight() != rowHeight) {
    tree.setRowHeight(getRowHeight());
    * Returns the tree that is being shared between the model.
    public JTree getTree() {
         return tree;
    * Overridden to invoke repaint for the particular location if
    * the column contains the tree. This is done as the tree editor does
    * not fill the bounds of the cell, we need the renderer to paint
    * the tree in the background, and then draw the editor over it.
    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;
    * A TreeCellRenderer that displays a JTree.
    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(TreeModel model) {
         super(model);
         * updateUI is overridden to set the colors of the Tree's renderer
         * to match that of the table.
         public void updateUI() {
         super.updateUI();
         // Make the tree's cell renderer use the table's cell selection
         // colors.
         TreeCellRenderer tcr = getCellRenderer();
         if (tcr instanceof DefaultTreeCellRenderer) {
              DefaultTreeCellRenderer dtcr = ((DefaultTreeCellRenderer)tcr);
              // For 1.1 uncomment this, 1.2 has a bug that will cause an
              // exception to be thrown if the border selection color is
              // null.
              // dtcr.setBorderSelectionColor(null);
              dtcr.setTextSelectionColor(UIManager.getColor
                             ("Table.selectionForeground"));
              dtcr.setBackgroundSelectionColor(UIManager.getColor
                                  ("Table.selectionBackground"));
         * Sets the row height of the tree, and forwards the row height to
         * the table.
         public void setRowHeight(int rowHeight) {
         if (rowHeight > 0) {
              super.setRowHeight(rowHeight);
              if (JTreeTable.this != null &&
              JTreeTable.this.getRowHeight() != rowHeight) {
              JTreeTable.this.setRowHeight(getRowHeight());
         * This is overridden to set the height to match that of the JTable.
         public void setBounds(int x, int y, int w, int h) {
         super.setBounds(x, 0, w, JTreeTable.this.getHeight());
         * Sublcassed to translate the graphics such that the last visible
         * row will be drawn at 0,0.
         public void paint(Graphics g) {
         g.translate(0, -visibleRow * getRowHeight());
         super.paint(g);
         // Draw the Table border if we have focus.
         if (highlightBorder != null) {
              highlightBorder.paintBorder(this, g, 0, visibleRow *
                             getRowHeight(), getWidth(),
                             getRowHeight());
         * TreeCellRenderer method. Overridden to update the visible row.
         public Component getTableCellRendererComponent(JTable table,
                                  Object value,
                                  boolean isSelected,
                                  boolean hasFocus,
                                  int row, int column) {
         Color background;
         Color foreground;
         if(isSelected) {
              background = table.getSelectionBackground();
              foreground = table.getSelectionForeground();
         else {
              background = table.getBackground();
              foreground = table.getForeground();
         highlightBorder = null;
         if (realEditingRow() == row && getEditingColumn() == column) {
              background = UIManager.getColor("Table.focusCellBackground");
              foreground = UIManager.getColor("Table.focusCellForeground");
         else if (hasFocus) {
              highlightBorder = UIManager.getBorder
              ("Table.focusCellHighlightBorder");
              if (isCellEditable(row, column)) {
              background = UIManager.getColor
                   ("Table.focusCellBackground");
              foreground = UIManager.getColor
                   ("Table.focusCellForeground");
         visibleRow = row;
         setBackground(background);
         TreeCellRenderer tcr = getCellRenderer();
         if (tcr instanceof DefaultTreeCellRenderer) {
              DefaultTreeCellRenderer dtcr = ((DefaultTreeCellRenderer)tcr);
              if (isSelected) {
              dtcr.setTextSelectionColor(foreground);
              dtcr.setBackgroundSelectionColor(background);
              else {
              dtcr.setTextNonSelectionColor(foreground);
              dtcr.setBackgroundNonSelectionColor(background);
         return this;
    * An editor that can be used to edit the tree column. This extends
    * DefaultCellEditor and uses a JTextField (actually, TreeTableTextField)
    * to perform the actual editing.
    * <p>To support editing of the tree column we can not make the tree
    * editable. The reason this doesn't work is that you can not use
    * the same component for editing and renderering. The table may have
    * the need to paint cells, while a cell is being edited. If the same
    * component were used for the rendering and editing the component would
    * be moved around, and the contents would change. When editing, this
    * is undesirable, the contents of the text field must stay the same,
    * including the caret blinking, and selections persisting. For this
    * reason the editing is done via a TableCellEditor.
    * <p>Another interesting thing to be aware of is how tree positions
    * its render and editor. The render/editor is responsible for drawing the
    * icon indicating the type of node (leaf, branch...). The tree is
    * responsible for drawing any other indicators, perhaps an additional
    * +/- sign, or lines connecting the various nodes. So, the renderer
    * is positioned based on depth. On the other hand, table always makes
    * its editor fill the contents of the cell. To get the allusion
    * that the table cell editor is part of the tree, we don't want the
    * table cell editor to fill the cell bounds. We want it to be placed
    * in the same manner as tree places it editor, and have table message
    * the tree to paint any decorations the tree wants. Then, we would
    * only have to worry about the editing part. The approach taken
    * here is to determine where tree would place the editor, and to override
    * the <code>reshape</code> method in the JTextField component to
    * nudge the textfield to the location tree would place it. Since
    * JTreeTable will paint the tree behind the editor everything should
    * just work. So, that is what we are doing here. Determining of
    * the icon position will only work if the TreeCellRenderer is
    * an instance of DefaultTreeCellRenderer. If you need custom
    * TreeCellRenderers, that don't descend from DefaultTreeCellRenderer,
    * and you want to support editing in JTreeTable, you will have
    * to do something similiar.
    public class TreeTableCellEditor extends DefaultCellEditor {
         public TreeTableCellEditor() {
         super(new TreeTableTextField());
         * Overridden to determine an offset that tree would place the
         * editor at. The offset is determined from the
         * <code>getRowBounds</code> JTree method, and additionally
         * from the icon DefaultTreeCellRenderer will use.
         * <p>The offset is then set on the TreeTableTextField component
         * created in the constructor, and returned.
         public Component getTableCellEditorComponent(JTable table,
                                  Object value,
                                  boolean isSelected,
                                  int r, int c) {
         Component component = super.getTableCellEditorComponent
              (table, value, isSelected, r, c);
         JTree t = getTree();
         boolean rv = t.isRootVisible();
         int offsetRow = rv ? r : r - 1;
         Rectangle bounds = t.getRowBounds(offsetRow);
         int offset = bounds.x;
         TreeCellRenderer tcr = t.getCellRenderer();
         if (tcr instanceof DefaultTreeCellRenderer) {
              Object node = t.getPathForRow(offsetRow).
              getLastPathComponent();
              Icon icon;
              if (t.getModel().isLeaf(node))
              icon = ((DefaultTreeCellRenderer)tcr).getLeafIcon();
              else if (tree.isExpanded(offsetRow))
              icon = ((DefaultTreeCellRenderer)tcr).getOpenIcon();
              else
              icon = ((DefaultTreeCellRenderer)tcr).getClosedIcon();
              if (icon != null) {
              offset += ((DefaultTreeCellRenderer)tcr).getIconTextGap() +
                   icon.getIconWidth();
         ((TreeTableTextField)getComponent()).offset = offset;
         return component;
         * This is overridden to forward the event to the tree. This will
         * return true if the click count >= 3, or the event is null.
         public boolean isCellEditable(EventObject e) {
         if (e instanceof MouseEvent) {
              MouseEvent me = (MouseEvent)e;
              // If the modifiers are not 0 (or the left mouse button),
    // tree may try and toggle the selection, and table
    // will then try and toggle, resulting in the
    // selection remaining the same. To avoid this, we
    // only dispatch when the modifiers are 0 (or the left mouse
    // button).
              if (me.getModifiers() == 0 ||
    me.getModifiers() == InputEvent.BUTTON1_MASK) {
              for (int counter = getColumnCount() - 1; counter >= 0;
                   counter--) {
                   if (getColumnClass(counter) == TreeTableModel.class) {
                   MouseEvent newME = new MouseEvent
                   (JTreeTable.this.tree, me.getID(),
                        me.getWhen(), me.getModifiers(),
                        me.getX() - getCellRect(0, counter, true).x,
                        me.getY(), me.getClickCount(),
    me.isPopupTrigger());
                   JTreeTable.this.tree.dispatchEvent(newME);
                   break;
              if (me.getClickCount() >= 3) {
              return true;
              return false;
         if (e == null) {
              return true;
         return false;
    * Component used by TreeTableCellEditor. The only thing this does
    * is to override the <code>reshape</code> method, and to ALWAYS
    * make the x location be <code>offset</code>.
    static class TreeTableTextField extends JTextField {
         public int offset;
         public void reshape(int x, int y, int w, int h) {
         int newX = Math.max(x, offset);
         super.reshape(newX, y, w - (newX - x), h);
    * ListToTreeSelectionModelWrapper extends DefaultTreeSelectionModel
    * to listen for changes in the ListSelectionModel it maintains. Once
    * a change in the ListSelectionModel happens, the paths are updated
    * in the DefaultTreeSelectionModel.
    class ListToTreeSelectionModelWrapper extends DefaultTreeSelectionModel {
         /** Set to true when we are updating the ListSelectionModel. */
         protected boolean updatingListSelectionModel;
         public ListToTreeSelectionModelWrapper() {
         super();
         getListSelectionModel().addListSelectionListener
         (createListSelectionListener());
         * Returns the list selection model. ListToTreeSelectionModelWrapper
         * listens for changes to this model and updates the selected paths
         * accordingly.
         ListSelectionModel getListSelectionModel() {
         return listSelectionModel;
         * This is overridden to set <code>updatingListSelectionModel</code>
         * and message super. This is the only place DefaultTreeSelectionModel
         * alters the ListSelectionModel.
         public void resetRowSelection() {
         if(!updatingListSelectionModel) {
              updatingListSelectionModel = true;
              try {
              super.resetRowSelection();
              finally {
              updatingListSelectionModel = false;
         // Notice how we don't message super if
         // updatingListSelectionModel is true. If
         // updatingListSelectionModel is true, it implies the
         // ListSelectionModel has already been updated and the
         // paths are the only thing that needs to be updated.
         * Creates and returns an instance of ListSelectionHandler.
         protected ListSelectionListener createListSelectionListener() {
         return new ListSelectionHandler();
         * If <code>updatingListSelectionModel</code> is false, this will
         * reset the selected paths from the selected rows in the list
         * selection model.
         protected void updateSelectedPathsFromSelectedRows() {
         if(!updatingListSelectionModel) {
              updatingListSelectionModel = true;
              try {
              // This is way expensive, ListSelectionModel needs an
              // enumerator for iterating.
              int min = listSelectionModel.getMinSelectionIndex();
              int max = listSelectionModel.getMaxSelectionIndex();
              clearSelection();
              if(min != -1 && max != -1) {
                   for(int counter = min; counter <= max; counter++) {
                   if(listSelectionModel.isSelectedIndex(counter)) {
                        TreePath selPath = tree.getPathForRow
                        (counter);
                        if(selPath != null) {
                        addSelectionPath(selPath);
              finally {
              updatingListSelectionModel = false;
         * Class responsible for calling updateSelectedPathsFromSelectedRows
         * when the selection of the list changse.
         class ListSelectionHandler implements ListSelectionListener {
         public void valueChanged(ListSelectionEvent e) {
              updateSelectedPathsFromSelectedRows();

Maybe you are looking for