Re: JComboBox into JHeader




adil wrote:
Hello ,
i am trying to put a JComboBox into Header of a JTable, i do it by
implementing the TableCellRenderer, also i implement
getTableCellRendererComponent(Jtable.....) method to return a ComboBox.
i can see the combobox into header of my table , but i can select any items
of it, it's seems that the combobox disabled.
can somenone help me plz ?

Unfortunately, what you're trying to do is non-trivial to accomplish.

Using a custom renderer will not help you because a renderer by
definition is only something that is used to render (i.e paint) the
header cell - the component itself is NOT physically present in the
container hierarchy and hence cannot receive events which are required
for any user interaction.

The same issue also occurs if you want to insert custom components such
as say a JCombobox in the cell of a table. But the problem is easier to
solve in that case because Table cells can be made editable - and hence
defining your Custom component as a CellEditor will cause it to be
inserted at the cell location when the user clicks on the cell to begin
editing. But the Swing design of TableHeaders don't seem to allow a
Header to be editable, and so that approach doesn't work here.

The only option that I can see is to write your own version of a
JTableHeader - but I don't think it is by any means an easy solution to
implement.

BK

P.S. I haven't been active in Swing based development for about 2+
years now, and hence haven't kept track of changes in recent versions
of Swing - wonder if things have improved and there's an easier way out
?

.



Relevant Pages

  • How can I resize a JTables column width?
    ... JTableHeader which is wrapped around a DefaultTableColumnModel object that ... After I start the application, the header of the table looks good, but the ... but why don't the cell values show up? ... TableColumn firstCol = new TableColumn; ...
    (comp.lang.java.help)
  • How can I resize a JTables column width?
    ... JTableHeader which is wrapped around a DefaultTableColumnModel object that ... After I start the application, the header of the table looks good, but the ... but why don't the cell values show up? ... TableColumn firstCol = new TableColumn; ...
    (comp.lang.java.programmer)
  • Re: Autosort, but keep Row 1 seperate
    ... The formula I'm using is in a cell that is sorted. ... "Dave Peterson" wrote: ... of my header was affecting the coding of line 2). ... want it to sort by Status first, ...
    (microsoft.public.excel.misc)
  • Re: Average price between dates
    ... where A1 is the cell with the #N/A ... Right click on the Date header in the pivottable. ... Then sort your data by this helper column. ... I would like to get the average price per month. ...
    (microsoft.public.excel.worksheet.functions)
  • Re: Month Conversion in SUMPRODUCT
    ... header row which was causing the value error. ... If every cell in the range has a date and if they're true Excel dates then ... The cell ranges were correct. ... maybe it was something like a reference missing ...
    (microsoft.public.excel.worksheet.functions)