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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T09:38:35+00:00 2026-05-14T09:38:35+00:00

Hey guys, working on an event calendar. I’m having some trouble getting my column

  • 0

Hey guys, working on an event calendar. I’m having some trouble getting my column heads to display.. here is the code

private JTable calendarTable;
private DefaultTableModel calendarTableModel; 

final private String [] days = {"Sunday", "Monday", "Tuesday",
                                    "Wednesday", "Thursday", "Friday",
                                    "Saturday"};
//////////////////////////////////////////////////////////////////////
/* Setup the actual calendar table */


calendarTableModel = new DefaultTableModel() {
    public boolean isCellEditable(int row, int col){
             return false;
    }
};

// setup columns
for(int i = 0; i < 7; i++)
    calendarTableModel.addColumn(days[i]); 

calendarTable = new JTable(calendarTableModel);

calendarTable.getTableHeader().setResizingAllowed(false);
calendarTable.getTableHeader().setReorderingAllowed(false);

calendarTable.setColumnSelectionAllowed(true);
calendarTable.setRowSelectionAllowed(true);
calendarTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

calendarTable.setRowHeight(105);
calendarTableModel.setColumnCount(7);
calendarTableModel.setRowCount(6);

Also, Im sort of new with tables.. how can I make the rowHeight split between the max size of the table?

  • 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-05-14T09:38:36+00:00Added an answer on May 14, 2026 at 9:38 am

    Table header

    Either put calendarTable in a JScrollPane, or add calendarTable.getTableHeader() as well.

    Row height

    Add a listener to change row height whenever the table is resized.

    calendarTable.addComponentListener(new ComponentAdapter() {
        public void componentResized(ComponentEvent evt) {
            if (evt.getID() == ComponentEvent.COMPONENT_RESIZED) {
                calendarTable.setRowHeight(calendarTable.getHeight() / calendarTable.getRowCount());
            }
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey guys i want to execute my SQL statement but im having synatx trouble,
Hey Guys, here is my code for this, the only help i get from
Hey guys I am working on a SW here I am kinda in need
Hey guys I have the following code working which is sending a GET Request
hey guys im working on a task to make my story's links like this
Hey guys, I'm working on a status-Updater. It works, there is just one problem,
Hey guys, I was working on a simple chat program to brush up on
Hey guys, so I've got my NSFetchedResultsController working fine under the 3.1 SDK, however
hey guys, i'm getting an exception on the following inner exception: {Value cannot be
Hey Guys...need help. Working on a project and get this error on the Output

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.