Changing Columns in JTable using JRadioButtons doesn't refresh structure

Course Queries Syllabus Queries 2 years ago

0 1 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating

Posted on 16 Aug 2022, this text provides information on Syllabus Queries related to Course Queries. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (1)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 years ago

 


I've removed most of my GUI to keep the code short.

I have a buttongroup of 3 JRadioButtons to select the table schema i want to display in my JTable, which is contained in a JScrollPane

I have tried to use fireTableStructureChanged() andfireTableDataChanged() as well as JTable.repaint() to no avail. Can anyone help me?

Here is a simple example that runs a window with my configuration but does not update the table.

public class test1 implements ActionListener {

private boolean payrollActive = false;

private JPanel mainPanel = new JPanel();
private JTable dataTable;

private Vector<String> courseColumns = new Vector<String>();
private Vector<String> courseColumnsPay = new Vector<String>();
private Vector<String> profsColumns = new Vector<String>();
private Vector<String> offSpaceColumns = new Vector<String>();

public test1() {
    //Add columns for tables
    String[] courseColsPay = {"Year", "Program", "Course", "Code", "CCCode", 
            "Weight", "Session", "Section", "Day", "STime", "FTime", 
            "BookedRM", "EnrolCap", "Description", "ProfFName", 
            "ProfLName", "ProfEmail", "Notes", "Syllabus", "Exam", 
            "CrossList", "PreReqs", "EnrolCtrls", "Shared",
            "TrackChanges", "Address", "WageType", "BasePay",
            "BenefitRate", "Budgeted", "PayAmount", 
            "MthAmount", "Term", "AccNumber", "PayAdmin", "PayableTo"};
    for (String col : courseColsPay) {
        courseColumnsPay.add(col);
    }
    for (int i = 0; i < 25; i++) {
        courseColumns.add(courseColsPay[i]);
    }
    String[] profCols = {"FName", "LName", "Email", "UTEmail", "Birthdate", 
            "OfficeBC", "OfficeRM", "Department", "Status", 
            "Fellowship", "OfficeStat", "PhoneNum", "HomeAddr",
            
                                                
                                                
0 views
0 shares

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.