JTable in JComboBox

if any one has got a code for displaying more then one column in JCombobox(i.e JTable in JComboBox)
plz. send to this mail id :- [email protected]
Hope this helps.
Regards,
chandru

do u want JTable in JCombobox or a JComboBox in a JTable?

Similar Messages

  • JTable with JComboBox

    Hi friends,
    I am adding JComboBox in JTable its working properly
    But data is not adding dynamically to JComboBox
    I am Sending my Code plz give me reply
    I am Struggleing from 1 week on wards
    package com.dnt.autopopulation;
    import javax.swing.*;
    import java.awt.*;
    import javax.swing.table.JTableHeader;
    import javax.swing.table.TableColumn;
    import java.awt.event.*;
    import javax.swing.JTable;
    import javax.swing.table.DefaultTableModel;
    import javax.swing.event.TableModelEvent;
    import java.util.ArrayList;
    import java.util.Calendar;
    import java.util.Locale;
    import java.text.SimpleDateFormat;
    import java.util.Vector;
    import javax.swing.border.*;
    import com.dnt.eaip.Connectmagr;
    import com.dnt.eaip.*;
    import com.dnt.util.*;
    import javax.swing.plaf.ButtonUI;
    import com.dnt.admin.EndStartDateCheck;
    import javax.swing.table.TableCellRenderer;
    import javax.swing.table.TableColumnModel;
    public class AutoPopRollBack extends JPanel {
    boolean selection = false;
    public static final int HAND_CURSOR = 12;
    Cursor cursor = new Cursor(HAND_CURSOR);
    int selectedRow = -1;
    ImageIcon headertop1 = new ImageIcon("./images/k2topbar.gif");
    JLabel HeaderLabe = new JLabel(headertop1);
    Border border1 = new EtchedBorder(EtchedBorder.RAISED, Color.white, Color.blue);
    Border border2 = BorderFactory.createBevelBorder(BevelBorder.RAISED,
    new Color(154, 254, 211), new Color(108, 178, 148),
    new Color(37, 60, 50), new Color(53, 87, 72));
    DefaultTableModel dm = new DefaultTableModel();
    Vector searchlist = new Vector();
    Vector rows = new Vector();
    Vector returnList;
    Connectmagr objConnectmagr = new Connectmagr();
    JFrame frame = new JFrame();
    JLabel headlab = new JLabel();
    JCalendarComboBox EndDateTxt;
    JLabel HawbLab = new JLabel();
    JTextField HawbTxt = new JTextField();
    JLabel AgentLab = new JLabel();
    JLabel StartDateLab = new JLabel();
    JCalendarComboBox StartDateTxt;
    JComboBox AgentLBox = new JComboBox();
    JLabel EnddateLab = new JLabel();
    JPanel ReviewJobsPane = new JPanel();
    JButton SearchBtn = new JButton();
    ButtonUI ui = new com.sun.java.swing.plaf.motif.MotifButtonUI();
    ArrayList AgentList = new ArrayList();
    JComboBox DocTypeLBox = new JComboBox();
    JLabel doctypelab = new JLabel();
    JPanel displayPanel = new JPanel();
    ButtonGroup group1;
    JRadioButton rb;
    JTable table;
    public ArrayList jobList = new ArrayList();
    public AutoPopRollBack(JFrame frame, ArrayList agentArrayList) {
    this.frame = frame;
    this.AgentList = agentArrayList;
    try {
    jbInit();
    } catch (Exception e) {
    e.printStackTrace();
    public void jbInit() throws Exception {
    Calendar cal = Calendar.getInstance();
    Locale loc = new Locale("");
    SimpleDateFormat dateformat = new SimpleDateFormat("dd/MM/yyyy");
    EndDateTxt = new JCalendarComboBox(cal, loc, dateformat);
    StartDateTxt = new JCalendarComboBox(cal, loc, dateformat);
    HeaderLabe.setBackground(new Color(250, 233, 216));
    HeaderLabe.setBounds(new Rectangle(0, 0, 830, 33));
    this.setLayout(null);
    this.setBackground(SystemColor.control);
    headlab.setBackground(new Color(250, 233, 216));
    headlab.setFont(new java.awt.Font("Verdana", 1, 12));
    headlab.setForeground(Color.blue);
    headlab.setHorizontalAlignment(SwingConstants.CENTER);
    headlab.setText(" :: Auto Population Rollback");
    headlab.setBounds(new Rectangle(39, 2, 247, 25));
    EndDateTxt.setBounds(new Rectangle(474, 36, 116, 18));
    EndDateTxt.setBackground(Color.white);
    EndDateTxt.setFont(new java.awt.Font("Times New Roman", 1, 10));
    EndDateTxt.setForeground(Color.blue);
    EndDateTxt.setBorder(null);
    HawbLab.setFont(new java.awt.Font("Dialog", 0, 13));
    HawbLab.setForeground(Color.blue);
    HawbLab.setHorizontalAlignment(SwingConstants.RIGHT);
    HawbLab.setText("Job No/Airway Bill No:");
    HawbLab.setBounds(new Rectangle(326, 14, 146, 18));
    HawbTxt.setBounds(new Rectangle(474, 14, 125, 18));
    HawbTxt.setText("");
    HawbTxt.setFont(new java.awt.Font("Times New Roman", 1, 10));
    HawbTxt.setForeground(Color.blue);
    HawbTxt.setBorder(border1);
    AgentLab.setFont(new java.awt.Font("Dialog", 0, 13));
    AgentLab.setForeground(Color.blue);
    AgentLab.setHorizontalAlignment(SwingConstants.RIGHT);
    AgentLab.setText("<html>Agent:<font size=\'4\' color=\"#993333\">*</font></html>");
    AgentLab.setBounds(new Rectangle(31, 14, 97, 18));
    StartDateLab.setFont(new java.awt.Font("Dialog", 0, 13));
    StartDateLab.setForeground(Color.blue);
    StartDateLab.setHorizontalAlignment(SwingConstants.RIGHT);
    StartDateLab.setText("Start Date:");
    StartDateLab.setBounds(new Rectangle(23, 36, 105, 18));
    StartDateTxt.setBounds(new Rectangle(129, 36, 116, 18));
    StartDateTxt.setBackground(Color.white);
    StartDateTxt.setFont(new java.awt.Font("Times New Roman", 1, 10));
    StartDateTxt.setForeground(Color.blue);
    StartDateTxt.setBorder(null);
    AgentLBox.setBackground(Color.white);
    AgentLBox.setFont(new java.awt.Font("Verdana", 0, 13));
    AgentLBox.setForeground(Color.blue);
    AgentLBox.setBounds(new Rectangle(129, 14, 178, 18));
    AgentLBox.setFont(new java.awt.Font("Times New Roman", 1, 10));
    EnddateLab.setFont(new java.awt.Font("Dialog", 0, 13));
    EnddateLab.setForeground(Color.blue);
    EnddateLab.setHorizontalAlignment(SwingConstants.RIGHT);
    EnddateLab.setText("End Date:");
    EnddateLab.setBounds(new Rectangle(391, 36, 81, 18));
    ReviewJobsPane.setBackground(new Color(240, 233, 216));
    ReviewJobsPane.setBorder(BorderFactory.createLineBorder(Color.black));
    ReviewJobsPane.setBounds(new Rectangle(69, 47, 705, 96));
    ReviewJobsPane.setLayout(null);
    SearchBtn.setUI(ui);
    SearchBtn.setCursor(cursor);
    SearchBtn.setBackground(new Color(76, 125, 104));
    SearchBtn.setBounds(new Rectangle(377, 153, 89, 19));
    SearchBtn.setFont(new java.awt.Font("Tahoma", 1, 10));
    SearchBtn.setForeground(Color.white);
    SearchBtn.setBorder(border2);
    SearchBtn.setOpaque(true);
    SearchBtn.setFocusPainted(false);
    SearchBtn.setText("Search");
    SearchBtn.addActionListener(new AutoPopRollBack_SearchBtn_actionAdapter(this));
    for (int i = 0; i < AgentList.size(); i++)
    AgentLBox.addItem( (String) AgentList.get(i));
    DocTypeLBox.setFont(new java.awt.Font("Verdana", 0, 13));
    DocTypeLBox.setForeground(Color.blue);
    DocTypeLBox.setMinimumSize(new Dimension(22, 19));
    DocTypeLBox.setBounds(new Rectangle(129, 58, 179, 18));
    DocTypeLBox.setFont(new java.awt.Font("Times New Roman", 1, 10));
    DocTypeLBox.addItem("New Jobs");
    DocTypeLBox.addItem("Draft jobs");
    DocTypeLBox.addItem("Finished jobs");
    doctypelab.setBounds(new Rectangle(7, 58, 121, 18));
    doctypelab.setText("<html>Document Type:<font size=\'4\' color=\"#993333\">*</font></html>");
    doctypelab.setHorizontalAlignment(SwingConstants.RIGHT);
    doctypelab.setForeground(Color.blue);
    doctypelab.setFont(new java.awt.Font("Dialog", 0, 13));
    displayPanel.setBorder(BorderFactory.createLineBorder(Color.black));
    displayPanel.setBounds(new Rectangle(69, 182, 705, 315));
    this.add(headlab, null);
    this.add(HeaderLabe, null);
    this.add(ReviewJobsPane, null);
    ReviewJobsPane.add(HawbLab, null);
    ReviewJobsPane.add(AgentLab, null);
    ReviewJobsPane.add(AgentLBox, null);
    ReviewJobsPane.add(StartDateLab, null);
    ReviewJobsPane.add(StartDateTxt, null);
    ReviewJobsPane.add(HawbTxt, null);
    ReviewJobsPane.add(EnddateLab, null);
    ReviewJobsPane.add(EndDateTxt, null);
    ReviewJobsPane.add(DocTypeLBox, null);
    ReviewJobsPane.add(doctypelab, null);
    this.add(SearchBtn, null);
    this.add(displayPanel, null);
    //this.add(scrollPaneView, null);
    // scrollPaneView.getViewport().add(displayPanel, null);
    this.setVisible(true);
    void FieldEditable(boolean str) {
    StartDateTxt.setEnabled(str);
    EndDateTxt.setEnabled(str);
    public static void main(String args[]) {
    JFrame frame = new JFrame();
    ArrayList agentlist = new ArrayList();
    agentlist.add(0, "BF0651");
    agentlist.add(1, "PF0010");
    AutoPopRollBack objAutoPopRollBack = new AutoPopRollBack(frame, agentlist);
    frame.getContentPane().add(objAutoPopRollBack);
    frame.setBounds(new Rectangle(0, 0, 820, 593));
    frame.setVisible(true);
    void SearchBtn_actionPerformed(ActionEvent e) {
    displayPanel.setVisible(false);
    Vector data=new Vector();
    rows.removeAllElements();
    boolean flag = true;
    String che = new EndStartDateCheck().crossCheck(StartDateTxt.getCalendar(), EndDateTxt.getCalendar());
    try {
    if(HawbTxt.getText().equalsIgnoreCase("")){
    if (StartDateTxt._spinner.getText().equalsIgnoreCase("")) {
    JOptionPane.showMessageDialog(this, "Please Select Start Date",
    "Warning", JOptionPane.WARNING_MESSAGE);
    flag = false;
    else if (!che.equalsIgnoreCase("")) {
    JOptionPane.showMessageDialog(frame, che, "Message Window", JOptionPane.INFORMATION_MESSAGE);
    flag = false;
    }else{
    FieldEditable(true);
    if (flag) {
    try {
    displayPanel.removeAll();
    } catch (Exception ex) {
    rows.removeAllElements();
    data.removeAllElements();
    SearchBtn.setEnabled(true);
    searchlist.add(0, AgentLBox.getSelectedItem().toString().trim());
    if (!HawbTxt.getText().trim().equalsIgnoreCase(""))
    searchlist.add(1, HawbTxt.getText().toString().trim());
    else
    searchlist.add(1, "");
    searchlist.add(2, new Integer(DocTypeLBox.getSelectedIndex() + 1));
    String startDate = new ConvertDate().convertddMM_To_MMdd(StartDateTxt._spinner.getText());
    String endDate = new ConvertDate().convertddMM_To_MMdd(EndDateTxt._spinner.getText());
    Vector columns = new Vector();
    columns.add(0, "");
    columns.add(1, "JOB No");
    columns.add(2, "Status");
    columns.add(3, "Current Form Type");
    columns.add(4, "New Form Type");
    System.out.println("Before calling Data Base");
    jobList = objConnectmagr.AutoRollBackSearch(searchlist, startDate, endDate, "AutoPopRollBack");
    if (jobList.size() > 0) {
    for (int i = 0; i < jobList.size(); i++) {
    ArrayList temp = new ArrayList();
    temp = (ArrayList) jobList.get(i);
    Vector col = new Vector();
    col.add(0, new Boolean(false));
    col.add(1, temp.get(0).toString().trim());
    col.add(2, temp.get(1).toString().trim());
    col.add(3, temp.get(2).toString().trim());
    Vector tempstr=new Vector();
    String [] tem=temp.get(3).toString().trim().split("\\|");
    tempstr.removeAllElements();
    for(int k=0;k<tem.length;k++)
    tempstr.add(k,tem[k]);
    col.add(4, new JComboBox(tempstr));
    data.add(col);
    dm.setDataVector(data, columns);
    table = new JTable(dm) {
    public void tableChanged(TableModelEvent e) {
    super.tableChanged(e);
    public boolean isCellEditable(int rowIndex, int vColIndex) {
    return true;
    JScrollPane scroll = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    table.setColumnSelectionAllowed(false);
    table.setRowSelectionAllowed(false);
    table.setCellSelectionEnabled(false);
    table.setBackground(SystemColor.inactiveCaptionText);
    table.setRowHeight(20);
    JTableHeader head = table.getTableHeader();
    head.setSize(850, 75);
    table.setTableHeader(head);
    table.getTableHeader().setFont(new Font("Verdana", Font.BOLD, 11));
    table.getTableHeader().setBackground(new Color(130, 170, 150));
    table.getTableHeader().setForeground(Color.BLUE);
    table.getTableHeader().setReorderingAllowed(false);
    table.getTableHeader().setResizingAllowed(false);
    table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
    table.setFont(new java.awt.Font("MS Sans Serif", 0, 13));
    table.setForeground(new Color(125, 25, 0));
    TableColumn col = table.getColumnModel().getColumn(0);
    col.setMinWidth(75);
    col.setMaxWidth(75);
    TableColumn col1 = table.getColumnModel().getColumn(1);
    col1.setMinWidth(150);
    col1.setMaxWidth(150);
    TableColumn col2 = table.getColumnModel().getColumn(2);
    col2.setMinWidth(150);
    col2.setMaxWidth(150);
    TableColumn col3 = table.getColumnModel().getColumn(3);
    col3.setMinWidth(150);
    col3.setMaxWidth(150);
    TableColumn col4 = table.getColumnModel().getColumn(4);
    col4.setMinWidth(160);
    col4.setMaxWidth(160);
    TableColumn tc = table.getColumnModel().getColumn(0);
    tc.setCellEditor(table.getDefaultEditor(Boolean.class));
    tc.setCellRenderer(table.getDefaultRenderer(Boolean.class));
    tc.setHeaderRenderer(new CheckBoxHeader(new MyItemListener()));
    Vector tempstr=new Vector();
    for(int j=0;j<jobList.size();j++){
    ArrayList temlist=(ArrayList)jobList.get(j);
    String [] tem=temlist.get(3).toString().trim().split("\\|");
    tempstr.removeAllElements();
    for(int k=0;k<tem.length;k++)
    tempstr.add(k,tem[k]);
    JComboBox portTypesCombo = new JComboBox(tempstr);
    col4.setCellEditor(new DefaultCellEditor(portTypesCombo));
    col4 = table.getColumnModel().getColumn(4);
    col4.setCellEditor(new MyComboBoxEditor(tempstr));
    // If the cell should appear like a combobox in its
    // non-editing state, also set the combobox renderer
    col4.setCellRenderer(new MyComboBoxRenderer(tempstr));
    System.out.println(tempstr);
    displayPanel.setLayout(new BorderLayout());
    displayPanel.add(table.getTableHeader(), BorderLayout.PAGE_START);
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    table.addMouseListener(new MouseAdapter() {
    public void mouseClicked(MouseEvent e) {
    table.setEditingColumn(0);
    int column = 0;
    if (e.getClickCount() == 1) {
    Point p = e.getPoint();
    selectedRow = table.rowAtPoint(p);
    column = table.columnAtPoint(p);
    System.out.println(table.isCellEditable(selectedRow, column));
    if (column != 0) {
    selectedRow = -1;
    returnList = new Vector();
    returnList = (Vector) rows.get(selectedRow);
    else if (column == 0) {
    table.revalidate();
    table.repaint();
    scroll.getViewport().add(table);
    displayPanel.add(scroll, BorderLayout.CENTER);
    displayPanel.setVisible(true);
    else {
    JOptionPane.showMessageDialog(this, "No Data Available");
    } catch (Exception e1) {
    e1.printStackTrace();
    class MyItemListener implements ItemListener {
    public void itemStateChanged(ItemEvent e) {
    Object source = e.getSource();
    if (source instanceof AbstractButton == false)return;
    boolean checked = e.getStateChange() == ItemEvent.SELECTED;
    for (int x = 0, y = table.getRowCount(); x < y; x++) {
    table.setValueAt(new Boolean(checked), x, 0);
    class AutoPopRollBack_SearchBtn_actionAdapter implements java.awt.event.ActionListener {
    AutoPopRollBack adaptee;
    AutoPopRollBack_SearchBtn_actionAdapter(AutoPopRollBack adaptee) {
    this.adaptee = adaptee;
    public void actionPerformed(ActionEvent e) {
    adaptee.SearchBtn_actionPerformed(e);
    class RadioButtonRenderer implements TableCellRenderer {
    public Component getTableCellRendererComponent(JTable table, Object value,
    boolean isSelected, boolean hasFocus, int row, int column) {
    if (value == null)return null;
    return (Component) value;
    class RadioButtonEditor extends DefaultCellEditor implements ItemListener {
    private JRadioButton button;
    public RadioButtonEditor(JCheckBox checkBox) {
    super(checkBox);
    public Component getTableCellEditorComponent(JTable table, Object value,
    boolean isSelected, int row,
    int column) {
    if (value == null)return null;
    button = (JRadioButton) value;
    button.addItemListener(this);
    return (Component) value;
    public Object getCellEditorValue() {
    button.removeItemListener(this);
    return button;
    public void itemStateChanged(ItemEvent e) {
    super.fireEditingStopped();
    class CheckCellRenderer extends JCheckBox implements TableCellRenderer {
    protected static Border m_noFocusBorder;
    public CheckCellRenderer() {
    super();
    m_noFocusBorder = new EmptyBorder(1, 2, 1, 2);
    setOpaque(true);
    setBorder(m_noFocusBorder);
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
    int row, int column) {
    if (value instanceof Boolean) {
    Boolean b = (Boolean) value;
    setSelected(b.booleanValue());
    setBackground(isSelected && !hasFocus ?
    table.getSelectionBackground() : table.getBackground());
    setForeground(isSelected && !hasFocus ?
    table.getSelectionForeground() : table.getForeground());
    setFont(table.getFont());
    setBorder(hasFocus ? UIManager.getBorder(
    "Table.focusCellHighlightBorder") : m_noFocusBorder);
    return this;
    class CheckBoxHeader extends JCheckBox implements TableCellRenderer, MouseListener {
    protected CheckBoxHeader rendererComponent;
    protected int column;
    protected boolean mousePressed = false;
    public CheckBoxHeader(ItemListener itemListener) {
    rendererComponent = this;
    rendererComponent.addItemListener(itemListener);
    public Component getTableCellRendererComponent(
    JTable table, Object value,
    boolean isSelected, boolean hasFocus, int row, int column) {
    if (table != null) {
    JTableHeader header = table.getTableHeader();
    if (header != null) {
    rendererComponent.setForeground(header.getForeground());
    rendererComponent.setBackground(header.getBackground());
    rendererComponent.setFont(new java.awt.Font("Verdana", 1, 10));
    header.addMouseListener(rendererComponent);
    setColumn(column);
    rendererComponent.setText("Select All");
    setBorder(UIManager.getBorder("TableHeader.cellBorder"));
    return rendererComponent;
    protected void setColumn(int column) {
    this.column = column;
    public int getColumn() {
    return column;
    protected void handleClickEvent(MouseEvent e) {
    if (mousePressed) {
    mousePressed = false;
    JTableHeader header = (JTableHeader) (e.getSource());
    JTable tableView = header.getTable();
    TableColumnModel columnModel = tableView.getColumnModel();
    int viewColumn = columnModel.getColumnIndexAtX(e.getX());
    int column = tableView.convertColumnIndexToModel(viewColumn);
    if (viewColumn == this.column && e.getClickCount() == 1 && column != -1) {
    doClick();
    public void mouseClicked(MouseEvent e) {
    handleClickEvent(e);
    ( (JTableHeader) e.getSource()).repaint();
    public void mousePressed(MouseEvent e) {
    mousePressed = true;
    public void mouseReleased(MouseEvent e) {
    public void mouseEntered(MouseEvent e) {
    public void mouseExited(MouseEvent e) {
    class MyComboBoxRenderer extends JComboBox implements TableCellRenderer {
    public MyComboBoxRenderer(Vector items) {
    super(items);
    public Component getTableCellRendererComponent(JTable table, Object value,
    boolean isSelected, boolean hasFocus, int row, int column) {
    if (isSelected) {
    setForeground(table.getSelectionForeground());
    super.setBackground(table.getSelectionBackground());
    else {
    setForeground(table.getForeground());
    setBackground(table.getBackground());
    // Select the current value
    setSelectedItem(value);
    return this;
    class MyComboBoxEditor extends DefaultCellEditor {
    public MyComboBoxEditor(Vector items) {
    super(new JComboBox(items));
    and Bringing data from data base by using this method
    if (i == 0) sqlString = "SELECT * FROM FLIGHTSEARCH WHERE AGENT_CODE='" + agentCode + "' and ISSUEDATE BETWEEN '" + startDate + "' and '" + endDate + "'";
    else sqlString = "SELECT * FROM FLIGHTSEARCH WHERE AGENT_CODE='" + agentCode + "' and JOB_NO='" + JobNo + "%'";
    st = con.createStatement();
    System.out.println("---new jobs search-->" + sqlString);
    rs = st.executeQuery(sqlString);
    while (rs.next()) {
    retVector = new ArrayList();
    retVector.add(0, rs.getString("JOBNO"));
    retVector.add(1, "New Job");
    retVector.add(2, rs.getString("DOC_TYPE"));
    String temp="";
    if(retVector.get(2).toString().trim().equalsIgnoreCase("K1")){
    temp="K8I|K8T";
    }else if(retVector.get(2).toString().trim().equalsIgnoreCase("K2")){
    temp="K8E";
    }else if(retVector.get(2).toString().trim().equalsIgnoreCase("K8I")){
    // temp="K1|K8T";
    }else if(retVector.get(2).toString().trim().equalsIgnoreCase("K8T")){
    temp="K1|K8I";
    }else if(retVector.get(2).toString().trim().equalsIgnoreCase("K8E")){
    temp="K2";
    retVector.add(3,temp);
    retVector.add(3, rs.getString("AGENT_CODE"));
    retVectorlist.add(retVector);
    i am sending data To ComboBox like this
    if(retVector.get(2).toString().trim().equalsIgnoreCase("K1")){
    K8I and K8T
    if K2 adding k8E and for other types as mentioned above
    But for ComboBoxes it is showing same Items not changing
    Please any body can help to me
    Thanks and Regards
    Ravichandra

    If you want further help post a Short, Self Contained, Compilable and Executable, Example Program ([url http://homepage1.nifty.com/algafield/sscce.html]SSCCE) that demonstrates the problem.
    And don't forget to use [url http://forum.java.sun.com/help.jspa?sec=formatting]code formatting when posting code.

  • JTable with JComboBox/JSpinner problem

    The following code has a JTable with 2 columns.The lst column has JComboBoxes, the 2nd column has JSpinners.I want to set the spinner range of values based on the selection of JComboBox. The JComboBox selections are "small" and "large". For "small" the spinner should range from 0..49, for "large" from 50..99. When a selection is made, MyTable.itemStateChanged() is called, which in turn calls SpinnerEditor.setValueRange(). This sets an array with the desired values and then sets the model with this array. However, it sets the range not only for the row in which the combo box was clicked, but all rows.
    So in MyTable.setCellComponents(), there is this:
    spinnerEditor = new SpinnerEditor(this, defaultTableModel);
    modelColumn.setCellEditor(spinnerEditor);
    If the table has n rows, are n SpinnerEditors created, or just 1?
    If 1, do n need to be created and if so, how?
    public class MyTable extends JTable implements ItemListener {
         private DefaultTableModel defaultTableModel;
         private Vector<Object> columnNameVector;
         private JComboBox jComboBox;
         private SpinnerEditor spinnerEditor;
         private final int COMBO_BOX_COLUMN = 0;
         final static int SPINNER_COLUMN = 1;
         public static String SMALL = "Small";
         public String LARGE = "Large";
         private final String[] SMALL_LARGE = {
                   SMALL,
                   LARGE };
         public MyTable(String name, Object[][] variableNameArray, Object[] columnNameArray) {
              columnNameVector = new Vector<Object>();
              // need column names in order to make copy of table model
              for (Object object : columnNameArray) {
                   columnNameVector.add(object);
              defaultTableModel = new DefaultTableModel(variableNameArray, columnNameArray);
              this.setModel(defaultTableModel)     ;
              setCellComponents();
              setListeners();
         private void setCellComponents() {
              // combo box column -----------------------------------------------
              TableColumn modelColumn = this.getColumnModel().getColumn(COMBO_BOX_COLUMN);
              jComboBox = new JComboBox(SMALL_LARGE);
              // set default values
              for (int row = 0; row < defaultTableModel.getRowCount(); row++) {
                   defaultTableModel.setValueAt(SMALL_LARGE[0], row, COMBO_BOX_COLUMN);
              modelColumn.setCellEditor(new DefaultCellEditor(jComboBox));
              DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
              renderer.setToolTipText("Click for small/large"); // tooltip
              modelColumn.setCellRenderer(renderer);
              // index spinner column ------------------------------------------------------------
              modelColumn = this.getColumnModel().getColumn(SPINNER_COLUMN);
              spinnerEditor = new SpinnerEditor(this, defaultTableModel);
              modelColumn.setCellEditor(spinnerEditor);
              renderer = new DefaultTableCellRenderer();
              renderer.setToolTipText("Click for index value"); // tooltip
              modelColumn.setCellRenderer(renderer);
         private void setListeners() {
              jComboBox.addItemListener(this);
         @Override
         public void itemStateChanged(ItemEvent event) {
              // set spinner values depending on small or large
              String smallOrLarge = (String)event.getItem();
              if (this.getEditingRow() != -1 && this.getEditingColumn() != -1) {
                   spinnerEditor.setValueRange(smallOrLarge);
         public static void main(String[] args) {
              try{
                   UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
              catch (Exception e){
                   e.printStackTrace();
              String[] columnNameArray = {"JComboBox", "JSpinner"};
              Object[][]  dataArray = {
                        {"", "0"},
                        {"", "0"},
                        {"", "0"},
              final MyTable myTable = new MyTable("called from main", dataArray, columnNameArray);
              final JFrame frame = new JFrame();
              frame.getContentPane().add(new JScrollPane(myTable));
              frame.setTitle("My Table");
              frame.setPreferredSize(new Dimension(200, 125));
              frame.addWindowListener(new WindowAdapter(){
                   @Override
                   public void windowClosing(WindowEvent e) {
              frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
              frame.setLocation(800, 400);
              frame.pack();
              frame.setVisible(true);
    public class SpinnerEditor extends AbstractCellEditor implements TableCellEditor {
         private JComponent parent;
         private DefaultTableModel defaultTableModel;
         private final JSpinner spinner = new JSpinner();
         private String[] spinValues;
         private int row;
         private int column;
         public SpinnerEditor(JTable parent, DefaultTableModel defaultTableModel ) {
              super();
              this.parent = parent;
              this.defaultTableModel = defaultTableModel;
              setValueRange(MyTable.SMALL);
              // update every time spinner is incremented or decremented
              spinner.addChangeListener(new ChangeListener(){
                   public void stateChanged(ChangeEvent e) {
                        String value = (String) spinner.getValue();
                        System.out.println ("SpinnerEditor.stateChanged(): " + value);
                        setValue(value);
         private void setValue(String value) {
              // save to equation string
              System.out.println ("SpinnerEditor.setValue(): " + value + " at (" + row + ", " + MyTable.SPINNER_COLUMN + ")");
              ((JTable) parent).setValueAt(spinner.getValue(), this.row, this.column);
         @Override
         public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column)      {
              System.out.println ("SpinnerEditor.getTableCellEditorComponent(): row: " + row + "\tcolumn: " + column);
              System.out.println ("SpinnerEditor.getTableCellEditorComponent(): value: " + value);
              this.row = row;
              this.column = column;
              return spinner;
         @Override
         public boolean isCellEditable(EventObject evt) {
              return true;
         // Returns the spinners current value.
         @Override
         public Object getCellEditorValue() {
              return spinner.getValue();
         @Override
         public boolean stopCellEditing() {
              System.out.println("SpinnerEditor.stopCellEditing(): spinner: " + spinner.getValue() + " at (" + this.row + ", " + this.column + ")");
              ((JTable) parent).setValueAt(spinner.getValue(), this.row, this.column);
              return true;
         public void setValueRange(String smallOrLarge) {
              System.out.println ("SpinnerEditor.setValueRange for " + smallOrLarge);
              final int ARRAY_SIZE = 50;
              if (MyTable.SMALL.equals(smallOrLarge)) {
                   final int MIN_SPIN_VALUE = 0;               
                   final int MAX_SPIN_VALUE = 49;
                   //System.out.println ("SpinnerEditor.setValueRange(): [" + MIN_SPIN_VALUE + ".." +  MAX_SPIN_VALUE + "]");
                   spinValues = new String[ARRAY_SIZE];
                   for (int i = MIN_SPIN_VALUE; i <= MAX_SPIN_VALUE; i++) {
                        spinValues[i] = new String(Integer.toString(i));
              else { // large
                   final int MIN_SPIN_VALUE = 50;               
                   final int MAX_SPIN_VALUE = 99;
                   //System.out.println ("SpinnerEditor.setValueRange(): [" + MIN_SPIN_VALUE + ".." +  MAX_SPIN_VALUE + "]");
                   spinValues = new String[ARRAY_SIZE];
                   for (int i = 0; i <ARRAY_SIZE; i++) {
                        spinValues[i] = new String(Integer.toString(MIN_SPIN_VALUE + i));
                   //for (int i = 0; i <ARRAY_SIZE; i++) {
                   //     System.out.println ("spinValues[" + i + "] = " + spinValues);
              System.out.println ("SpinnerEditor.setValueRange(): [" + spinValues[0] + ".." + spinValues[ARRAY_SIZE-1] + "]");
              // set model
              spinner.setModel(new SpinnerListModel(java.util.Arrays.asList(spinValues)));

    However, it sets the range not only for the row in which the combo box was clicked, but all rows. Yes, because a single editor is used by the column.
    One solution is to create two editors, then you override the getCellEditor(...) method to return the appropriated editor. Something like:
    If (column == ?)
        if (smallOrLarge)
          return the small or large spinner editor
        else
           return the large spinner editor
    else
        return super.getCellEditor(...);

  • JTable with JComboBox cells

    Hi all,
    When I make the JComboBox(es) become the cell of the JTable, the list of JComboBox is not expanded as the way a JComboBox behaves when you click on the arrow to see the whole list. I think the JComboBox is not receiving the mouse click event. Another way to say, something keeps the JComboBox from receiving the mouse click.
    Has anybody experienced this scenario?
    Frank.

    Is the table cell editable? If it isn't, that is your problem. Enable cell editing for that cell(s).
    Stephen

  • JTable CellEditor JComboBox Tab Key

    Hi,
    I use JDK 1.4.1_01 and got a JComboBox as CellEditor inside a JTable.
    Now I tried:
    table.setSurrendersFocusOnKeystroke(true);
    So the table gives up focus to the editor e.g. after the TAB Key is pressed while navigating through the table.
    But there is another Keyboard Event necessary to activate the JComboBox in the Editor (the arrow on the right becomes visible).
    Is there a possibility to make the JComboBox visible right after TAB was pressed?
    Thanks in advance!

    just a guess, didnt try it but... try to set
    public boolean shouldSelectCell(EventObject anEvent)
            return false;
    }in your cell editor
    hope it helps

  • Creating a dynamic JTable wit JComboBox

    I am trying to create a dynamic Jtable such that the first column is editable and the other columns contain JComboBoxes that contain as items all the elements of the first column. I can build the table, but I want to make it dynamic so that when the contents of a cell in the first column are changed, all the combo boxes are updated to reflect this change. In general, what is the best way to do this?

    import java.util.HashSet;
    import java.util.Vector;
    import javax.swing.DefaultCellEditor;
    import javax.swing.DefaultComboBoxModel;
    import javax.swing.JComboBox;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.event.TableModelEvent;
    import javax.swing.event.TableModelListener;
    import javax.swing.table.DefaultTableModel;
    import javax.swing.table.TableCellEditor;
    * @author Ian Schneider
    public class DynamicJTableWithJComboBox {
        public static void main(String[] args) throws Exception {
            final DefaultTableModel data = new DefaultTableModel(new Object[] {"a","b","c"},10);
            final JComboBox jcb = new JComboBox();
            data.addTableModelListener(new TableModelListener() {
                public void tableChanged(TableModelEvent e) {
                    HashSet s = new HashSet();
                    for (int i = 0; i < data.getRowCount(); i++) {
                        s.add(data.getValueAt(i,0));
                    jcb.setModel(new DefaultComboBoxModel(new Vector(s)));
            TableCellEditor tce = new DefaultCellEditor(jcb);
            JTable jt = new JTable(data);
            for (int i = 1; i < data.getColumnCount(); i++) {
                jt.getColumnModel().getColumn(i).setCellEditor(tce);
            javax.swing.JFrame f = new javax.swing.JFrame();
            f.setDefaultCloseOperation(f.EXIT_ON_CLOSE);
            f.getContentPane().add(new JScrollPane(jt));
            f.pack();
            f.setVisible(true);
    }

  • How to stop Auto Edit in JTable With JComboBox or JTextField

    Hi everybody
    I'm working with JTable and having 5 columns last 3 are hidden. First contains a Combobox Editor and Second contens JTextbox for editing. Every thing working fine except that whenever i clik the table it automatically opens its editor either JComboBox or JTextField for editing.
    I want to remove this and want to allow editing whenever user press Enter key on that column.
    I am using class
    FeeAmtEditor extends JTextField implements TableCellEditor for Textbox editing and class FeeTypeEditor extends JComboBox implements TableCellEditor for combobox edition
    another promblem that I need to press 'Escape' key to deactivate combo box or text box after entering data. This also i want to avoid.
    thanks in advance

    public void setComboBox(JComboBox cb, int columnindex)
            if(columnindex < 0 || columnindex >= getColumnCount())
                return;
            DefaultCellEditor dce = new DefaultCellEditor(cb);
            dce.setClickCountToStart(2);
            TableColumn column = jtable.getColumn(getColumnName(columnindex));
            column.setCellEditor(dce);
        }hope this help you..

  • JTable inside JComboBox

    Hi all,
    I was looking at the example
    http://forum.java.sun.com/thread.jspa?forumID=57&threadID=413291
    Please any one help me ... how I can make comboBox multicolumn ... ???
    regards,

    You need to either write your own implementation of Table Model; or use something like javax.swinf.table.DefaultTableModel. In particular, look at how getRowCount and getColumnCount are implemented.
    When you've decided on your model, just call JTable.setModel.

  • Problem with JTable and JComboBoxes in cells

    Hello,
    I've build a Table with static comboboxes in the first row. These comboboxes are static because they are used to filter the content of the table.
    I extended AbstractTableModel for the data handling and I use the DefaultCellRenderer for combobox handling.
    So far everything works fine. But if I gain focus to one combobox and then click to another cell (either table cell or another combobox) i receive a NullPointerException from within the component:
    java.lang.NullPointerException
         at javax.swing.plaf.basic.BasicTableUI$MouseInputHandler.adjustFocusAndSelection(Unknown Source)
         at javax.swing.plaf.basic.BasicTableUI$MouseInputHandler.mousePressed(Unknown Source)
         at java.awt.AWTEventMulticaster.mousePressed(Unknown Source)
         at java.awt.AWTEventMulticaster.mousePressed(Unknown Source)
         at java.awt.Component.processMouseEvent(Unknown Source)
         at java.awt.Component.processEvent(Unknown Source)
         at java.awt.Container.processEvent(Unknown Source)
         at java.awt.Component.dispatchEventImpl(Unknown Source)
         at java.awt.Container.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
         at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
         at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
         at java.awt.Container.dispatchEventImpl(Unknown Source)
         at java.awt.Window.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at java.awt.EventQueue.dispatchEvent(Unknown Source)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.run(Unknown Source)The problem is, that no error is visible on client side! I just see the NullPointerException in my console but no GUI Errors occur.
    Actually I could leave the table as it is now because there are no obvious errors but I don't think its a good job to ignore exceptions.
    Does anyone see where this problem could come from????
    Do I have to extend the BasicTableUI somehow because the exception is thrown in there???
    Thanks for any help!
    Bye Jan

    Hi brad,
    I'm using eclipse and java1.4.2_06. Isn't it enough to write the program arguments to the run configuration in eclipse?!
    I tried that but it didn't work out, I get the same error msg. :(
    But I can say that whatever happens inside the UI, the exception is thrown before I receive a mouseClicked event on the table itself. I added some kind of dummy mouse listener to the table that only prints the events to the console. Is the cell renderer or cell editor using is own MouseAdapter?
    You said: ...consume the event so the table won't react....
    How could I catch this MouseInputHandler???
    Thanx!
    Jan

  • Exception raised using JComboBox with JUComboBoxBinding in a JTable

    Hello,
    I am using JDeveloper 9.0.3.1035.
    I have a JTable bound to a bc4j view object. Now I want to use a JComboBox to select the value for a foreign key column in that Table. For this I have followed the HOWTO posted by Arno van der Kolk in Thread JClient - JTable and JComboBox which extends the OTN example "How to Add a JComboBox to a Cell in a JTable". This almost works fine except for one thing:
    In the the ComboBox I display a String value but the view attribute is of type Number. Now when I edit the column using the ComboBox and the value of the selected entry cannot be converted to Number I get an exception like the following:
    oracle.jbo.domain.DataCreationException: JBO-25009: Cannot create an object of type:oracle.jbo.domain.Number with value:030522 001
    Even after this exception is raised the database record is updated with the correct number value corresponding to the selected entry when the changes are commited. The only w/a I have found so far is to display the foreign key attribute as the first column of the JComboBox but this is not what I want. This behaviour also occurs using the aforementioned OTN example with my JDev version but the sample works with JDev 9.0.2.
    How can I get this to work using JDev 9.0.3?
    Any help is greatly appreciated.
    Regards,
    Christof Breker

    The Thread I was really referring to is:
    [JClient] HOWTO: Using databound comboboxes (for foreign keys) in a JTable
    The OTN sample can be found under:
    http://otn.oracle.com/sample_code/products/jdev/jclient/jclient_table_combo_sample.html

  • Event handling of JComboBox outside a JTable

    Hi to All,
    I've a question about JTables and JComboBoxes... I'm working on a application which holds a JTable and several JButtons and JCombBoxes. When the user clicks on a cell in the JTable, this cell will get the focus and the text will be highlighted. An action will be performed when the user clicks on a JButton (this just works fine). When the user clicks on a JComboBox also an action must be performed... but this won't work. I guess it won't work because of the JComboBox will draw a popup, and this popup will be cover the cell with the focus...
    I could not catch any event of the JComboBox...
    How can I check for a click on a JComboBox when an other component (JTable cell) has the focus?
    Thnx,

    Hi Swetha,
    Button controls in a table are available only in version 2.0 of the .NET PDK.
    In order to use Button in a table and handle its events u will have to upgrade.
    Further information about using input controls in a table is available in the How to section of the PDK documentation.
    Thanks, Reshef

  • Refresh data in JTable

    hi, i hava a problem, i have a jtable where same Data column depend from another column of the same jtable and a jtextfield that is external to jtable
    my jtable is
    jcombobox | text | text | text ecc....
    when the user change the SelectedItem of jcombobox the other column`s data is jacombobox values * external JtextField text....
    if i change the value of the external jtextfield how can i refresh the data in the jtable whitout click over all cell???
    this is the code of the My CellRender of the first column:
    public class MyComboBoxRenderer extends JComboBox implements TableCellRenderer {
        JTable jt;
        PortataUgelli pug;
        public MyComboBoxRenderer(String[] items,JTable table,PortataUgelli pu) {
            super(items);
            this.jt=table;
            this.pug=pu;
            addItemListener(new java.awt.event.ItemListener() {
                public void itemStateChanged(java.awt.event.ItemEvent evt){
                    if (jt.getSelectedColumn()==0){ //This action is only for the first column
                        String ugello= (String)getSelectedItem();
                        if (ugello==null) ugello=""+0;
                        double b=Double.parseDouble(pug.getPressione().trim());
                        String par="" + new VariID().getFunzioneUgelli(ugello,b); //this method calculate the value of the other cell
                        int sel;
                        if (jt.getSelectedRow() < 0) sel=0;
                        else sel = jt.getSelectedRow();
                        jt.setValueAt(par,sel,1); //set the value of the cell
        public Component getTableCellRendererComponent(JTable table, Object value,
                boolean isSelected, boolean hasFocus, int row, int column) {
            if (isSelected) {
                setForeground(table.getSelectionForeground());
                super.setBackground(table.getSelectionBackground());
            } else {
                setForeground(table.getForeground());
                setBackground(table.getBackground());
            // Select the current value
            setSelectedItem(value);
            return this;
    }

    It's fairly simple...
    you need to have your own custom TableModel. Extend AbstractTableModel and when you go to set a cell (to change the data in that cell) you simply fire an event with the:
    fireTableCellUpdated(int row, int column) method to let the view know that the data changed in that cell of that table changed and needs to be redrawn...
    Here's the link to the tutorial page/section on creating a custom table model and also firing events when data changes:
    http://java.sun.com/docs/books/tutorial/uiswing/components/table.html#data

  • How to enable JScrollPane in a cell of the JTable

    Hi,
    I am able to place the components into the cell of the JTable. But I am unable to interact with the components like JTable or JComboBox after inseting them into a cell of the JTable.
    This was the one of the Scenario:
    Step 1: I created One JTable named as "insertTable"and adding to JScrollPane
    Step 2: I'm able to inserted the newly created JTable ("insertTable") in to a cell of another JTable(like table inserting a table) using TableCellRenderer.
    here was the problem. I am able to insert the newly created table into the cell. the "insertTable" size is greater the Cell size. So, the "insertTable" is appering with Horizantal and Vertical Scrollbars because the "insertTable" is added to JScrollBar. but I am unable to move the scrollbars.
    please any one help me for this.

    you still didn't try to learn the difference between cellEditor vs cellRenderer - as you were advised to do more than once in recent posts.
    If you do, the answer will be obvious (to you :-). As long as you don't there's nothing to help
    Cheers
    Jeanette

  • JTable in JCombox

    hi every one.
    i write a program that puts a Jtable in JComboBox
    but this not fine work please help me if possible.
    thanks
    import javax.swing.*;
    import java.awt.*;
    class TableInComboBox extends JFrame{
         JPanel panel = new JPanel();
         JComboBox cboBox = new JComboBox();
         MyRenderer my = new MyRenderer();
         TableInComboBox() {
              cboBox.setRenderer(my);
              cboBox.addItem(new Persons("aaa","bbb"));
              cboBox.addItem(new Persons("ccc","ddd"));
              cboBox.addItem(new Persons("xxx","yyy"));
              cboBox.addItem(new Persons("1234","4321"));
              cboBox.setSelectedIndex(0);
              panel.add(cboBox);
              getContentPane().add(panel);
         public static void main(String[] args) {
              TableInComboBox frame = new TableInComboBox();
              frame.setSize(300,300);
              frame.setVisible(true);
    }//end class TableInComboBox
    class MyRenderer implements ListCellRenderer{
         JTable table = new JTable(2,4);
         public Component getListCellRendererComponent(JList list, Object value, int a, boolean isSelected, boolean hasFocus) {
         try {
                   table.setValueAt( ( (Persons)value ).getFirstName(),a,0 );
                   table.setValueAt( ( (Persons)value ).getLastName(),a,1 );
              }catch (Throwable e){}
              return table;
    }//end class MyRenderer
    class Persons {
         private String firstname,lastname;
         Persons(String firstname,String lastname){
              this.firstname=firstname;
              this.lastname=lastname;
         }//end Constructor
    String getFirstName(){
              return firstname;
         }//end getFirstName
         String getLastName(){
              return lastname;
         }//end getLastName()
    }//end class Persons

    Tom
    Another guess is that you are getting selection events from the combo box as the JTable initialises it for editing the cell valueLooks like just the opposite to me -- when the cell is selected for editing, the previously selected item in its (combobox) editor remains selected, which does not trigger a itemStateChanged event in 1.6.x as in some earlier version (not sure exactly when the behavior changed). That's why
    when i swith from one combox box to another combo box the details of the previous sombo box is displayed.The solution might be for getTableCellEditorComponent to call the same code as called by itemStateChanged which should, of course, be in a method of its own.
    But you're right, we're playing guessing games here.
    @OP: I strongly suggest that you post a SSCCE, a short program that demonstrates your problem.
    {color:#0000ff}http://mindprod.com/jgloss/sscce.html{color}
    luck, db

  • JTable in JCombo

    i want to display JTable in JComboBox
    please see this code and tell me the mistake
    import java.awt.*;
    import java.lang.Object.*;
    import javax.swing.*;
    import javax.swing.text.*;
    import java.awt.event.*;
    import javax.swing.plaf.basic.*;
    import javax.swing.plaf.metal.*;
    import java.util.*;
    import javax.swing.table.*;
    //My Custom ComboBox
    class myCombo extends JComboBox{
    protected int popupWidth;
    public myCombo(Vector vItems)
    //super(vItems);
    this.addItem(vItems);
    setUI(new myComboDefaultUI());
    //setBorder(new EtchedBorder());
    public Dimension getPopupSize() {
    Dimension size = getSize();
    if (popupWidth < 1) popupWidth = size.width;
    return new Dimension(popupWidth,
    size.height);
    //UI class controls popup size and location
    public class myComboDefaultUI extends BasicComboBoxUI{
    protected ComboPopup createPopup(){
    BasicComboPopup popup = new BasicComboPopup(comboBox){
    protected JScrollPane createScroller() {
    JScrollPane jscrollpane = new JScrollPane( list,
    ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED );
    return jscrollpane;
    }//end of method createScroller
    public void show() {
    Dimension popupSize = ((myCombo)comboBox).getPopupSize();
    popupSize.setSize( popupSize.width,
    getPopupHeightForRowCount(
    comboBox.getMaximumRowCount() ) );
    //computes popup size
    Rectangle popupBounds = computePopupBounds( 0,
    comboBox.getBounds().height, popupSize.width, popupSize.height);
    list.invalidate();
    int selectedIndex = comboBox.getSelectedIndex();
    if ( selectedIndex == -1 ) {
    list.clearSelection();
    } else {
    list.setSelectedIndex( selectedIndex );
    list.ensureIndexIsVisible( list.getSelectedIndex() );
    setLightWeightPopupEnabled(
    comboBox.isLightWeightPopupEnabled() );
    show( comboBox, popupBounds.x,
    popupBounds.y);
    return popup;
    }//end of method createPopup
    }//end of inner class myComboUI
    //My custom Renderer
    class Renderer extends javax.swing.JTable implements
    ListCellRenderer {
    int nTotalRows;
    static int nRunningRows=0;
    String columnNames[];
    /** Creates new Renderer */
    public Renderer() {
    super();
    public Renderer(int nRows, int nCols, int nListRows)
    //super(nRows,nCols);
    nTotalRows = nListRows;
    public Component getListCellRendererComponent(JList
    p1,Object rowData,int index,boolean isSelected,boolean
    cellHasFocus) {
    //FDFH fdfh;
    //if (value instanceof FDFH)
    Vector value = (Vector) rowData;
    this.setModel(new DefaultTableModel(value.size(),((Vector)value.elementAt(0)).size())) ;
    System.out.println("Value is:" + value.toString()+ ", index:" + index);
    //fdfh = (FDFH)value;
    //Put values into JTable cells
    System.out.println(value+"shekar");
    if(index != -1)
    {     for(int i=0;i<value.size();i++)
         Vector v1=(Vector)value.elementAt(i);
         for ( int j = 0; j < v1.size(); j++ ) {
         getModel().setValueAt( v1.elementAt(j), i, j ) ;
    /*     if(index<2)
         getModel().setValueAt(value,0,index);
         else{
         getModel().setValueAt(value,1,index-2);
    //getModel().setValueAt(value,0,1);
    //getModel().setValueAt(value,0,2);
    //Set JTable Size
    //setSize(700,300);
    setRowSelectionAllowed(true);
    return this;
    public class Combo2 extends JFrame{
         JPanel p=new JPanel();
         public myCombo com;
         protected int popupWidth;
         public Combo2(){
              String columnNames[][] ={{"Name", "Vorname", "Ort", "PLZ"},
              {"Mark", "Andrews", "Baseball", "1"},
              {"Tom", "Ball", "Football", "2"},
              {"Alan", "Chung", "Baseball", "3"},
              {"Jeff", "Dinkins", "Football", "4"},
              {"Amy", "Fowler", "Hockey", "5"}};
         Vector v=new Vector();
         for(int i=0;i<columnNames.length;i++)
              Vector v1=new Vector();
         for(int j=0;j<columnNames.length;j++)
         v1.addElement(columnNames[i][j]);
              v.addElement(v1);
         com=new myCombo(v);
         Renderer renderer =new Renderer(6,4,1);
         com.setRenderer(renderer);
         p.add(com);
         //com.setUI(new myComboDefaultUI());
         this.getContentPane().add(p);
         this.setSize(500,200);
         this.setVisible(true);
         public static void main (String [] arg){
              Combo2 obj=new Combo2();
    Hope this helps.
    Regards,
    chandru

    Hi,
    What is not working???
    JRG

Maybe you are looking for

  • Error on HP-UX

    Hi. I have this class. * RtsPrintReport.java * Created on 6 ottobre 2004, 1.57 package reports.print; import net.sf.jasperreports.engine.*; import net.sf.jasperreports.engine.design.*; import net.sf.jasperreports.engine.export.*; import java.io.*; im

  • Hows to get Web Results as the first entry on a page

    How do I get rid of the "ads related to" "searches related to" "featured content" in the search results? I would like "web results" to be a the top of the page. Scrolling through all the unwanted results are cumbersome to me..thank you for your time.

  • Interlaced? (jagged lines) issue when burning a disc

    I uploaded some standard definition DVD-R footage into my 2011 iMac (550gb). To get the DVD-R's vob footage into FCPX for editing, I first transferred the vob's to QT MOV's via MPEG Streamclip. I then imported it into FCPX as is (SD 640x480), then ed

  • Previously viewed items in a web search are no long highlighted

    When I do a google search, or search of any kind, previously viewed items are no longer highlighted. I have no way of knowing which items I have already viewed. == This happened == Every time Firefox opened == July 8, 2010

  • Open waveform chart in other screen.

    Hello to all! I have a front panel with two indicators, the value of those two indicators goes to waveform chart. My problem is that I need to call from run_time_menu to waveform chart and that it is opened in a screen different, appearing only wavef