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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T08:01:11+00:00 2026-06-04T08:01:11+00:00

I am trying to add a JScrollPane to my JTable , but it doesn’t

  • 0

I am trying to add a JScrollPane to my JTable, but it doesn’t seem to works. I have a JTable with 21 rows and 5 columns, and I’m adding a JScrollPane as per the following code…

public Targy_felv() {
    JScrollPane scrollPane;
    JFrame frame = new JFrame();
    frame.setVisible(true);
    frame.setSize(600, 300);
    table = new JTable();
    Object o[] = new Object[]{"Tárgynév", "Oktató", "Kredit", "Félév", "Tárgykód"};
    table.setModel(new DefaultTableModel(get_Tárgyak(), o));
    scrollPane = new JScrollPane();
    scrollPane.getViewport().add(table);
    frame.add(table);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

Could someone please help me to understand why the scrollbars aren’t appearing.

  • 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-04T08:01:11+00:00Added an answer on June 4, 2026 at 8:01 am

    Make sure you’re adding the JScrollPane to your JFrame, not the JTable. If you originally just had a JFrame and a JTable you would have added it like this…

    JTable table = new JTable();
    JFrame frame = new JFrame();
    frame.add(table);
    

    If you’re adding the JScrollPane, you need to change your add() method to add the JScrollPane instead of the JTable, either like this…

    JTable table = new JTable();
    JFrame frame = new JFrame();
    frame.add(new JScrollPane(table));
    

    or like this, if you need to reference the JScrollPane later in your code…

    JTable table = new JTable();
    JScrollPane scrollPane = new JScrollPane(table);
    JFrame frame = new JFrame();
    frame.add(scrollPane);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying to use JScrollPane with my applet, but it doesn't work.
I'm trying to translate between view and viewport coordinates. But the JViewport/JScrollpane doesn't seem
i'm trying to add a jtable component to my jPanel but i am unable
Im trying to add a centered background image behind a JTable in a JScrollPane.
i have a pretty basic jquery question. im trying to add jscrollpane to my
I trying to make a game where I add a Canvas to a JScrollPane
Trying to add a new element to the DOM but I get all sorts
Trying to add an onclick handler to my tabs, and can't seem to get
Trying to add a class object into a List using reflection, but when invoking
Trying to add a 'class' html attribute, but I think the keyword 'class' is

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.