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 8869837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:34:33+00:00 2026-06-14T17:34:33+00:00

I made ​​reference to a number of methods. That the effective way for fireTableCellUpdated.

  • 0

I made ​​reference to a number of methods.
That the effective way for fireTableCellUpdated.
But in fact I still do not apply.

How to make the table content update in the after DETA value update.

The method I call GJJ method implementation.
Although updated but the emergence of many new window.
This is not my needs.

Tell me how to add a button in the new window and listening button to perform the update behavior
friend told me how to do it.

         class MyTable extends AbstractTableModel {

    Object p[][]={  
                {DETA_1_1,DETA_1_2, DETA_1_3, DETA_1_4, DETA_1_5},
                {DETA_2_1,DETA_2_2, DETA_2_3, DETA_2_4, DETA_2_5},
                {DETA_3_1,DETA_3_2, DETA_3_3, DETA_3_4, DETA_3_5},
                {DETA_4_1,DETA_4_2, DETA_4_3, DETA_4_4, DETA_4_5},
                {DETA_5_1,DETA_5_2, DETA_5_3, DETA_5_4, DETA_5_5},
                {DETA_6_1,DETA_6_2, DETA_6_3, DETA_6_4, DETA_6_5},
                {DETA_7_1,DETA_7_2, DETA_7_3, DETA_7_4, DETA_7_5},
                {DETA_8_1,DETA_8_2, DETA_8_3, DETA_8_4, DETA_8_5},  
                {DETA_9_1,DETA_9_2,DETA_9_3,DETA_9_4,DETA_9_5},  
                {DETA_10_1,DETA_10_2,DETA_10_3,DETA_10_4,DETA_10_5},  
                {DETA_11_1,DETA_11_2,DETA_11_3,DETA_11_4,DETA_11_5},  
                {DETA_12_1,DETA_12_2,DETA_12_3,DETA_12_4,DETA_12_5},  
                {DETA_1_3_1,DETA_1_3_2,DETA_1_3_3,DETA_1_3_4,DETA_1_3_5},  
                {DETA_1_4_1,DETA_1_4_2, DETA_1_4_3, DETA_1_4_4, DETA_1_4_5},  
                {DETA_15_1,DETA_15_2,DETA_15_3,DETA_15_4,DETA_15_5},  
                {DETA_16_1,DETA_16_2,DETA_16_3,DETA_16_4,DETA_16_5},  
                {DETA_17_1,DETA_17_2,DETA_17_3,DETA_17_4,DETA_17_5},  
                {DETA_1_8_1,DETA_1_8_2,DETA_1_8_3,DETA_1_8_4,DETA_1_8_5},  
                {DETA_19_1,DETA_19_2,DETA_19_3,DETA_19_4,DETA_19_5}  
            };  
    String[] n = { "NO","CARD","NAME","NAME2","time" };

    public int getColumnCount() {
        return n.length;
    }

    public int getRowCount() {
        return p.length;
    }

    public String getColumnName(int col) {
        return n[col];
    }

    public Object getValueAt(int row, int col) {
        return p[row][col];
    }

    public Class getColumnClass(int c) {
        return getValueAt(0, c).getClass();
    }

}

   private void GJJ() {
    JFrame f = new JFrame();
    MyTable mt = new MyTable();
    JTable t = new JTable(mt);

    t.setPreferredScrollableViewportSize(new Dimension(550, 30));
    JScrollPane s = new JScrollPane(t);
    f.getContentPane().add(s, BorderLayout.CENTER);
    f.setTitle("coolman");
    f.pack();
    f.setVisible(true);
    f.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);

        }
    });

}
  • 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-14T17:34:34+00:00Added an answer on June 14, 2026 at 5:34 pm

    You’re question is a little vague. “Updating” a table model could be updating existing model (ie editing the data) and/or adding new rows.

    I’ve done a quick example of both.

    When editing a row, the model will and table will update them selves, so you needn’t do anything, however, if you add or remove rows, you will become responsible for firing the update events yourself.

    public class TestTableModel {
    
        public static void main(String[] args) {
            new TestTableModel();
        }
    
        public TestTableModel() {
            EventQueue.invokeLater(new Runnable() {
                @Override
                public void run() {
                    try {
                        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                    } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) {
                    }
    
                    final MyTableModel tableModel = new MyTableModel();
                    final JTable table = new JTable(tableModel);
    
                    JButton addButton = new JButton("Add");
                    addButton.addActionListener(new ActionListener() {
                        @Override
                        public void actionPerformed(ActionEvent e) {
                            tableModel.add();
                        }
                    });
                    JButton updateButton = new JButton("Update");
                    updateButton.addActionListener(new ActionListener() {
                        @Override
                        public void actionPerformed(ActionEvent e) {
                            int row = table.getSelectedRow();
                            if (row > -1) {
                                table.setValueAt("Banana", row, 0);
                            }
                        }
                    });
    
                    JPanel buttonPane = new JPanel();
                    buttonPane.add(addButton);
                    buttonPane.add(updateButton);
    
                    JFrame frame = new JFrame();
                    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                    frame.setLayout(new BorderLayout());
                    frame.add(new JScrollPane(table));
                    frame.add(buttonPane, BorderLayout.SOUTH);
                    frame.pack();
                    frame.setLocationRelativeTo(null);
                    frame.setVisible(true);
                }
            });
        }
    
        public class Person {
    
            private String name;
            private int age;
    
            public Person() {
            }
    
            public Person(String name, int age) {
                this.name = name;
                this.age = age;
            }
    
            public int getAge() {
                return age;
            }
    
            public String getName() {
                return name;
            }
    
            public void setName(String name) {
                this.name = name;
            }
    
            public void setAge(int age) {
                this.age = age;
            }
    
        }
    
        public class MyTableModel extends AbstractTableModel {
    
            private List<Person> lstPeople;
    
            public MyTableModel() {
                lstPeople = new ArrayList<Person>(25);
                lstPeople.add(new Person("Darryl Garton", randomAge()));
                lstPeople.add(new Person("Neil Willison", randomAge()));
                lstPeople.add(new Person("Darryl Hege", randomAge()));
                lstPeople.add(new Person("Karina Jerry", randomAge()));
                lstPeople.add(new Person("Erik Leddy", randomAge()));
                lstPeople.add(new Person("Chandra Kehrer", randomAge()));
                lstPeople.add(new Person("Katy Sapien", randomAge()));
                lstPeople.add(new Person("Lonnie Blakes", randomAge()));
                lstPeople.add(new Person("Kelly Ruocco", randomAge()));
                lstPeople.add(new Person("Fernando Mckinnie", randomAge()));
            }
    
            @Override
            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return true;
            }
    
            protected int randomAge() {
    
                return (int)Math.round(Math.random() * 99) + 1;
    
            }
    
            @Override
            public int getRowCount() {
                return lstPeople.size();
            }
    
            @Override
            public int getColumnCount() {
                return 2;
            }
    
            @Override
            public String getColumnName(int column) {
                String name = null;
                switch (column) {
                    case 0:
                        name = "Name";
                        break;
                    case 1:
                        name = "Age";
                        break;
                }
                return name;
            }
    
            @Override
            public Class<?> getColumnClass(int columnIndex) {
                Class clazz = String.class;
                switch (columnIndex) {
                    case 1:
                        clazz = Integer.class;
                        break;
                }
                return clazz;
            }
    
            @Override
            public Object getValueAt(int rowIndex, int columnIndex) {
                Object value = null;
                Person person = lstPeople.get(rowIndex);
                switch (columnIndex) {
                    case 0:
                        value = person.getName();
                        break;
                    case 1:
                        value = person.getAge();
                        break;
                }
                return value;
            }
    
            @Override
            public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
                Person person = lstPeople.get(rowIndex);
                switch (columnIndex) {
                    case 0:
                        if (aValue instanceof String) {
                            person.setName(aValue.toString());
                        }
                        break;
                    case 1:
                        if (aValue instanceof Integer) {
                            person.setAge((Integer)aValue);
                        }
                        break;
                }
                fireTableCellUpdated(rowIndex, columnIndex);
            }
    
            public void add() {
    
                lstPeople.add(new Person());
                fireTableRowsInserted(lstPeople.size() - 1, lstPeople.size() - 1);
    
            }
    
        }
    
    }
    

    You might like to have a read through How to use tables for more information

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've heard a number of my colleagues make reference to the fact that Sybase
I have made a Fiddle for reference: http://jsfiddle.net/xypQY/ Which element would i apply WebKit
I made a Dictionary <string, string> collection so that I can quickly reference the
I recently made some reference additions to a project in my solution and made
I've made a simple .NET 4 Web Application in VS2010, and added a reference
I made a dll in c# but i need to export the functions. Is
I made an iphone app to capture image from camera and to set that
I made an application that passes trough an XML file and extracts the entries
Check my other question with bounty: Finding similar number patterns in table I'm trying
In java how to use class variables in methods? this is the code that

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.