Article View: borland.public.jbuilder.java.swing
Article #12981JTable's column headers disappear --- bug?
From: Sandeep Kochhar
Date: Wed, 14 Oct 1998 00:00
Date: Wed, 14 Oct 1998 00:00
101 lines
3374 bytes
3374 bytes
hi!
The program below is a stripped down version of something I created in
JBuilder (+ Swing 1.03).
Basically, if the usePanel flag is set to true, the column headers
disapper.
any idea if this is a swing bug?
thanks.
_____________________________________
Sandeep Kochhar
Painted Word, 25 First St, 4th Floor, Cambridge, MA 02141.
Tel: 617-949-5532; Fax: 617-949-5515.
Email: kochhar@paintedword.com.
// ------program begin------
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import com.sun.java.swing.*;
public class ATblTst extends JApplet
{
// set usePanel to true to see the missing column headers bug
private final boolean usePanel = false; // <--------
private boolean isStandalone = false;
private BorderLayout borderLayout1 = new BorderLayout();
private BorderLayout borderLayout2 = new BorderLayout();
private JScrollPane jScrollPane1 = new JScrollPane();
private JPanel jPanel1 = new JPanel();
private Object[][] data = {
{"Mary", "Campione"},
{"Alison", "Huml"}
};
private String[] columnNames = {"First Name", "Last Name"};
private JTable jTable1 = new JTable(data, columnNames);
public ATblTst()
{
}
public void init()
{
try {
jbInit();
}
catch (Exception e) {
e.printStackTrace();
}
}
private void jbInit() throws Exception
{
this.getContentPane().setLayout(borderLayout1);
this.setSize(400,300);
this.getContentPane().add(jScrollPane1, BorderLayout.CENTER);
if (usePanel) {
jPanel1.setLayout(borderLayout2);
jPanel1.add(jTable1, BorderLayout.CENTER);
jScrollPane1.getViewport().add(jPanel1, null);
}
else {
jScrollPane1.getViewport().add(jTable1, null);
}
}
public String getAppletInfo()
{
return "Applet Information";
}
public String[][] getParameterInfo()
{
return null;
}
public static void main(String[] args)
{
ATblTst applet = new ATblTst();
applet.isStandalone = true;
JFrame frame = new JFrame();
frame.addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);}});
frame.setTitle("Applet Frame");
frame.getContentPane().add(applet, BorderLayout.CENTER);
applet.init();
applet.start();
frame.setSize(400,320);
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
frame.setLocation((d.width - frame.getSize().width) / 2,
(d.height - frame.getSize().height) / 2);
frame.setVisible(true);
}
}
// ------program end------
Technical Details
Message-ID:
<362514E3.8F63867A@paintedword.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,8dd026f36315022c,start X-Google-Attributes: gid111d45,public From: Sandeep Kochhar <kochhar@paintedword.com> Subject: JTable's column headers disappear --- bug? Date: 1998/10/14 Message-ID: <362514E3.8F63867A@paintedword.com> X-Deja-AN: 401121447 Content-Transfer-Encoding: 7bit X-Accept-Language: en Content-Type: text/plain; charset=us-ascii Organization: Painted Word Mime-Version: 1.0 Newsgroups: borland.public.jbuilder.java.swing