🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #16346

Re: JTable Headings

#16346
From: Paul Bates
Date: Tue, 02 Mar 1999 00:00
52 lines
2283 bytes
Paul Bates wrote in message <36dc2d7f.0@dns.pareto-partners.co.uk>...
>I can't seem to get JTable headings to appear under JBuilder.  I have read
>all the stuff about how you have to use a scrollpane, but it still doesn't
>work.  I have found one other person with the same problem on DejaNews, but
>he didn't get a response.  Anyone know what's going wrong.  My test code
>attempts to create a new TestFrame, which should have headings 1,2,3,4.
>
>import java.awt.*;
>import com.sun.java.swing.*;
>import jclass.table.*;
>import com.sun.java.swing.table.*;
>import java.util.*;
>
>public class TestFrame extends JFrame {
>  JTable      jTable1     = new JTable(new String[][] {{"a","b","d","e"},
>{"f","g","h","i"}}, new String [] {"1","2","3","4"});
>  JScrollPane scrollPane1 = new JScrollPane(jTable1);
>
>  public TestFrame()  {
>    setSize(new Dimension(634, 672));
>    getContentPane().add(scrollPane1, BorderLayout.CENTER);
>    setVisible(true);
>  }
>}
>

I've answered my own question (after struggling with this for days).  The
following works:


import java.awt.*;
import com.sun.java.swing.*;
import jclass.table.*;
import com.sun.java.swing.table.*;
import java.util.*;

public class TestFrame extends JFrame {
  JTable      jTable1     = new JTable(new String[][]
{{"a","b","d","e"},{"f","g","h","i"}}, new String [] {"1","2","3","4"});
  JScrollPane scrollPane1 = new JScrollPane(jTable1);

  public TestFrame() {
    setSize(new Dimension(634, 672));
    getContentPane().add(jTable1.getTableHeader(), BorderLayout.NORTH);
    getContentPane().add(scrollPane1, BorderLayout.CENTER);
    setVisible(true);
  }
}

Incidentally the original code worked fine with Sun's JDK 1.2, but not under
JBuilder
Technical Details
Message-ID: <36dc3b23.0@dns.pareto-partners.co.uk>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <36dc2d7f.0@dns.pareto-partners.co.uk>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,c17b840ccaa33b55
X-Google-Attributes: gidf74b3,public
From: "Paul Bates" <paulb@pareto-partners.co.uk>
Subject: Re: JTable Headings
Date: 1999/03/02
Message-ID: <36dc3b23.0@dns.pareto-partners.co.uk>
X-Deja-AN: 450468354
References: <36dc2d7f.0@dns.pareto-partners.co.uk>
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3
X-Trace: 2 Mar 1999 19:35:31 GMT, dns.pareto-partners.co.uk
Newsgroups: borland.public.jbuilder.java.language