Jtree Handles but no children problem
My tree uses data from a database to populate. What I want is there to be the little handle image to open and close, whether or not there are children. The reason why is, I don't want the database queried until the uses tries to expand the node. I've tried using the DefaultCellRenderer to set leaf nodes to the default closed position and open position, but i just get little folder not the expandable handles. It needs to behave as though is has children, even though it has none. Right now I have it all working with a placeholder to trick each node and when I retrieve the data it vanishes (user never sees it) but it seems like there should be a better way. Help(?) jaszzmongrel
I hate this, but don't know of a better way.import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import javax.swing.tree.*;
import java.util.*;
public class Test2 extends JFrame {
private static final Random rand = new Random();
public Test2() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container content = getContentPane();
DefaultMutableTreeNode mtn = new DefaultMutableTreeNode("Root");
for (int i=0; i<5; i++) mtn.add(new MyTreeNode("Node-"+i));
JTree jt = new JTree(mtn);
jt.addTreeWillExpandListener(new javax.swing.event.TreeWillExpandListener() {
public void treeWillExpand(TreeExpansionEvent tse) {
TreeNode tn = (TreeNode)tse.getPath().getLastPathComponent();
if (tn instanceof MyTreeNode && !((MyTreeNode)tn).isChildChecked()) {
int r = rand.nextInt(3);
((MyTreeNode)tn).removeAllChildren();
for (int i=0; i<r; i++) ((MyTreeNode)tn).add(new MyTreeNode("Child-"+i));
public void treeWillCollapse(TreeExpansionEvent tse) {}
content.add(new JScrollPane(jt), BorderLayout.CENTER);
jt.setShowsRootHandles(true);
setSize(300,300);
public static void main(String[] args) { new Test2().setVisible(true); }
class MyTreeNode extends DefaultMutableTreeNode {
boolean childCheck = false;
public MyTreeNode(Object obj) {
super(obj);
add(new DefaultMutableTreeNode());
public boolean isChildChecked() { return childCheck; }
public void add(MutableTreeNode mtn) {
if (childCheck) {
removeAllChildren();
childCheck=true;
super.add(mtn);
}
Similar Messages
-
I have set up my new iPad 2 on my computer (Windows 7), but experienced syncing problems from the start. It seems that although my iPad is regognized in iTunes as it appears there, it only gives met the options to set up as a new iPad or restore from the backup, no synching options. What do I do?
File>Devices>Transfer Purchases will transfer the itunes purchases to your ocmputer.
You should sync your ipod to your computer regularly. -
I plugged in my brand new nano to my husbands desktop to get it registered, but had a problem mid way through when I tried to used an apple login that already existed. Now it's not registered and the computer won't recognize my device. How do I fix this?
iPod not recognized in 'My Computer' and in iTunes for Windows
Call U.S. iPod and Mac technical support: 1-800-APL-CARE (1-800-275-2273) to register your iPod Nano. -
in my i phone 4s all the notification sounds come first.after 4-5 seconds the msg,facebook notifications etc.seems to appear on the screen.But earlier the problem was not there.Earlier with instant sound the notifications were there on the screen.how to Sort out the Problem?
No, sounds like when you dropped it an cracked the screen it may have also damaged the logic board or the repair person damaged a cable.
-
I have apple iPhone 4S upgraded to iOS 6.0.1 and everything was working fine suddenly my Wifi was not connecting and found the wifi on/off button is greyed out and to enable it I tried all resets but still my problem have not solved, still wifi is off
Same here.... No fix. Replacing is the option apparently and if you're out of warranty, you're SOL. That was as per the "Genius" at Apple.
-
my computer crashed so i had to reformat, but the only problem is i lost my old itunes account, had to download new version. Now i have an ipod full of music but how can i place all my music I have on the ipod into my new itunes account??
Not if you first do a sync and have iTunes make a backup. However, if your only copy of the iTunes data is in the Touch, then you need to first copy the data to a new iTunes Library using third-party software such as Phone To Mac.
-
how do i get backed up purchases from an old iphone to a new one, but the only problem is an ipod is backed up into the new phone and i cant get my iphone data on to the new phone because its under i pod?
Thanks very much!
Although I had to add everything again to the playlist, at least I can just copy it over in future! -
I am trying to do a full Time Machine Backup to a new external disk. The backup starts, and it says "Time remaining about 4 days." That seems like a very long time, but the real problem is that the computer "logs off" after a few hours, and the backup stops. The system preferences are set to "Never" for Computer sleep and Display sleep. The computer does not ordinarily log off automatically, but it has done this twice since I started the Time Machine backup.
If you have more than one user account, these instructions must be carried out as an administrator.
Launch the Console application in any of the following ways:
☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
☞ Open LaunchPad. Click Utilities, then Console in the icon grid.
Make sure the title of the Console window is All Messages. If it isn't, select All Messages from the SYSTEM LOG QUERIES menu on the left. If you don't see that menu, select
View ▹ Show Log List
from the menu bar.
Enter the word "Starting" (without the quotes) in the String Matching text field. You should now see log messages with the words "Starting * backup," where * represents any of the words "automatic," "manual," or "standard." Note the timestamp of the last such message. Clear the text field and scroll back in the log to that time. Select the messages timestamped from then until the end of the backup, or the end of the log if that's not clear. Copy them (command-C) to the Clipboard. Paste (command-V) into a reply to this message.
If all you see are messages that contain the word "Starting," you didn't clear the search box.
If there are runs of repeated messages, post only one example of each. Don't post many repetitions of the same message.
When posting a log extract, be selective. Don't post more than is requested.
Please do not indiscriminately dump thousands of lines from the log into this discussion.
Some personal information, such as the names of your files, may be included — anonymize before posting. -
I am finding the ability to download previous purchases now shown on my iCloud account to be difficult. Music appears fine and most movies are OK but I have problems with all music videos included with album purchases. Any ideas?
Phillip_dc wrote:
Firstly, I purchased my first iPhone a few years ago, since then there have been a lot of apps released, a lot which I downloaded for free, tried and deleted from both my phone and my iTune 'Apps' Panel. What bothers me is when I do get a new iOS device, iPad and/or iPhone 5, and I don't want to just copy the back-up of my current iOS device to the new one, then to get the apps I want I will have to scroll through countless useless 'trash' applications in my purchase history to 'cloud download' the ones I want.
Just sync the apps you want from your computer. You don't need to redownload them directly on the iPhone Purchased list.
Will Apple be employing such a feature, a 'permanently delete/un-purchase' feature?
Dunno.
Send suggestions here -> http://www.apple.com/feedback/ -
I am trying to look at my I cloud account on a pc in the library it normally works fine but now says problem connecting with the server. what can i do or is there an issue today
Hi...
Try restarting the AMDS > How to restart the Apple Mobile Device Service (AMDS) on Windows
iCloud system status reports everything green > Apple - System Status -
i buy new iphone but i have problem in my mobile. it's need activation and i dont no how to active its need sim activation but i take it from UK and my brother send me this phone in saudi arabia i am old coustomer of apple so please help me i am suck
If the phone is locked to a carrier then you will need the carrier to unlock it And only the carrier can do that.
-
I have installed creative cloud and a trial version of illustrator on my laptop since then my IT department has purchase illustrator but is having problems installing it onto a PC workstation.
Hi, the problem is that my IT department was sent a link on his laptop to install Illustrator, however the request was for them to build me a workstation and install it on there. they have built the workstation and is having problem installing the CC desktop app on there, just to clarify would you be able to answer the following:
1) Do you have to have CC desktop app to install Illustrator from the given link?
2) If you have signed up & installed CC on your laptop, can you install illustrator on a workstation by simply installing the CC desktop app on the workstation, log into that with your username & activate the link to install illustrator, basically the provided link should not be specific to a computer or user?
Thanks -
Cannot connect to facebook but have no problem connecting to other websites
I cannot connect to facebook but have not problem connecting to other website? How can I change check this problem?
Andrew Heckler
Re: Unable to access Facebook from ANY browser on my Mac (suddenly)
Dec 21, 2012 7:00 PM (in response to dpman2008)
I had the same problem, and I just fixed it. See this thread-https://discussions.apple.com/thread/4612888?start=0&tstart=0
Let me know if this works!
Klickut: This solved my problem. I'm now left wondering how the hosts file became corupt or modified that blocked Facebook only? -
i have bought a iphone 4s from uk. but i face problem in using sim on it. this is updated with 6.0.1 version. this phone also have a chip in sim plate. now how could i use it?
Where did you purchase in UK and is the iPhone carrier locked ??
-
Hello, I just purchase Adobe Premier elements 12. I installed it but the only problem is when I try to open "new project" it tells me I have to put my password in and username for the first seven days of installation, but when I do that the project never opens, it just has the loading bar loading and then it stops, so I have no idea wat the problem is, please help
new project help
What computer operating system is your Premiere Elements running on?
Have you gone through the typical drills of
1. Latest version of QuickTime installed on your computer with Premiere Elements?
2. Running program from User Account with Administrative Privileges as well as from Run As Administrator applied to the desktop icon
with right click of the icon, followed by selecting Run As Administrator?
3. Does problem exist with and without the antivirus and firewall(s) disabled?
4. Even though the Premiere Elements 12 Editor will not open, can you open the Elements Organizer 12?
If Yes to all of the above, please review the following for a possible solution...
ATR Premiere Elements Troubleshooting: PE12: Premiere Elements 12 Editor Will Not Open
Please review and consider the above and then we can decide what next which might include trying to open
the program directly from the .exe files. (If Windows 7, 8, or 8.1 64 bit, Local Disk C\Program Files\Adobe\
Adobe Premiere Elements 12\ and in the Adobe Premiere Elements 12 Folder are the Adobe Premiere Elements 12.exe
and Adobe Premiere Elements.exe files. Double click the Adobe Premiere Elements .exe file to try to open the project.)
We will watching for your results.
ATR
Maybe you are looking for
-
Can I have multiple email accounts or at least notification of emails in one location
I have a hotmail, gmail, yahoo email accounts and want to either have them all running at the same time or at least setup email notification funneled to one of the accounts.
-
Are Acrobat Pro 11 do what Acrobat Pro 11 does
I am using forms from the VA Supreme Court, With Adobe Acrobat Pro 11 I can save the form by using the save icon at the lower right hand corner and putting it in my documents. I can think close out the VSC site and then open the form. By doing this a
-
IMac G5 Reboots spontaneously after adding USB drive
I bought a western digital My Book hard drive a couple of weeks ago and it seems that when it is hooked up my iMac will occasionally reboot. I reformatted the drive to mac format and have done a couple of backups. It appeared to be related to sleep s
-
Hi. I can not add cover preview in DPS organizer when i use Chrome. No problem in Firefox. Ants
-
I recently moved my outlook directory to a different drive as my C: drive was getting full. Everything went smoothly except for now I cannot send emails from any of my addresses with the error "Sending' reported error (0x8004010F): "Outlook data fil