Any component as leaf for JTree problems
hi,
I'm trying to get arbitary components as leaves in a JTree and it looks like its very nearly there, but there are two (related?) problems.
1) If you click around on the top 3 tree components then it gets stuck in a loop of rendering and causes a stack exception to be thrown.
2) For the embedded JTree component, expanding its nodes doesn't update the parent tree
both may be because current the row height is set at the wrong time (in the TreeCellRenderer)
any help would be really appreciated!
thanks,
asjf
import javax.swing.*;
import javax.swing.tree.*;
import java.awt.*;
import java.util.*;
public class ComponentTree
public static void main(String args[])
try{(new UIManager()).setLookAndFeel((new UIManager()).getSystemLookAndFeelClassName());}
catch(Exception e){}
DefaultMutableTreeNode c0 = new DefaultMutableTreeNode(new JButton("root"));
DefaultMutableTreeNode c1 = new DefaultMutableTreeNode(new JButton("c1"));
DefaultMutableTreeNode c2 = new DefaultMutableTreeNode(new JList(new Object [] {"A","B","C"}));
DefaultMutableTreeNode c3 = new DefaultMutableTreeNode(new JTable(new Object [][] {{"Active","true"},{"User","root"}}, new Object [] {"Name","Value"}));
DefaultMutableTreeNode c4 = new DefaultMutableTreeNode(new JTree());
DefaultMutableTreeNode c5 = new DefaultMutableTreeNode(new JList(new Object [] {"D","E","F"}));
DefaultMutableTreeNode c6 = new DefaultMutableTreeNode(new JCheckBox("Active",true));
DefaultTreeModel dtm = new DefaultTreeModel(c0);
dtm.insertNodeInto(c6,c0,0);
dtm.insertNodeInto(c1,c0,0);
dtm.insertNodeInto(c2,c0,0);
dtm.insertNodeInto(c5,c2,0);
dtm.insertNodeInto(c3,c1,0);
dtm.insertNodeInto(c4,c3,0);
JTree tree = new JTree(dtm);
tree.setEditable(true);
tree.setCellRenderer(new DefaultTreeCellRenderer()
public Component getTreeCellRendererComponent( JTree tree, Object value, boolean isSelected, boolean expanded, boolean leaf, int row, boolean hasFocus)
System.out.println("Render row "+row);
Component c = (Component) ((DefaultMutableTreeNode) value).getUserObject();
if(c instanceof JCheckBox)
c.setBackground(UIManager.getColor("Tree.textBackground"));
tree.setRowHeight(c.getHeight());
return c;
tree.setCellEditor(new DefaultTreeCellEditor(tree,(DefaultTreeCellRenderer)tree.getCellRenderer())
public boolean isCellEditable(EventObject evt){return true;}
public Component getTreeCellEditorComponent( JTree tree, Object value, boolean isSelected, boolean expanded, boolean leaf, int row)
return (Component) ((DefaultMutableTreeNode) value).getUserObject();
JFrame frame = new JFrame("ComponentTree");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(tree);
frame.pack();
frame.show();
}
thanks!
this seems an awful lot of code to get this working - it should be possible to have a single CellEditor/Renderer??
also running the code - its very hard to select checkbox items, and the JLists seem to disable themselves when the main tree updates?
its also not general to any Component (?) (although we probably only want JComponent) so we can't add a JTree as a leaf?
I'm guessing there is a simpler way to get this working?
Similar Messages
-
My itunes radio rebuffers every 8 seconds - is there any fix or help for this problem. I am running the latest itunes on a new Mac with 4MB download speed.
You need to update your Mac OS to at least 10.5.8.
Itunes 10+ requires Mac OS 10.5.8+ -
Creating a JTable as a leaf for JTree
Is it possible to create a JTable as leaf node of a JTree..?
I used treecellrenderer which returns JTable as component.. but i'm getting a single row of table in my tree..? How can i solve this..?bbritta,
Thanks a lot.. for u'r support. But actually i don't want to have some kind of explorer type interface with a tree on the left side of a panel & a TABLE . I want to have a JTable as a leaf node in JTree. I mean i need JTable as node for Jtree.. But still teh code u suggested make some sense.. i will give a try.. Thanks..
gussev,
U got my problem..!
"that is possible, at the beginning of the next month, even at the end of this I'm going to release several JavaBeans and "JTable as a node for a JTree" bean would be available. I'll send a message to forum. "
I'm eagerly waiting for u'r message..
Thanks
Saran -
Is there any component in JSF for file browsing
Hi Friends,
i have to place a file browser in my page,i am using JSF Framework. so i need file browser component in JSF , but i am not able to find the JSF Component for file browser.( in normal html there is this tag {<input type="file" /> } for file browsing ), is there tag for file browsing in JSF.Edukondalu_Avula wrote:
can you tell me what is the jar file i have to add for this taglib
<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t" %>
Read reply #3. I have posted a link. -
MD4C order report for shipping notification doesnu2019t display any component
Dear guru ,
I have created a shipping notification for a subcontract order.
If I run order report (using MD04 or MD4C) for shipping notification doesnu2019t display any component.
I have seen note 498217.
Any workaround does exist ? What do you suggest ?
I need to have a confirmation date from vendor but also to have a pegging of the requirements.
Thanks in advance.Any suggestions to this? I have the same problem
rgds
GAR -
My iPad (version 1, IOS 5.1) has quit connecting with the store. I am unable to update or buy any app. I did a reboot and a reset with deleting the data. I can not find anything in support for this problem. Any help will be appreciated.
My iPad (version 1, IOS 5.1) has quit connecting with the store. I am unable to update or buy any app. I did a reboot and a reset with deleting the data. I can not find anything in support for this problem. Any help will be appreciated.
-
I've searched to no avail for this problem. Similar posts but none that tell me what to do. I can't add or delete any bookmarks on my iPad 2 running the newest iOS. I know how it's suppose to work, it just isn't working!
It started after the major update to iOS 7.
I can't believe that this is so hard to do. It's just not letting me. I can add a bookmark to the home screen just fine, just not in a bookmarks folder anywhere I try.
I've used Apple products since 2001 and have always loved how intuitive they are. But the Safari browser since iOS 7 has been the worst I've experienced. At least right in the beginning after that update.
I'd really appreciate any help that doesn't just tell me how it's suppose to work...I know that.
My iPad 4 is not affected with the problem and works as it should.To delete, tap "Edit" (tap to enlarge image)
-
I can't get any contact info for installation problem- I just bought a Mac Air and my CS5 is asking for a reinstall. Mac Air has no DVD slots. HELP I al VERY FRUSTRATED THAT ADOBE HAS NO WAY TO GET HELP
You are right, Adobe does not support CS5 because it is no longer sold.
Simply download the trial version of CS5 from this Adobe web site and input your serial number.
Adobe - Photoshop : For Macintosh -
I bought my iphone 5 in Houston on May 15 2013.
IMEI 013428009645399.The problem I have is that in the country
which I live GREECE the 4G is
not working.Please if you have any solution for this
problem let me know.My email is [email protected]
Thanking you in advance
Philip CouridisiPhones purchased in the US are NOT guaranteed to work with 4G bands outside of North America.
For what crazy reason did you purchase an iPhone in the US if you live in Greece? If your phone needs servicing, it will have to be brought back to the US. You cannot get that phone serviced in Greece. -
I guess the problem come from me but I really need those contacts before he calls me for it. I'll try some method that I got from some responders on your support website. Do you have or can you recommand any software that can solve this problem?
One more thing. I just update my iphone that my boss gave to me but it seems to be like it giving me some trouble. My iphone was updated not too long and was successful. I try to lock into it and it telling me emergency call. I plug it to my itune and it telling me that the sim card is not valid or supported. So I inserted my sim card that I usually use to call and it still saying the same. Please help me get into it.And as far as paying for phone support, here are a few tips:
If you call your carrier first and then they route you to Apple, you usually don't have to pay for phone support.
If you are talking to Apple and they ask you to pay a support fee, ask if you can get an exception this time. That usually works once, but they keep track of the times you've been granted such an exception.
If you still end up paying the support fee, that fee only applies if it's not a hardware related issue. In other words, if it can be fixed by just talking over the phone and following Apple's instructions, then the fee applies. But if your device is deemed to have a hardware failure that caused the issue, then the fee should not apply, and you can ask for it to be waived after the fact.
This forum is free, and almost all of the technical support articles the Apple tech advisors use are available on this website. Literally 99% of what they can do over the phone is just walking you through the publicly available support articles. In other words, you're paying the fee to have them do your research for you. It's like hiring a research consultant to go look stuff up in the public library so you don't have to. You're capable of doing it; you'd just rather pay someone to do it for you.
It's like Starbucks. You know how to make coffee. Everyone knows how to make coffee. And Starbucks coffee isn't any better than what you could make at home for far less. But you want the convenience. So you're really paying a convenience fee. Milk is more expensive at 7-Eleven than it is at the grocery store... because it's a convenience store. -
I signed in as my dad's ID, and now, I'm signed in as my own ID. The problem is, when I try to verify any update, it asks for my dad's ID password instead of mine. How can I fix this? I've already tried to sign in and sign out, but it doesn't work...
You need to delete and redownload those applications. His Apple ID is stored inside them.
(115505) -
When I open ITunes, I get a message that "iTunes has stopped working". I have tried reinstalling iTunes, creating a new user file, changing the startup programs in accordance with articles in iTunes troubleshooting, but am having no success in getting iTunes to stay open. Any fixes for this problem?
-
How to generate sitemap for SiteStudio sites. Is there any component avai
How to generate sitemap for SiteStudio sites. Is there any component available?
We want to create xml having list of all site URLS for SEO purpose.
Is there any way to achieve this ?
ThanksSiteStudio comes with SiteMap fragments. Change the page template so it is a document type XML, add the fragment and you're practiacally done.
-
if i open passbook on iphone 5, it always say cannot connect to itunes, any fix from apple tech support? and whats the reason for this problem? why do we have to figure it out and not even apple can give answer??
actually i found out how to fix it
1 sign out of apple account
2 close down passbook app
3 change year to 2013
4 reopen passbook and sign in at the button with your apple ID
5 change the time to auto update and it should work from now on.
this worked for me let me know if it work for you:) -
I am using adobe photoshop cs6. I am facing a problem. When i save any image as "save for web". After saving image it show cropped. An image show many parts of the image after saving the image. Please help me. Thanks in advance.
Just go back in photoshop and use the Slice Select tool, then just click and select the slice and hit delete - if you're not sure which one is the active slice just right click and find the one that has the Delete Slice option.
It's possible you either added the slices by accident or if you received it from someone they just had the slices hidden. For the future, you can go to View > Show > Slices to display (or hide) slices.
Maybe you are looking for
-
Hi, Recently, my j2ee enginee cannot start dispacher and j2ee server always in yellow colour (Starting framework forever). This is the error i got from server.log : Thread[SAPEngine_EnquReader,5,main]##0#0#Error#1#com.sap.engine.core.locking.impl3.Lo
-
Acer Aspire One will only connect via Fon now on H...
Since activating Fon on my BT Home Hub my Acer Aspire One - running Linux Linpus - will no longer log on to the 'normal' wireless connection on my hub, only Fon, which has limited bandwidth, etc. Anybody know why? Have a solution? I've 'proved' it's
-
Transfer a message of high dimension from client to client
What i must use to di it? Ftp? SocketChannel? Thanks.
-
I am trying to run InCopy CS3 on a 2.66 gHz Intel iMac, 4 GB RAM, 320 GB HD, and InCopy is crashing when opening certain older files, such as those created in CS. (We need to be able to open archived files that were created in earlier versions.) Ther
-
E63 cant sign into MSN Messenger out of the blue
I had the phone for almost a year, and out of the blue, I cannot sign in to my msn account. This is the message I got windows live is currently unable to connect. this may be because your phone is in the offline mode or you do not have a data connect