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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:42:30+00:00 2026-06-12T04:42:30+00:00

I created a GUI class that displays a list of items. When the user

  • 0

I created a GUI class that displays a list of items. When the user selects an item, it pops a new window that displays a JTable, which is supposed to give detailed information for that item (two columns: parameter on the left, the value on the right). This (kind of) worked until I decided to make all the methods and variables in the table class non-static, in case the user wants to open several table windows in the same time.

And then it stopped working. The table won’t show. All the code executes, but the table is empty, even after I use the add method of its model.

(also, I’d appreciate comments about a better idea for the GUI, mainly because one of the fields is called “description” and can be very long. I am writing the application for myself, so function is first priority)

Edit: here is some code, don’t hesitate to ask me for more. (I didn’t copy it in the first place because I assumed it was simple enough)

JTable class, starting from line 82 – all the rest is automatically generated.

public void main(ArrayList<String> l, ArrayList<String> d) {
    labels = l;
    data = d;
    /*
     * Set the Nimbus look and feel
     */
    //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
    /*
     * If Nimbus (introduced in Java SE 6) is not available, stay with the
     * default look and feel. For details see
     * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
     */
    try {
        for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
            if ("Nimbus".equals(info.getName())) {
                javax.swing.UIManager.setLookAndFeel(info.getClassName());
                break;
            }
        }
    } catch (ClassNotFoundException ex) {
        java.util.logging.Logger.getLogger(PopupTable.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (InstantiationException ex) {
        java.util.logging.Logger.getLogger(PopupTable.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (IllegalAccessException ex) {
        java.util.logging.Logger.getLogger(PopupTable.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (javax.swing.UnsupportedLookAndFeelException ex) {
        java.util.logging.Logger.getLogger(PopupTable.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    }
    //</editor-fold>

    /*
     * Create and display the form
     */
    java.awt.EventQueue.invokeLater(new Runnable() {

        public void run() {
            new PopupTable().setVisible(true);
            model.addColumn("Description");
            model.addColumn("Value");
            for (int i = 0; i < data.size(); i++) {
                Object[] r = {labels.get(i), data.get(i)};
                System.out.println(labels.get(i) + data.get(i));
                model.addRow(r);
            }
            Object[] asd = {"Name", "Skelet"};
            model.addRow(asd);
        }
    });
}

public static void asd() {
    System.out.println("Bazinga!");
}
private ArrayList<String> labels;
private ArrayList<String> data;
private DefaultTableModel model = new DefaultTableModel();
;
// Variables declaration - do not modify                     
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTable table;
// End of variables declaration                   
}

The other class calls this one’s “main” method by sending two lists, one for the field data and another for the description of each data (first would send “2000”, second would send “Experience”). As I said, everything works if the variables and methods are static. If they’re not, everything works, except for the table, which doesn’t show up.

Here’s the code from the outside class, which I use to create the Table class:

new PopupTable().main(list1, list2);
  • 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-12T04:42:32+00:00Added an answer on June 12, 2026 at 4:42 am

    I just noticed that the run() method had:

    new PopupTable().setVisible(true);
    

    So I deleted it and then run the class like that:

    PopupTable pt = new PopupTable();
    pt.main(MagiciaFileManipulator.getMetadata(), itemList.get(0));
    pt.setVisible(true);
    

    Now everything works perfectly! I can’t believe it was so simple, I thought I looked at everything and mistakenly concluded it was a fundamental problem with JTables and static/non-static.

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

Sidebar

Related Questions

I created a array of JPanels which contains a common JLabel class gui {
I have a GUI window that I've created using Netbeans. I then ported the
I have a class (simulation) which creates an instance of another class (GUI). Inside
I have created a GUI for starting a Thread which does something very simple.
I have created a GUI that will setup the pivot table. For example, I
I am going to make a GUI that will have dynamically created sets of
I'm attempting to build a very simple wxPython GUI that monitors and displays external
I have a simple Jython GUI that displays an XML file in a JTree.
I have a program with a GUI that needs to open a separate window
I am working on an assignment for my GUI programming class, in which we

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.