I want combo box in jtable visible from start not when i click the cell... any idea?

Let's java.awt.Robot do it.

Sorry my drawing isnt very good.... It look like figure A , but i want it to look like Figure B from start. Any one who used combobox in table has already experienced it...

@Majestic please check my post http://stackoverflow.com/questions/6261017/how-to-add-different-jcombobox-items-in-a-column-of-a-jtable-in-swing/6261853#6261853 and then really ask the question, sure there are lots of ways how to implements that, anyway basic tutorial show this issue in low lever form http://download.oracle.com/javase/tutorial/uiswing/components/table.html#combobox examples for JTable http://www.java2s.com/Code/Java/Swing-JFC/Table.htm (TableCellRenderer + TableCellEditor)

mkorbel please check the question.................................. Thank you for your help

@Majestics, just joke, its Friday OT day > this quoestion invoked only I want to cleaned up my car <

Lucky dude...........................

Try using this for your cell renderer. You can pass it the combo box that you are using for the cell editor.

class CheckBoxCellRenderer implements TableCellRenderer {
        JComboBox combo;
        public CheckBoxCellRenderer(JComboBox comboBox) {
            this.combo = new JComboBox();
            for (int i=0; i<comboBox.getItemCount(); i++){
                combo.addItem(comboBox.getItemAt(i));
            }
        }
        public Component getTableCellRendererComponent(JTable jtable, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
            combo.setSelectedItem(value);
            return combo;
        }
    }

On your table column, column.setCellRenderer(new CheckBoxCellRenderer(comboBox));

Thanx ezzaral , i m dying to check it , if it work u rock 10000000000000000000000000 times.

Yes it worked... thanx alot... but my table has three combo boxes... it worked great for only one other two are not working properly..... any idea?

It would really depend on how you created the renders and assigned them to the column. If you did it the same way as the first then I don't see any reason why it would not work fine.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.