hi all ,,,, i need to add a JTree to my program,i wrote one but i need it to display the content of the desktop of the computer ,i look at java tautorial and i look at googel but find nothing, plz if somebody know plz help
You will need to use the File class to discover the names of the files on the desktop, and then just create JTreeNode instances for them as normal. The files on the desktop live (under Windows 2000/XP) in three different locations:
C:\Documents and Settings\yourusername\Desktop C:\Documents and Settings\Default User\Desktop C:\Documents and Settings\All Users\Desktop
Create a File instance with one of these paths and then use the listFiles() method.
Well, you can find out the name of the current user by getting the system property "user.name". If they are not using Windows 2000/XP then yes, you will need to alter the path accordingly. You can find out the operating system with the properties "os.name" and "os.version". The final solution is likely to be a bit brittle though I'm afraid.