Hi.. I have some output results as Xml String.. and i want to display that output as DataGrid Tables... help me how to use datagrid in swings like c# Datagrid...?
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
Hi.. I have some output results as Xml String.. and i want to display that output as DataGrid Tables... help me how to use datagrid in swings like c# Datagrid...?
What is a DataGrid? Do you mean a JTable? Have you gone through the Swing tutorials yet?
yah.. actually i have seen .net code for that.. actually i am getting output xml file from web services as a string... so i want to convert it into xml then tables... how to use JTables for that? if any example pls give me....
Here's a link to the tutorial for tables:
How to Use Tables (The Java™ Tutorials > Creating a GUI With JFC/Swing > Using Swing Components)
If you don't understand my answer, don't ignore it, ask a question.
Thank u Norm.. but I want to know how to add xml data to a JTable.. and how to add Xml data as multiple rows to a table....?
@ch.nagaraju: you're making a common mistake of trying to look for a tutorial for a very specific problem, one that likely doesn't exist. You must break your current problem into smaller steps, and then understand how to do the smaller steps. I suggest you read up on and learn how to extract information from XML files with Java, and then read the tutorial that Norm has linked to on how to create JTables. Then use your brain to combine the two into one finished product.
ok. thank u Curmudgeon...
ok i understood.... i know how to convert string to xml file.. but i want to know how to use JTable for that xml file.... i want to display that xml as a table...
As curmudgeon has pointed out, you need to break the problem down. XML is technically a language, and how you wish to display the contents to a user is dependent upon the data it contains, which you have given us no insight into...is it a list? Is it hierarchical? Are there multiple entries? You have provided no information regarding these questions, so we can only advise to use a JTable because you mention DataGrid (again, not defining what this is but making us guess).
So in order to break the problem down, I would suggest the following steps (google is your friend for finding tutorials on how to accomplish each of these steps)
- Figure out how to read the data within the XML. You could parse it yourself or use a parser that comes with J2SE (google for information on these).
- When you read the data you must store it somehow...my advice would be to create classes which best represent the data. But you could structure it using the appropriate data structure
- Lastly, and only lastly, should you be thinking about how best to render that data to the user. Is a JTable the best? What about a JTree? Or a JList? Because we have no clue how the data is structured, we can only guess.
Lastly, if you wish to make full use of the expertise on these forums, I recommend providing as much detail as you can in order to give context to your questions so as to prevent contributors from guessing at what might be the situation.