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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:35:41+00:00 2026-06-10T14:35:41+00:00

Looking round Stack exchange I can’t find a good answer to this. Most of

  • 0

Looking round Stack exchange I can’t find a good answer to this. Most of the code in similar questions I’ve seen look massive and bloated where an error could easily creep in; I can’t see if I’m making the same mistake or not.

I only have two classes (and an interface), my probelm being is that my JTable is blank:

enter image description here

Here is my code:

Launch the program

public class Launcher {


    public static void main(String[] args) {
        javax.swing.SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                IViewManager.Util.getInstance();
            }
        });
    }
}

Start the ViewManager frame

public class ViewManager implements IViewManager {

    JFrame frame = null;
    JTabbedPane myListTabs = null;
    ComicsListPane myComicsListPane = null;

    public ViewManager(){

    //Create and set up the window.
    frame = new JFrame("My List Agregator");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    //Add the Tabbed pane for lists.
    myListTabs = new JTabbedPane();
    myComicsListPane = new ComicsListPane();
    myListTabs.add(myComicsListPane);
    myListTabs.setTitleAt(myListTabs.getTabCount()-1, "title");
    frame.getContentPane().add(myListTabs);

    //Display the window.
    frame.pack();
    frame.setVisible(true);
    }
}

The Comics List Pane

public class ComicsListPane extends JPanel {
    /**
     * 
     */
    private static final long serialVersionUID = -5207104867199042105L;
    JTable myComicsTable = null;

        public ComicsListPane() {
                //Create the column names and data
            String[] columnNames = {"Comic Title",
                    "Volume",
                    "Edition",
            "Purchased"};

            Object[][] data = {
                    {"The Amazing Spider-man", new Integer(3),
                        new Integer(679), new Boolean(false)},
                        {"The Amazing Spider-man", new Integer(3),
                            new Integer(680), new Boolean(false)}
            };
            //Create the table
            myComicsTable = new JTable(data, columnNames);
            myComicsTable.setPreferredScrollableViewportSize(new Dimension(750, 110));
            myComicsTable.setFillsViewportHeight(true);
            myComicsTable.setFillsViewportHeight(true);

            JScrollPane scrollPane = new JScrollPane(myComicsTable);        
            scrollPane.add(myComicsTable);
            scrollPane.setPreferredSize(new Dimension(450, 110));
            this.add(scrollPane, BorderLayout.CENTER);
        }
    }

I can’t see where I’ve gone wrong, mostly I’ve copied form the Java Doc Tutorials.

Could someone help point out the error, to a java novice?

  • 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-10T14:35:43+00:00Added an answer on June 10, 2026 at 2:35 pm

    It looks like your problem is when you create the JScrollPane.

    JScrollPane scrollPane = new JScrollPane(myComicsTable);        
    scrollPane.add(myComicsTable);
    

    The second line here is not needed – you’ve already constructed the JScrollPane with the JTable, there’s no need to then add it to the JScrollPane. Indeed – this is using the add() method from Container. Exactly why it’s causing the behaviour you are seeing is not clear to me without looking at the javadocs/source in more detail.

    As an aside, when you’re working with GUIs (and indeed, generally) it’s best to narrow your code down to the smallest chunks. i.e. a method to create the JTable – can that be displayed? Then, a method to wrap it in a JScrollPane – does display as you would wish? etc. etc.

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

Sidebar

Related Questions

I'm looking to find a way to round up to the nearest 500.I've been
I am looking to find out and track how long a round-trip to the
I have been looking round for an open-source CMS framework that I can use
I'm looking to round values like 2.3913 -> 2.5 4.6667 -> 4.5 2.11 ->
I'm looking for a numeric type in ILE RPG which will wrap round when
Looking at some assembly code for x86_64 on my Mac, I see the following
Looking to do a bit of refactoring... Using NHibernate I have this query currently
Looking for a perl one-liner what will find all words with the next pattern:
Looking for best advice on how to do this: I have an insert like
I'm looking at ways to reduce the quantity of Round Trips to my site

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.