Plz Urgent!...How to display a list of items and on click display subitems?

Hi all,

I need the java code which on execution will display items, say 5 items. Then, when I click on one of these items, that item will expand and show subitems, say 5 subitems( one item as a web link). Please provide me with the java code. Its urgent and I need it badly. IF the execution is different then simple java programs( like how it is executed in command prompt), then please guide the execution part also.

Hello and welcome to the forum. You know of course that all of the folks here are volunteers who enjoy helping others learn Java, and we'll gladly help you with your code or with specific questions on how you can create a certain program. On the other hand, what this forum isn't is a code-producing mill that gives out code on demand.

So on that note, let's see a decent try by you towards a solution first. After you've done this and posted it with your specific questions, I'm sure that several of us will be be glad to help you along.

Getting back at your original question, it suggests a tree of some sort, so perhaps a JTree may fit your bill here?

But even before exploring this option, please make sure that you are looking for a Java solution here and not a JavaScript solution as the latter is often involved in web applications (though Java is quite useful for web apps too), and the two platforms are completely different.

You may want to first go through the GUI tutorials before attempting to code a GUI.

For starters, you appear to be trying to code an applet but are initializing your code in a constructor rather than the init() method. Your code also doesn't compile as you're calling methods that don't exist for the objects that you're trying to call them on.

Is there a reason that you're using AWT here instead of Swing for your GUI library? My own bias is to not code with AWT but to use the more robust and richer Swing platform.

Also just curious: What is your motivation for creating this and why such an urgent hurry?

Yes I know its not compiling and I had done this in my class to code an applet only and no idea about how to do in an init() method. So, basically, my code here is messed up....

I also have no idea about Swing( will surely learn in a time to come) but I really need this code to run now....as its a matter of confidence. Plz help and without expecting ne delay..i need someone to organize the code and make it run.