Changing Columns in JTable using JRadioButtons doesn't refresh structure

Course Queries Syllabus Queries 3 years ago

3.15K 1 0 0 0

User submissions are the sole responsibility of contributors, with TuteeHUB disclaiming liability for accuracy, copyrights, or consequences of use; content is for informational purposes only and not professional advice.

Answers (1)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 3 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.

Similar Forum