🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #12858

Re: JTable multi-line headers

#12858
From: Anne JANSSENS
Date: Tue, 27 Oct 1998 00:00
46 lines
2104 bytes
Here are some ideas to solve your problem, hope it would help !
Anne

Multiligne Text :
By default, the cell renderer of the JTableHeader is a JLabel component,
that means
that you can not have multiligne in a header.
To change the renderer of the JTable :
mytable.getColumnModel().getColumn(num_col).setHeaderRenderer(new
Renderer());
I think you can define a new Render for each column header that would be
based on a multiligne component
such as TextComponent

ex : public class Renderer extends JTextComponent implements
TableCellRenderer
{    public Renderer
     {  setOpaque(true);
        setForeground(UIManager.getColor("TableHeader.foreground"));
        setBackground(UIManager.getColor("TableHeader.background"));
        -- you may want to change the paint in the column
        -- if you want more detail, you can ask me
       setBorder(new myBorder()


       });

    }

   public Component getTableCellRendererComponent(JTable table,
                                                  Object value,
                                                  boolean isSelected,
                                                  boolean hasFocus,
                                                  int row,
                                                  int column)
   { setFont(table.getFont());
     setText(value.toString());
     return this ;
  }

}

What I have implemented is multicolumn header, by modifying the border of
the column you can find
the example in response of one of my question : problem with header in
JTable dated 29-09-98!
Technical Details
Message-ID: <714h5q$9ov16@forums.borland.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <36350756.9BA53ED9@gdesystems.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,8c548303a9cb6a65
X-Google-Attributes: gid111d45,public
From: "Anne JANSSENS" <recherche@generix.fr>
Subject: Re: JTable multi-line headers
Date: 1998/10/27
Message-ID: <714h5q$9ov16@forums.borland.com>
X-Deja-AN: 405545881
References: <36350756.9BA53ED9@gdesystems.com>
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.2106.4
Organization: Another Netscape Collabra Server User
Newsgroups: borland.public.jbuilder.java.swing