Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8746891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:15:59+00:00 2026-06-13T12:15:59+00:00

I have a small project to complete. I have to parse an XML file

  • 0

I have a small project to complete. I have to parse an XML file and then display onto a user interface (swing). I did some research and tried out SAX parsing. Now, I am thinking how can I convert the object model into a UI.
Here is the tutorial link I found:
http://www.mkyong.com/java/how-to-read-xml-file-in-java-sax-parser/

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T12:16:00+00:00Added an answer on June 13, 2026 at 12:16 pm

    Here we go for what you want is done.

    import javax.swing.*;
    import javax.swing.table.DefaultTableModel;
    import java.awt.*;
    import java.util.ArrayList;
    import java.util.Iterator;
    
    public class JTableComponent {
        public static void main(String[] args) {
            new JTableComponent();
        }
    
        public JTableComponent() {
            JFrame frame = new JFrame("Creating JTable Component Example!");
            JPanel panel = new JPanel();
    
            DefaultTableModel aModel = new DefaultTableModel() {
                public boolean isCellEditable(int row, int column) {
                    return false;
                }
            };
    
            Staff s1 = new Staff("vinod1", "BCA", "A", "10000");
            Staff s2 = new Staff("vinod2", "BCA", "A", "20000");
            Staff s3 = new Staff("vinod3", "BCA", "A", "30000");
            Staff s4 = new Staff("vinod4", "BCA", "A", "40000");
            ArrayList<Staff> l = new ArrayList<Staff>();// here you will get parser
                                                        // object this is as sample
            l.add(s1);
            l.add(s2);
            l.add(s3);
            l.add(s4);
            Iterator<Staff> is = l.iterator();
    
            String col[] = { "firstname", "lastname", "nickname", "salary" };
            aModel.setColumnIdentifiers(col);
            JTable table = new JTable(aModel);
            while (is.hasNext()) {
                Staff t = is.next();
                String firstname = t.getFirstname();
                String lastname = t.getLastname();
                String nickname = t.getNickname();
                String salary = t.getSalary();
                String temp[] = { firstname, lastname, nickname, salary };
                aModel.addRow(temp);
            }
            table.setModel(aModel);
            panel.add(table, BorderLayout.CENTER);
    
            frame.add(panel);
            frame.setSize(300, 300);
            frame.setVisible(true);
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        }
    }
    

    Bean for you shown xml file

    public class Staff 
    {
        String firstname= "";
        String  lastname ="";
        String nickname = "";
        String salary = "";
    
        public Staff(String firstname,String lastname,String nickname,String salary)
        {
             this.firstname= firstname;
             this.lastname =lastname;
             this.nickname = nickname;
             this.salary = salary;
        }
    
        public String getFirstname() {
            return firstname;
        }
        public void setFirstname(String firstname) {
            this.firstname = firstname;
        }
        public String getLastname() {
            return lastname;
        }
        public void setLastname(String lastname) {
            this.lastname = lastname;
        }
        public String getNickname() {
            return nickname;
        }
        public void setNickname(String nickname) {
            this.nickname = nickname;
        }
        public String getSalary() {
            return salary;
        }
        public void setSalary(String salary) {
            this.salary = salary;
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some small project to stream video to android device. Streaming is done
The idea behind this small project of mine is to have an user enter
I currently have a small (I'm a complete beginner) project in VTK where I've
I have a header-file, the COM interface. I have created a small win32 program
I have a small project containing 1 HTML file and 4 JavaScript files. Recently,
We have a small project with some heavy-weight dependencies (e.g. Spring) of which we
Very recent i have to complete a project which have a small portion of
I have a small project that I was using node-dirty for, but it's not
I have done small project in c++, the IDE I am using is Visual
I have a small project that I will be working on shortly that collects

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.