File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes XML parsing in Java Swing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "XML parsing in Java Swing" Watch "XML parsing in Java Swing" New topic
Author

XML parsing in Java Swing

keba dev
Greenhorn

Joined: Apr 25, 2013
Posts: 4
Hi there below is the code for parsing xml in java swing now the xml is parsed properly in this is displayed in console but the issue is i have to display it in the new jframe gui with text box in it can anyone out there help regarding the same.

Ranganathan Kaliyur Mannar
Bartender

Joined: Oct 16, 2003
Posts: 1077
    
  10

Hi keba,
Welcome to the Ranch!

I see that you have posted xml parsing code and some sop statements. You first need to gather this output in variable - so, declare a StringBuilder variable and keep appending to that the needed text.
Then, you have to create a JFrame, have a JTextArea in a JScrollPane and call setText on the text area to have the content printed in the GUI.

If you are new to Swing GUI programming, you can start here

Also, would like to point out 2 things:
Please do not use all caps for the subject - on the net, it is considered as shouting. And also, please UseCodeTags when posting code. I have added them this time for you.


Ranga.
SCJP 1.4, OCMJEA/SCEA 5.0.
keba dev
Greenhorn

Joined: Apr 25, 2013
Posts: 4
Thanks For your response will update code and will try resolving the way you have told also will keep in mind when posting next time the caps thing and tags.

Thank You For Your Time And Assistance.
Ranganathan Kaliyur Mannar
Bartender

Joined: Oct 16, 2003
Posts: 1077
    
  10

Sure, you're welcome.
keba dev
Greenhorn

Joined: Apr 25, 2013
Posts: 4
Hi,

I have to display parsed string into the text box i get required output in console by this code.

if(nameAttribute != null && !nameAttribute.equals("")){
System.out.println("Name : " +nameAttribute);

}

if (blname) {
double value = Double.parseDouble(new String(ch, start, length));
System.out.println("Value : " + value);
blname = false;
}



the code below of jtextfield
textField.setBounds(163, 77, 86, 20);
textField.setColumns(10);

like wise i have three textfields can you please help i have tried settext also append also string builder, can you post a sample for the same. Thanks in advance.

keba dev
Greenhorn

Joined: Apr 25, 2013
Posts: 4
Hi


I am posting my code here i hope that might give you clear idea that where i am going wrong. There might be certain unwanted code please ignore it.



Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

keba dev, I added the code tags to your last post. Please do that yourself in the future.

As for where you are going wrong: Ranganathan Kaliyur Mannar suggested you should collect the data from the parser into a StringBuilder. That's still good advice, even though you have not paid any attention to it so far. Hopefully you already know that System.out.println doesn't do that.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: XML parsing in Java Swing