Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Empty Table

Posted on 2003-03-01
1
Medium Priority
?
211 Views
Last Modified: 2010-03-31
Is is possible to display an empty table(Table which displays only the column headers)?  Do I always have to supply some data when I am creating talbes?
0
Comment
Question by:asukai
1 Comment
 
LVL 86

Accepted Solution

by:
CEHJ earned 160 total points
ID: 8048187
Perfectly possible:

  // Create columns names
    String columnNames[] = { "Column 1", "Column 2", "Column 3" };

    // Create empty data
    String dataValues[][] = {};

    DefaultTableModel dtm = new DefaultTableModel(dataValues, columnNames);
    table = new JTable(dtm);


Don't forget to add the table to a JScrollPane, or you won't see the headers
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses
Course of the Month10 days, 5 hours left to enroll

569 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question