DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2

Thread: JTable

  1. #1
    Join Date
    May 2004
    Posts
    2

    JTable

    Could someone help me with this? Why I can not get the row head to display. Thanks,



    import java.awt.*;
    import java.util.*;
    import javax.swing.*;
    import javax.swing.table.*;

    class test {
    public static void main( String args[] ) {
    JFrame F = new JFrame();
    F.setSize(500,100); F.setTitle("Test");
    String[] col = {"Count", "Name", "Company"};
    String[][] data = {
    {"1", "A", "A123"},
    {"2", "B", "B123"}
    };
    JTable T = new JTable(data, col);
    JPanel topPanel = new JPanel();
    topPanel.setLayout( new BorderLayout() );
    topPanel.add(T, BorderLayout.WEST);
    Container C = F.getContentPane();
    C.add(topPanel);
    F.setVisible(true);
    }
    }

  2. #2
    Join Date
    Jun 2004
    Posts
    1
    Add a scrollpane. The headers will appear. If you dont want to use a scrollpane, you'll have to use the getTableHeader() method.

    Add this to your code. Should work.

    JScrollPane scrollpane = new JScrollPane(T);
    topPanel.add(scrollpane, BorderLayout.WEST);

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links