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

  • Home
  • SEARCH
  • 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 583227
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:46:13+00:00 2026-05-13T14:46:13+00:00

I have a tree and a table on my panel, when I click the

  • 0

I have a tree and a table on my panel, when I click the tree node, the table needs to change at the same time, but it doesn’t. I search online and read the Java tutorial and didn’t find any solutions. From some posts I think I need to use fireTableStruetureChanged(), but it just doesn’t work in my code. Could anyone help me out of this? The following is the code. Thanks a ton!

public class tableStructureChange extends JFrame implements ... {
.....

/ //columnNames is a public variable, because I need to change the columns later
columnNames = new String[] {"col1","col2"}; */
data = new String[][]{
{"Mary", "Campione"},
{"Alison", "Huml"}, };

table = new JTable(new MyTableModel());
table.setAutoCreateColumnsFromModel( false );

feedback = new JScrollPane(table);  //feedback is the bottom panel

…

}

//the following class is the problem, i need the table to be reloaded
//when the class is called, but the table doesn't change at all

public void displayFeedback(String tempString) {

//create table for bottom panel
columnNames = new String[] {"col3","col4", "col5"};
String[][] data = new String[][]{
{"Mary", "Campione", "us"},
{"Alison", "Huml", "canada"}, };
//table = new JTable(data, columnNames);
//fireTableStructureChanged();   //this is the problem part

}

// my table model
class MyTableModel extends AbstractTableModel {
String[] columnNames = new String[] {“col1″,”col2”};

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

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

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

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

}

}

…
}

  • 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-05-13T14:46:13+00:00Added an answer on May 13, 2026 at 2:46 pm

    In your method displayFeedback you seem to be hoping to replace the JTable object and have the display change to reflect what is selected in the JTree above. Instead of replacing what is in the View object, you should focus your effort on updating the Model, in this case, the AbstractTableModel subclass that you have created. There are a couple ways you can do that, but for a brute force proof of concept, you could do something like the following:

    • add a constructor to MyTableModel that takes a 2 dimensional array of data
    • in displayFeedback, create a new instance of MyTableModel that has new data relevant to the tree node that was selected.
    • call setModel on your global table variable.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 350k
  • Answers 350k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Constructors of any derived class still have to call a… May 14, 2026 at 7:02 am
  • Editorial Team
    Editorial Team added an answer Yes, When you send removeFromSuperview, subsequently release message sent. And… May 14, 2026 at 7:02 am
  • Editorial Team
    Editorial Team added an answer I'm not exactly sure what you're looking for, but you… May 14, 2026 at 7:02 am

Related Questions

I've got an odd thing going on with a query. I have a table
I have a series of questions about Keys, Indexes and Constraints in SQL, SQL
I have a rather peculiar data source I have to work with (an interface
We have a list of x,y pairs. Every pair represents a point on a
I'm building my first Flex custom component, in Flex 3. It is a data

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.