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

  • Home
  • SEARCH
  • 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 9123673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:23:53+00:00 2026-06-17T06:23:53+00:00

I have created an app just for exercise purpose with a JTable in it

  • 0

I have created an app just for exercise purpose with a JTable in it to show the data coming from my database.

My problem is that the table shows up in half the panel on my screen. I’ve tried everything to expand the columns without success. Can someone tell me how to modify the table?

Here is the code that creates the table:

    public void createTable() {
    JTable table = new JTable();
    DefaultTableModel tableModel = new DefaultTableModel(new Object[][]{},new String[]{"To do","Date added"});
    table.setSize(450, 600);
    table.setModel(tableModel);
    for(int i = 0; i < model.getId().size(); i++) {
        tableModel.addRow(new Object[]{model.getItem().get(i), model.getDate().get(i)});
    }
    add(table.getTableHeader());
    add(table);
}

Here is how it looks right now:

enter image description here

Also I want to ask about table.getTableHeader() because if I don’t add that it doesn’t show up since it is a part of the table.. is that normal?

  • 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-17T06:23:55+00:00Added an answer on June 17, 2026 at 6:23 am
    • JPanel has FlowLayout implemented in API, then your JPanel layed JComponents correctly, with yours logics (add JTableHeader, add JTable)

    • change that to the BorderLayout and to put JTableHeader to the NORTH / SOUTH and JTable to the CENTER

    • use JScrollPane for JTables view, everything else is bothering with LayoutManager and calculating for PreferredSize very ugly way,

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

Sidebar

Related Questions

I'm just starting to use core data in my iphone app. I have created
I have created a minimal PhoneGap app that has just this in the index.html:
i have just created a drum app. The user taps on the individual buttons
I have a question. I just created an app using WPF. and trying to
I have created an app in C# .Net 2.0 that uses the AxShockwaveFlash object
I have created an app that uses NSTimer, which gets triggered each second. My
I have created a mobile app using Phonegap Build (not just Phonegap...but Build ).
I have created an app using a badly named database, all alterations to important
I have created WinForms app, when I run it from console (cmd) the console
I have created an app that simply shows the user's current position on a

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.