Swing-pre-1.0, jdk1.1.5, Solaris.
When using a JComboBox as a JTable cell editor, keyboard navigation doesn't work properly. Alt+Down arrow doesn't post menu of the JComboBox.
Name: krT82822 Date: 07/11/99
Steps to reproduce:
1. Select the table (Note that on my system the table was
not visible until I actually clicked on it. This may be another bug.)
2. Use the arrow keys to select a cell in the first column
3. Type a letter
Note that the editor appears, but no changes can be made to the cell
If the combo box arrow is selected with the mouse, then changes can be
made with the keyboard.
import javax.swing.*;
import java.util.*;
import javax.swing.table.*;
public class JTableTest
{
public static void main(String [] args)
{
//allow changing of look and feel from command line
UIManager.LookAndFeelInfo[] lfi=UIManager.getInstalledLookAndFeels();
try
{
if(args.length >0)
{
int i=new Integer(args[0]).intValue();
if(i<lfi.length)
UIManager.setLookAndFeel(lfi[i].getClassName());
}
}
catch(Exception e)
{
//System.out.println(e);
}
//set up a frame
JFrame jf=new JFrame();
jf.setVisible(true);
jf.setSize(640,480);
Vector columnNames=new Vector(5,5);
//set up some data
for(int i=0;i<5;i++)
{
columnNames.addElement("Column "+i);
}
Vector data=new Vector(5,5);
Vector d=new Vector(5,5);
for(int i=0; i<5; i++)
{
Vector p=new Vector(5,5);
p.addElement("A");
for(int j=1; j<5; j++)
{
p.addElement("Cell "+i+", "+j);
}
data.addElement(p);
}
DefaultTableModel dt=new DefaultTableModel(data,columnNames);
//create a table
JTable jt=new JTable(dt);
jt.setSize(640,480);
jt.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
//create a cell editor
Vector letters=new Vector(5,1);
letters.addElement("A");
letters.addElement("B");
letters.addElement("C");
letters.addElement("D");
letters.addElement("E");
JComboBox jb=new JComboBox(letters);
jb.setLightWeightPopupEnabled(true);
jb.setEnabled(true);
jb.setEditable(true);
DefaultCellEditor dce=new DefaultCellEditor(jb);
//set the cell editor for the column
TableColumn tc = jt.getColumn(jt.getColumnName(0));
tc.setCellEditor(dce);
jf.getContentPane().add(jt);
}
}
(Review ID: 41128)
======================================================================</TEXTAREA>
</td>
</tr>
<TR>
<TD colspan="2" bgcolor="#BFBFBF"> </td>
</tr>
<a name="comments"></a>
<!-- COMMENTS -->
<TR>
<TD bgcolor="#BFBFBF" align="left" valign="bottom" height="24">
<img src="/bugz/images/dot.gif" width="10">Comments
</td>
<TD bgcolor="#BFBFBF" align="left" valign="bottom" height="24">
<!-- BEGIN:TBR Mohan
<A href="javascript:doDateStampSubmit(document.editbug_general, 'comments');"><font size="-1">[ Date Stamp ]</font></A>
<img src="/bugz/images/dot.gif" width="18">
END:TBR -->
<A href="javascript:doFullPageSubmit(document.editbug_general, 'comments');"><font size="-1">[ Full Page ]</font></a>
<img src="/bugz/images/dot.gif" width="22">
<FONT size="-1" color="darkblue">--- Enter SUN Proprietary data here ---</font>
</td>
</tr>
<TR>
<TD bgcolor="#BFBFBF" colspan="2" nowrap align="left">
<img src="/bugz/images/dot.gif" width="5">
<TEXTAREA rows="6" cols="95" wrap="virtual" name="comments" align="left" bgcolor="white">
###@###.### 2003-09-09