JTree expand problem
Let's say a tree has 3 children, and each children has a hierarchy of subtrees. Is there any way to just expand one children and its subtrees??
root
|_A
|_SUBTREE
|_B
|_SUBTREE
|_C
|_SUBTREE
If I do the following, it will expand the whole big tree.
JTree tree;
//etc...
1) /** Expand the tree */
for (int i=0; i<tree.getRowCount(); i++)
tree.expandRow(i);
If I do this, it own expands the first 6 children (including the subtrees of each children)
2) /** Expand the tree */
for (int i=0; i<6; i++)
tree.expandRow(i);
any ideas?? please help!!
I think u mistook my point. Let's say a JTree has 3 children as follows:
and each child has its own tree hierarchy.
root
|_SUBTREE1
|_SUBTREE2
|_SUBTREE3
All I want is when the user click a particular tree node, the whole subtree will expand.
I tried the following, but it only expands the child of the tree node I selected.
public void treeExpanded(TreeExpansionEvent evt)
{ System.out.println("treeExpanded...");
TreePath path = evt.getPath();
int pathCount = path.getPathCount();
System.out.println(pathCount);
for (int i=0; i<pathCount; i++)
tree.expandPath(path);
Any ideas???
Similar Messages
-
JTree expanding problem(urgent)
hi all,
I am new to java and i am developing DMS where i use JTree to display folders. I am using vectors for displaying folder names and files. when i select a folder and create a folder under that, after creating it should highlight the folder where i am creating folder but in my project it is highlighting HOME folder.
I tried tree.expandPath, tree.setSelectionPath(treepath), tree.fireTreeExpanded(treepath); but its not working.
before this steps i am printed treepath, path is correctly printing. I dont know why the tree is not expanding....
please give me a solution.....tree.scrollPathToVisible(...)
-
Hi,
I was wondering if there is a way to have a tree created and rendered in the completely expanded form. I am thinking along the lines that is there is a setting or a method that by default does it.
If i am not mistaken there is a posting here in the forum to do this programatically.
Thank You,
-UdayDid you search for "JTree Expanded By Default" and saw that the answers were all about expanding the tree programatically:
http://forum.java.sun.com/thread.jspa?forumID=57&threadID=774838
and you wanted to make double-sure there was no other way to do it? -
JTree corruption problem when expanding paths (sometimes)
Sometimes when adding nodes or expanding paths in my JTree I get a really weird corruption. Here's screenshots of the problem:
http://linuxhelp.homeunix.com/screen1.png
http://linuxhelp.homeunix.com/screen2.png
How can I stop this from happening?
AdamHi!
I also had this problem but it works fine using SwingUtilities.invokeLater
/Malin
private class ExpandListener implements TreeWillExpandListener {
TreePath path = null;
public void treeWillCollapse(TreeExpansionEvent e) {
public void treeWillExpand(TreeExpansionEvent e) {
path = e.getPath();
collapseAll();
if (path != null) {
// If we don't scroll later it doesn't work correctly in some cases
SwingUtilities.invokeLater(new Runnable() {
public void run() {
scrollPathToVisible(path);
* Collapses the tree.
public void collapseAll() {
for (int i = root.getChildCount(); i > 0; i--) {
collapseRow(i); -
I have a very large jtree, that at it second level gets loaded from a JDOm file.
The problem is I am having a problem expanding all the nodes under a
particular node. I need an expandAll method. Nothing I have tried has
expanded beyond the child level.
After a few permutations my code right now is
public void expandAll(DefaultMutableTreeNode node)
Enumeration list = node.breadthFirstenumeraion();
while (list.hasMoreElements())
TreePath treePath = new
TreePath(((DefaultMutableTreeNode)list.nextElement()).getPath()))
tree_m.expandPath(treePath);
Am i missing something about expandPath?
I even use the code from JTree example to the reload the model.
But it still only shows the nodes children, not the children's children....etc.Hi!
You can try these methods where treeRoot is the root node of the tree:
* Collapses the function group tree.
public void collapseAll() {
for (int i = treeRoot.getChildCount(); i > 0; i--) {
tree.collapseRow(i);
* Collapses the function group tree.
public void expandAll() {
for (int i = treeRoot.getChildCount(); i > 0; i--) {
tree.expandRow(i);
/Malin -
I have listed below a shor example.
What I need is a method to do each cell to be as wide as the tree is (see the red border line), even if I resize the window. And ofcourse, the tree should keep a minimum width so every cell is fully shown.
I'll be waiting for your answers. Thanks.
import javax.swing.*;
import javax.swing.tree.*;
import java.awt.*;
public class TreeExample extends JFrame {
public TreeExample() {
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
getContentPane().add(new JScrollPane(new SomeTree()));
pack();
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
new TreeExample().setVisible(true);
class SomeTree extends JTree {
public SomeTree() {
DefaultMutableTreeNode root = new DefaultMutableTreeNode("root");
String str = "***";
for (int i = 0; i < 10; i++) {
root.add(new DefaultMutableTreeNode(str));
str += "***";
setModel(new DefaultTreeModel(root));
setCellRenderer(new SomeCellRenderer());
setBorder(BorderFactory.createLineBorder(Color.RED));
class SomeCellRenderer extends JLabel implements TreeCellRenderer {
public Component getTreeCellRendererComponent(JTree tree, Object value,
boolean selected, boolean expanded,
boolean leaf, int row,
boolean hasFocus) {
setOpaque(true);
setText(value.toString());
setBackground(Color.LIGHT_GRAY);
return this;
}The only problem i can figure is maybe the layout. Flowlayout is squeezing the size of the buttons so that they can appear in the little area that they do get. If you use borderlayout instead of the flowlayout, it may solve your problem. If that also doesn't work then set the minimum sizes of the labels.
-
Hi,
I have created a JTree using the vector constructor. The hierachy is a teamList(Vector) -> team(Vector) -> players(Object). I put the teamList into the JTree construcotr.
At various points in the program the user can add teams to the team list, or players to an existing team. This is no problem. However the JTree does not update when the structure is changed.
I have found that it is updated if the tree isnt expanded, but once expanded it doesnt get updated. I have tried calling treeDidChange(), revalidate() and loads of other methods which sound like they might do the trick! but no success. I'm sure there must be a way of doing this and that I'm just missing the point!
Do I need to add the data to the vectors some other way? Any suggestions are greatfully received. I've spent far too long on this already!What about separating the UI from the program logic and data? Perhaps the JTree shouldn't hold the data, just a representation of the data.
-
hi all
i have a jtree contains where users can edit text in nodes....
when user finshes editing i want to display the new text keeping the edited node expanded...
all things i have done either make the whole tree collapse or makes the text appear as '.....' instead of what the user has entered..
thnx in advanceSandra,
I fetch data from a database and show it in a JTree.
Because I have to refresh the tree everytime a node is
expanded I had to overwrite the default expand()
method.why do you have to refresh the tree? can you pls explain...
Now in expand() I fetch the data, build a new
tree and fire treeStructureChanged(rootNode) and make
then a call to super.expand(path). This works fine,
but now the tree doesn't know which node is expanded
and which is not and it always trys to expand a node
even if it is already expanded. this sounds horrendous and way to much. why do you need to build a new tree every time?
Maybe somebody had the same problem and/or can help
me?i have written many trees (so to speak ;) which dynamically load data from DBs. so there are my 2 cents:
1) don't overwrite methods of JTree, it is not necessary (in most cases) and way to complex, interfering with the tree model et al
2) if you use the appr. classes (DefaultTreeModel, DefaultMutableTreeNode, etc) most things are achieved by firing the appr. events (if not done already by those classes).
3) in most cases you only will need a custom cell renderer to show the data in a way you like/need.
send some more details of your problems, maybe there are other/more efficient ways of achieving your goals.
thomas -
Hi,
I have a little problem with expanding JTree. I have created UI with levelbuttons, which sould expand jTree to next sublevel and collapse jTree back to higher level. The first time I press the expanding button all works fine, because I can set all the rows I want to expand, in this case all rows with addSelectionInterval method ( addSelectionInterval(0, jTree.getRowCount()) ). The problem is, how do I know the rows of next sublevel to expand. Collapsing the current sublevel rows is also a problem. How can get the row indexes of current level?Can you put your code here?
The following may be a solution:
TreePath treepath =tree.getPathForRow(int row) ; // row is the one you know;
DefaultMutableTreeNode node=(DefaultMutableTreeNode)(treepath.getLastPathComponent());
DefaultMutableTreeNode childnode = node.getFirstChild();
tree.expandPath(new TreePath(childnode.getPath())); -
Hello,
I have got a JApplet which uses a JTree.
When a node has child nodes, i.e. when it could be expanded, I have the following problem:
If the node is selected (I use TreeSelectionModel.SINGLE_TREE_SELECTION), I can't expand it. However, if it isn't selected, I DO can.
Does somebody what could be happening?
Thank you very much
Sergio OcioHi,
I'm using a JTree to display a recursive tree (jdev903preview). This works fine.
However, I have a few issues and questions regarding expanding the tree
(the +/- buttons):
1) If I set rootVisible to true, I see the accessor name in the tree root.
Setting rootVisible to false solves this. But this also removes the '+'
buttons of the first visible level in the tree! The user can only expand
these nodes by doubleclicking the icon. How do I get around this? I don't
want the accessor to be visible (why would I ever want to expose an internal
name to the user?), but I do want the '+' buttons.You may want to establish a custom cell-renderer for the Tree and take-out the "text" from the root node. Here's a sample:
jTree1.setCellRenderer(new JUTreeCellRenderer()
public java.awt.Component getTreeCellRendererComponent(javax.swing.JTree tree, Object value,
boolean sel,
boolean expanded,
boolean leaf, int row,
boolean hasFocus)
java.awt.Component cmp = super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus());
if (tree.getModel().getRoot() == value)
setText(""); //you can substitute any text you want here for the root node.
return cmp;
2) In the tree, the '+' buttons appear even for nodes which do not have children.
When the user clicks the '+' in front of an empty node, the '+' disappears, and
the icon changes from the 'map' icon to the 'leaf' icon. Why does it draw the
wrong icon and the '+' for empty nodes?This is because, JClient tree is bound to database and without executing individual nodes the binding does not know if the node is a leaf or a parent node. If you want to execute all nodes you may want to set the tree to expand all mode. I believe there's some swing call to "expand all nodes in a tree". BY default JClient only expands the first ViewObject in the hierarchy.
3) Is it possible to expand the entire tree by default?Again beware of the database query impact here.
Greetings,
Ivo -
How can I change the icon in the JTree of JavaHelps TOC when I expand or close the node. I understand that I need to give the tree a different cell renderer but can't find out where to do that. Does anyone have an example of this?
Thanks,
Rich
DeveloperThankyou for your help. I am getting a lot closer. There is something I am still missing though. I am sure I am setting the cell renderer to the tree now. The problem is that it is not effecting the images at all. Here is my code for this. Can you see what I am doing wrong?
private void jButtonHelp_ActionPerformed()
try
ClassLoader loader = this.getClass().getClassLoader();
URL helpURL = HelpSet.findHelpSet(loader, "helpset.hs");
m_hs = new HelpSet(loader, helpURL);
HelpBroker hb = m_hs.createHelpBroker();
JHelp jhelp = new JHelp(m_hs);
JHelpTOCNavigator jhtoc = null;
hb.setDisplayed(true);
new CSH.DisplayHelpFromSource(hb);
for(Enumeration enum = jhelp.getHelpNavigators();enum.hasMoreElements();)
try
jhtoc = (JHelpTOCNavigator)enum.nextElement();
break;
catch(Exception ee){}
if(jhtoc != null)
JTree aTree = getNavTree(jhtoc);
aTree.setCellRenderer(new HelpTreeRenderer());
aTree.updateUI();
jhelp.updateUI();
catch (Exception e)
System.out.println("Help Exception " + e.getMessage());
class HelpTreeRenderer extends DefaultTreeCellRenderer{
public Component getTreeCellRendererComponent(JTree tree, Object value,
boolean selected, boolean expanded, boolean leaf, int row,
boolean hasFocus) {
try
DefaultTreeCellRenderer treeCellRender = (DefaultTreeCellRenderer)
super.getTreeCellRendererComponent(tree, value, selected, expanded,
leaf, row, hasFocus);
DefaultMutableTreeNode node =(DefaultMutableTreeNode)value;
if(node.getLevel() == 1) treeCellRender.setIcon(getImageDepartment());
catch (Exception e)
System.out.println("HelpTreeRenderer Inner Class WIP Viewer Exception " + e.getMessage());
return this;
} -
Hi everyone!
I have a problem with handles in my JTree. The JTree is populated dynamically via RMI and and acts on expand. When I collapse a node I erase all childs so that I wont get double entries the next time I expand that node. The problem is that the + symbol disappears when i collapse since there is no children until you expand. Is there a way to force the + symbol to be visible all the time? I've tried to override the isLeaf() method to always return false but it doesn't change the behavior. The thing is that I have to erase all childs every time you collapse since the structure migth have been changed by other users.
Any ideas?
Thanx in advance!!!When I collapse a node I erase all childs so that I wont get double >entries the next time I expand that node
Why make a dummy node ...You stated that on collapse was when the erase was done. -
Please help me ..
i have write a code ..which is when the user clicks the button...
a jtree table will come and the values inside the jtree will be filled by the contents of the selected items in the form...
but my problem is jtree only is comming
i created the object class ... but ...
the initialisation is not happening...
plz check the code below .. this is my class
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
public class Reservation extends JFrame implements ItemListener,ActionListener{
JComboBox fromCity = null;
JComboBox toCity = null;
JComboBox dDay = null;
JComboBox dMonth = null;
JComboBox dYear = null;
JComboBox rDay = null;
JComboBox rMonth = null;
JComboBox rYear = null;
JComboBox adult = null;
JComboBox Cabin = null;
JFrame table;
public Reservation()
setSize(600,400);
JPanel p = new JPanel();
//getContentPane().setLayout(new BorderLayout());
GridBagLayout gbl = new GridBagLayout();
GridBagConstraints gbc = new GridBagConstraints();
p.setLayout(gbl);
String []cities = {"New York","Chicago","Miami","Pittsburgh","Memphis","New Orleans"};
String [] days={"1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","27","28","29","30","31"};
String [] months = {"January","Feburary","March","April","May","June","July","August","September","October","November","December"};
String [] year = {"2006","2007"};
String [] adt = {"1","2","3","4"};
String [] cab = {"Buisness","Economy"};
fromCity = new JComboBox(cities);
fromCity.setSelectedIndex(0);
toCity = new JComboBox(cities);
toCity.setSelectedIndex(0);
dDay = new JComboBox(days);
dMonth = new JComboBox(months);
dYear = new JComboBox(year);
rDay = new JComboBox(days);
rMonth = new JComboBox(months);
rYear = new JComboBox(year);
adult = new JComboBox(adt);
Cabin = new JComboBox(cab);
JLabel frmCity = new JLabel("From");
frmCity.setLabelFor(fromCity);
JLabel tCity = new JLabel("To");
tCity.setLabelFor(tCity);
JLabel dDate = new JLabel("Departure Date");
dDate.setLabelFor(dDate);
JLabel rDate = new JLabel("Return Date");
rDate.setLabelFor(rDate);
JLabel Psg = new JLabel("Pasengers");
Psg.setLabelFor(Psg);
JLabel Adults = new JLabel("Adults");
Adults.setLabelFor(Adults);
JLabel cabin = new JLabel("Cabin");
cabin.setLabelFor(cabin);
JLabel search = new JLabel("Search By");
search.setLabelFor(search);
JRadioButton ROneWay = new JRadioButton("One Way");
JRadioButton RRoundTrip = new JRadioButton("Round Trip");
JButton searchbutton = new JButton("Date");
ButtonGroup group = new ButtonGroup();
group.add(ROneWay);
group.add(RRoundTrip);
gbc.gridx = 0;
gbc.gridy = 0;
gbc.insets = new Insets(0,30,0,0);
p.add(frmCity,gbc);
gbc.gridx =1;
gbc.gridy = 0;
gbc.insets = new Insets(0,30,0,0);
p.add(fromCity,gbc);
gbc.gridx =0;
gbc.gridy = 1;
gbc.insets = new Insets(0,30,0,0);
p.add(tCity,gbc);
gbc.gridx =1;
gbc.gridy = 1;
gbc.insets = new Insets(10,30,0,0);
p.add(toCity,gbc);
gbc.gridx = 0;
gbc.gridy = 2;
gbc.insets = new Insets(10,50,0,0);
p.add(ROneWay,gbc);
gbc.gridx = 1;
gbc.gridy = 2;
gbc.insets = new Insets(10,30,0,0);
p.add(RRoundTrip,gbc);
gbc.gridx = 1;
gbc.gridy = 3;
gbc.insets = new Insets(0,0,0,0);
p.add(dDate,gbc);
gbc.gridx = 0;
gbc.gridy = 4;
p.add(dDay,gbc);
gbc.gridx = 1;
gbc.gridy = 4;
p.add(dMonth,gbc);
gbc.gridx = 2;
gbc.gridy = 4;
p.add(dYear,gbc);
gbc.gridx = 1;
gbc.gridy = 5;
gbc.insets = new Insets(0,0,0,0);
p.add(rDate,gbc);
gbc.gridx = 0;
gbc.gridy = 6;
p.add(rDay,gbc);
gbc.gridx = 1;
gbc.gridy = 6;
p.add(rMonth,gbc);
gbc.gridx = 2;
gbc.gridy = 6;
p.add(rYear,gbc);
gbc.gridx = 1;
gbc.gridy = 7;
p.add(Psg,gbc);
gbc.gridx = 0;
gbc.gridy = 8;
p.add(Adults,gbc);
gbc.gridx = 1;
gbc.gridy = 8;
p.add(adult,gbc);
gbc.gridx = 0;
gbc.gridy = 9;
p.add(cabin,gbc);
gbc.gridx = 1;
gbc.gridy = 9;
gbc.insets = new Insets(10,0,0,0);
p.add(Cabin,gbc);
gbc.gridx = 0;
gbc.gridy = 10;
p.add(search,gbc);
gbc.gridx = 1;
gbc.gridy = 10;
gbc.insets = new Insets(10,0,0,0);
p.add(searchbutton,gbc);
getContentPane().add(p);
fromCity.addItemListener(this);
toCity.addItemListener(this);
dDay.addItemListener( this);
dMonth.addItemListener( this);
dYear.addItemListener(this);
adult.addItemListener(this);
Cabin.addItemListener(this);
searchbutton.addActionListener(this);
//Jtable form
table = new JFrame();
Container container;
container = table.getContentPane();
JPanel jpanel = new JPanel(new GridLayout(2,1));
container.setLayout(new GridLayout(2,1));
JLabel l1 = new JLabel("Departure Journey");
l1.setLabelFor(l1);
container.add(l1);
final String[] colHeads = {"","Flightno","Date","Departure Time","Arrival Time","Flight","Duration","Fare"};
final Object[ ][ ] data = new Object[10][10];
JTable table = new JTable(data,colHeads);
int v=ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
int h = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
JScrollPane jsp = new JScrollPane(table,v,h);
container.add(jsp,BorderLayout.CENTER);
String ffcity,ttcity,dday,dmon,dyear,adt,cab;
public void itemStateChanged(ItemEvent e)
ffcity = (String)fromCity.getSelectedItem();
ttcity = (String)toCity.getSelectedItem();
dday = (String)dDay.getSelectedItem();
dmon = (String)dMonth.getSelectedItem();
dyear = (String)dYear.getSelectedItem();
adt = (String)adult.getSelectedItem();
cab = (String)Cabin.getSelectedItem();
public void actionPerformed(ActionEvent ae)
if(ae.getActionCommand() == "Date")
try
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:ds","sa", "");
PreparedStatement stmt = con.prepareStatement("select ifno,vdtime,vatime,vdate1,vdate2,vdate3,efare from airways where fcity = ? and tcity = ? and vdate1 = ? and vdate2 = ? and vdate3 = ?");
stmt.setString(1,ffcity);
stmt.setString(2,ttcity);
stmt.setString(3,dday);
stmt.setString(4,dmon);
stmt.setString(5,dyear);
ResultSet d = stmt.executeQuery();
/* int count=0;
while(d.next())
{count++;
int i = 0;*/
while(d.next())
/*for(int j =1;j<=7;j++)
data[i][j] = rs.getString(j);
System.out.println(" " + data[i][j]);
}i++;*/
System.out.println(d.getInt(1));
System.out.println(d.getDouble(2));
catch(Exception ex)
System.out.println("Error occurred");
System.out.println("Error:"+ex);
table.setVisible(true);
table.setSize(300,200);
private static void createAndShowGUI()
JFrame.setDefaultLookAndFeelDecorated(true);
Reservation r=new Reservation();
JFrame frame = new JFrame("Reservation Form");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//r.pack();
r.setVisible(true);
public static void main(String[] args)
SwingUtilities.invokeLater(new Runnable(){
public void run()
createAndShowGUI();
in this object creation is not happening
when i run this code ...
only jtree is comming..
how can i make it the values of seceted items to come in table
i commented the parts that having error..
when u uncomment it u will get the problem of this codeplease anyone
-
JCheckBox as nodes in JTree having problems with custom renderer and editor
Ok, let me give some background. I have an XML document that I am parsing and reading in as a JTree. Works fine.
Next, I have overwritten the DefaultTreeCellEditor to return a JCheckBox and in this implementation of the getTreeCellEditorComponent(), I actually tell the node that he is selected. Works great.
Next, I have overwritten the DefaultTreeCellRenderer to return a JCheckBox and in the implementation of the getTreeCellEditorComponenet, I actually check to see if the Node is selected in the tree based upon the isSelected state of the actual Tree Node set in the tree cell editor, and if so, I set the JCheckBox to selected(true).Works Great.
Now, here is the issue. If a node in the tree is selected that contains children, then I want all of the children of that node to also be selected. However, when I select a node with children only the selected node is changed, and then a few moments later, the system repaints the entire tree and ALL nodes int the tree are set to a selected state. Strange? Yes. Any ideas?? WONDERFUL!! :)
Here is the TreeCellEditor code:
public Component getTreeCellEditorComponent(JTree tree,
Object value,
boolean isSelected,
boolean expanded,
boolean leaf,
int row)
elementCheckBox_ = new JCheckBox();
Component result = null;
System.out.println("isSelected? Editor = " + isSelected);
TreePath newPath = tree.getPathForRow(row);
System.out.println("value = " + value.getClass().toString());
if(value instanceof IMarketTreeNodeElement)
if(isSelected)
if(((IMarketTreeNodeElement)value).isSelected())
((IMarketTreeNodeElement)value).setSelected(false);
else
((IMarketTreeNodeElement)value).setSelected(true);
elementCheckBox_.setSelected(isSelected);
return elementCheckBox_;
Here is the TreeCellRenderer code:
public Component getTreeCellRendererComponent(JTree tree,
Object value,
boolean selected,
boolean expanded,
boolean leaf,
int row,
boolean hasFocus)
Color colSelBorderCol = UIManager.getColor
("Tree.selectionBorderColor");
selBorder_ = BorderFactory.createLineBorder(colSelBorderCol, 1);
normBorder_ = BorderFactory.createEmptyBorder(1,1,1,1);
elementCheckBox_.setText(value.toString());
if(selected)
elementCheckBox_.setSelected(selected);
elementCheckBox_.setForeground(Color.YELLOW);
elementCheckBox_.setBackground(Color.RED);
else
elementCheckBox_.setForeground(tree.getForeground());
elementCheckBox_.setBackground(tree.getBackground());
if (hasFocus)
elementCheckBox_.setBorder(selBorder_);
else
elementCheckBox_.setBorder(normBorder_);
return elementCheckBox_;
Here is the Node Code setting all child nodes to selected:
public void setSelected(boolean selected)
isSelected_ = selected;
if(isSelected_)
if((this.getTagName() == "MARKET") ||
(this.getTagName() == "TIER") &&
(this.getChildCount() != 0))
selectChildren(true);
else
if((this.getTagName() == "MARKET") ||
(this.getTagName() == "TIER") &&
(this.getChildCount() != 0))
selectChildren(false);
public boolean isSelected()
return isSelected_;
public void selectChildren(boolean selected)
int children = getChildCount();
for(int i = 0; i < children; i++)
IMarketTreeNodeElement elem = (IMarketTreeNodeElement)
this.getChildNodes().item(i);
isSelected_ = selected;
Thanks for any help! :-)I tried to run your sample code and it won't compile. The header files:
#include
#include
#include
#include
#include
do not exist on my install of MeasurementStudio. I am a bit suspicous that I don't have the latest and greatest (loading the dialong resouce gave version warnings). Here is one of my header file headers:
//==============================================================================
// Title : NiAxes3d.h
// Copyright : National Instruments 1999. All Rights Reserved.
// Purpose : Defines the CNiAxes3D class.
//==============================================================================
I
looked on your updates site and don't really see an update that applies to ComponentWorks or MeasurementStudio. My version per the MAX program for 3DControls is 3.5.549.
Do I need a newer version? What do I have to do to get the updated version? What does it cost?
Chuck -
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
AlexanderYou 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...
Maybe you are looking for
-
Hello I have an apple Id on my ipad 2 and I want to change my password of my Id but I could not do it because I don't remember the answers to the security questions what to do?
-
How to make a single item from a folder in the bookmarks toolbar a new tab?
so i reorderd my bookmarks into folders and for quick access have the folders in the bookmarks toolbar. great i thought. but for any reason i can´t get a single bookmark out of such a folder to get a new tab in addition to existing tabs. command clic
-
Macbook Pro 15 2.4 boot problem
Hi I've recently replaced my keyboard after a coffee spill (quite straightforward) and it's been working fine ever since... However, since this morning, it has refused to boot properly. I hangs at the apple logo screen for ages (20/30 minutes) and o
-
IPod folder structure and content doesn't match iTunes Library structure
My iTunes Library has the following folders: Music Podcasts Audiobooks As expected, the Podcasts folder contains podcasts I have subscribed to, and the Audiobooks folder contains Audiobooks I purchased. So far, so good. However, in addition to CDs I
-
I'm not sure where else to post this. I think I saw a post about this but I can't find it again... I bought my iPhone a few weeks ago but I've been having a hard time with the dock connector. I think it wiggles too much as I have issues syncing with