Addiing ComboBox in JTable

Can any one help mee how to add combobox in jtable i am using Abstracttablemodel.

yes these the code where i am setting my editor and combobox
import java.sql.ResultSet;
import java.sql.*;
import java.util.*;
import javax.swing.JTable;
import javax.swing.table.TableCellRenderer;
import javax.swing.*;
import javax.swing.table.*;
import java.awt.*;
public class clsCustMast extends clsMSGen{
    String strQuery,
             querySrch1,
             querySrch2;
    String strTab1Rec;
    String strTableName;
    String []strTmp;
    public clsValidate val;
    public boolean flgInsrtTab1,
                       flgInsrtTab2,
                       flgErr;
    public String strCmbFrom,
                         strCmbTo;
   /* public JComboBox cmbRgn,
                          cmbCntry;*/
    int        intSlctdTab;     
    private int intCol,
                    rowCntTab1,
                    rowCntTab2;
     final static int CNS_TAB1 = 0;
     final static int CNS_TAB2 = 1;
     final static String CNS_MANDT = "1";
     final static boolean CNS_FALSE = false;
     final static boolean CNS_TRUE = true;
     final static String strUserPassword  = "manager";          
    public void disp(){
        super.disp();
        flgInsrtTab1 = CNS_FALSE;
        flgInsrtTab2 = CNS_FALSE;
        // to get all region ids from the  tble T_regionmast and populate it in the cmbReg to be displayed in the grid
        populateRegionCntryCmb();
        // to get all region ids from the  tble T_countrymast and populate it in the cmbCntry to be displayed in the grid
        //populateCntryCmb();
        intCol = 0;
        strQuery = "select a.f_custid,a.f_postcd,a.f_faxno,a.f_phoneno,a.f_regionid," +
                  " a.f_cntryid, a.f_delflag from t_custmast a,t_custtran b" +
                  " where a.f_custid = b.f_custid" +
                  " and b.f_langid = 'EN'";
        //System.out.println(strQuery);
        ResultSet Tab1Data = prcQuery(strQuery);
        try{
             ResultSetMetaData rmdTab1Dt = Tab1Data.getMetaData();
             intCol = rmdTab1Dt.getColumnCount();
             ++intCol;
             strTmp = new String[intCol+1];
             //JButton btn1;
             while (Tab1Data.next()){
                  String [] record = new String[intCol];
                  //Object [] record = new Object[intCol];
                  //btn1 = new JButton("C");
                  record[0] = new JButton("B").toString();
                  //record[0] = new Boolean(false);
                  for(int i=1; i<intCol; i++)
                 record= Tab1Data.getString(i);
          if (i==1)
cmbFrom.addItem(record[i]);
cmbTo.addItem(record[i]);
// System.out.println(record[i]);
model1.addRow(record);
model1.fireTableChanged(null);      
catch(SQLException ex)
     System.out.println("Error1");
ex.printStackTrace();
strQuery = "select f_langid, b.f_custname, f_city, f_address " +
          "from t_custmast a ,T_custtran b where " +
          "a.f_custid = b.f_custid" +
                    " and b.f_langid = 'EN'";
ResultSet Tab2Data = prcQuery(strQuery);
try{
intCol = 0;     
ResultSetMetaData rmdTab2Dt = Tab2Data.getMetaData();
intCol = rmdTab2Dt.getColumnCount();
while (Tab2Data.next()){
String [] record = new String[intCol];
for(int i=0; i<intCol;i++)
record[i]=Tab2Data.getString(i+1);
model2.addRow(record);
model2.fireTableChanged(null);
catch(SQLException ex)
     System.out.println("Error2");
ex.printStackTrace();
System.out.println(intCol);
//Connect the database and Returns the resultset corresponding to passed query     
     public ResultSet prcQuery(String strQuery){
          ResultSet resultQuery = dbCon.doQuery(strQuery);
          return resultQuery;
     public void populateRegionCntryCmb(){
          cmbRgn = new JComboBox();
          cmbCntry = new JComboBox();
          String queryRgn = "select f_regionid,f_cntryid from t_regionmast";
          ResultSet rsRgn = prcQuery(queryRgn);
          //String[] items = { "one", "two", "three", "four" };
          try{
               while(rsRgn.next()){
                    //cmbRgn.addItem(rsRgn.getString(1));
                    cmbCntry.addItem(rsRgn.getString(2));
                    //System.out.println(rsRgn.getString(1)+ " " + rsRgn.getString(2));
          }catch(SQLException ex)
{             System.out.println("Error in region cd retrieve");
ex.printStackTrace();
          System.out.println(cmbCntry.getItemAt(0));
          //cmbCntry = new JComboBox(items);
          cmbCntry.setEditable( false );
          DefaultCellEditor dceCmbCntry = new DefaultCellEditor( cmbCntry );          
          info_table.getColumnModel().getColumn(6).setCellEditor(dceCmbCntry);
          // Set the first columm to use a ComboBox as a renderer
          info_table.getColumnModel().getColumn(6).setCellRenderer(new clsComboBoxRenderer());
     public void populateCntryCmb(){
          cmbCntry = new JComboBox();
          String queryCntry = "select f_reionid,f_cntryid from t_regionmast";
          ResultSet rsCntry = prcQuery(queryCntry);
          try{
               if(!rsCntry.next()){
                    System.out.println("No Records in Country Master Table");
               }else{
                    while(rsCntry.next()){
                         cmbCntry.addItem(rsCntry.getString(1));
                         //System.out.println(rsCntry.getString(1));
          }catch(SQLException ex)
     System.out.println("Error in region cd retrieve");
ex.printStackTrace();
          System.out.println(cmbCntry.getItemAt(1));
          cmbCntry.setEditable( false );
          DefaultCellEditor dceCmbCntry = new DefaultCellEditor( cmbCntry );          
          info_table.getColumnModel().getColumn(6).setCellEditor(dceCmbCntry);
          // Set the first columm to use a ComboBox as a renderer
          info_table.getColumnModel().getColumn(6).setCellRenderer(new clsComboBoxRenderer());
     class clsComboBoxRenderer extends JComboBox implements TableCellRenderer
          public Component getTableCellRendererComponent
                    JTable info_table, Object value, boolean isSelected,
                    boolean hasFocus, int row, int column){
                         removeAllItems();
                         addItem( value );
                         return this;     
     public void add()
          String strAdd1[],
               strAdd2[];
          intSlctdTab = tabbedPane.getSelectedIndex();
          if ( intSlctdTab == CNS_TAB1){
               if ( flgInsrtTab1 == CNS_FALSE && flgInsrtTab2 == CNS_FALSE){
                    rowCntTab1 = model1.getRowCount();
                    //add a new row for both tabs when the add button is pressed while tab1 is selected.
                    //Add a new row for the tab1
                    strAdd1 = new String[8];
                    model1.addRow(strAdd1);
                    model1.fireTableChanged(null);
                    flgInsrtTab1 = CNS_TRUE;
                    //Add a new row for the tab2
                    strAdd2 = new String[4];
                    model2.addRow(strAdd2);
                    model2.fireTableChanged(null);
                    flgInsrtTab2 = CNS_TRUE;
               }else{
                    lblStatus.setText("Save the Records and then Add New one");
          }else if(intSlctdTab == CNS_TAB2){
               if ( flgInsrtTab2 = CNS_FALSE){
                    rowCntTab2 = model2.getRowCount();
                    //When a add button is pressed while selecting the 2nd tab add new row only to 2nd tab
                    strAdd2 = new String[4];
                    model2.addRow(strAdd2);
                    model2.fireTableChanged(null);
                    flgInsrtTab2 = CNS_TRUE;
               }else{
                    lblStatus.setText("Save the Records and then Add New one");
     public void save()
          // Decalrion for varaibles in the TAB1
          String strCustId,
               strDelFlg,
               strPostCd,
               strFaxNo,
               strPhNo,
               strRgnId,
               strCntryId;
boolean flag;                              
          //Assigning the values of the selected row to the corresponding fields
strCustId = model1.getValueAt(rowCntTab1,1).toString();
strPostCd = model1.getValueAt(rowCntTab1,2).toString();
strFaxNo = model1.getValueAt(rowCntTab1,3).toString();
strPhNo = model1.getValueAt(rowCntTab1,4).toString();
strRgnId = model1.getValueAt(rowCntTab1,5).toString();
strCntryId = model1.getValueAt(rowCntTab1,6).toString();
     strDelFlg = model1.getValueAt(rowCntTab1,7).toString();
     flgErr = CNS_FALSE;
     //Validation for mandatory field F_CUSTID
     flag = clsValidate.mandt(CNS_MANDT,strCustId);
if (flag == CNS_FALSE){
          lblStatus.setText("Please Enter Values for Cust Id Field");
          flgErr = CNS_TRUE;
//Validation for Mandatory field F_DELFLAG
flag = clsValidate.mandt(CNS_MANDT,strDelFlg);
if (flag == CNS_FALSE){
          lblStatus.setText("Please Enter Values for Delete Flag Field");
          flgErr = CNS_TRUE;
// if no error occurs process the insert process
if (flgErr == CNS_FALSE){
          String sqlInsrtT1;
          sqlInstrtT1 = "Insert into t_custmast'" + ( "'" +
                         " f_custid,f_delflag,f_postcd,f_faxno,f_phoneno," +
                              "f_regionid,f_cntryid '" +) "'" +
                              "(strCustId,strDelFlg,strPostCd,strFaxNo,strPhNo,strRgnId,strCntryId)";
          strTableName = "t_custmast";
     //     sqlInsrtT1 = "insert into t_custmast*/
     /*     StringBuffer InsertSQLT1 = new StringBuffer();
          strTableName = "t_custmast";
          InsertSQLT1.append("INSERT INTO " + strTableName );
          InsertSQLT1.append(" VALUES (");
               int colCntTab1 = model1.getColumnCount();
               System.out.println(colCntTab1);
          // for (int i=0; i < colCntTab1-1; i++) {
               int i = 0;
               System.out.println("Value at 2,1 " + model1.getValueAt(2,7));
               /* while(i < colCntTab1){
               System.out.println(" "+ i);
               //System.out.print( model1.getValueAt(2,i));
          //     InsertSQLT1.append(model1.getValueAt(rowCntTab1,i));
               InsertSQLT1.append(model1.getValueAt(2,i));
               if ( i != colCntTab1-1) {
                    InsertSQLT1.append(",");     
               }else{
                    InsertSQLT1.append(");");
               i++;
          //InsertSQLT1.append(");");
          // System.out.println( model1.getValueAt(rowCntTab1,7));
System.out.println(InsertSQLT1.toString());*/
public void delete(){}
public void cancel(){}
public void goTran(){}
public void Search(){
     intSlctdTab = tabbedPane.getSelectedIndex();
     if (intSlctdTab == CNS_TAB1 ){
          System.out.println(intSlctdTab);
querySrch1 = "select a.f_custid,a.f_postcd,a.f_faxno,a.f_phoneno,a.f_regionid,"
     + " a.f_cntryid, a.f_delflag from t_custmast a,t_custtran b"
                    + " where a.f_custid = b.f_custid"
                    + " and b.f_langid = 'EN'"
                    + " and a.f_custid between '" + strCmbFrom + "'"
                    + " and '" + strCmbTo + "'";
     searchCondnTab1(querySrch1);
     intSlctdTab = 3;
if ( intSlctdTab == CNS_TAB2 ){      
querySrch2 = "select f_langid, b.f_custname, f_city, f_address"
                    + " from t_custmast a ,T_custtran b "
                    + " where a.f_custid = b.f_custid"
                    + " and b.f_langid = 'EN'"
                    + " and a.f_custid between '" + strCmbFrom + "'"
                    + " and '" + strCmbTo + "'";                     
          searchCondnTab2(querySrch2);
          intSlctdTab = 3;
public void cmbFromSrch(){
     strCmbFrom = ((String)cmbFrom.getSelectedItem()).trim();
     System.out.println("Combo1 : " + strCmbFrom);
public void cmbToSrch(){
     strCmbTo = ((String)cmbTo.getSelectedItem()).trim();
     System.out.println("Combo2 : "+ strCmbTo);
     public void searchCondnTab1(String querySrch){
          System.out.println("Tab1 : " + querySrch);
ResultSet rsSrchTab1 = prcQuery(querySrch);
try{
     ResultSetMetaData rmdSrchTab1 = rsSrchTab1.getMetaData();
     intCol = rmdSrchTab1.getColumnCount();
     //increase the column count by one for the button
     ++intCol;
     //remove all datas before fetching records according to the conditions
     model1.vctData.removeAllElements();
     //adding records to the vector after fetching the records
     while (rsSrchTab1.next()){
          String [] record1 = new String[intCol];
          record1[0] = new JButton("B").toString();
          for(int i=1; i<intCol;i++)
record1[i]= rsSrchTab1.getString(i);     
model1.addRow(record1);
model1.fireTableChanged(null);      
catch(SQLException ex)
     System.out.println("Error3");
ex.printStackTrace();
     public void searchCondnTab2(String querySrch){
          System.out.println("Tab2 : " + querySrch);
          ResultSet rsSrchTab2 = prcQuery(querySrch);
     try{
     ResultSetMetaData rmdSrchTab2 = rsSrchTab2.getMetaData();
     intCol = rmdSrchTab2.getColumnCount();
     //remove all datas before fetching records according to the conditions     
     model2.vctData.removeAllElements();
     //adding records to the vector after fetching the records
     while (rsSrchTab2.next()){
     String [] record2 = new String[intCol];
     for(int i=0; i<intCol;i++)
     record2[i]= rsSrchTab2.getString(i+1);
     model2.addRow(record2);
     model2.fireTableChanged(null);     
     catch(SQLException ex)
          System.out.println("Error4");
     ex.printStackTrace();
     public static void main(String args[]){
     clsCustMast objCust = new clsCustMast();
     objCust.strUserid = "SIVAGURU";
     objCust.strTab1Name = "Basic";
     objCust.strTab2Name = "Details";
     objCust.strTitle = "Customer Maintenance";
          objCust.Tran_code = "XD01";
          objCust.strClsId = "clsCustMast";
          objCust.strLangid = "EN";
     objCust.connectDbase();
     objCust.disp();

Similar Messages

  • Problem of selecting combobox in JTable!!

    I click comboBox in jtable and choose one item
    then move mouse away
    and then click the comboBox again
    It turns out to be strange:
    the selectedItem of the comboBox changes the first item at once
    I refered to the demo "TableRenderDemo.java" in http://java.sun.com/docs/books/tutorial/uiswing/components/example-swing/TableRenderDemo.java
    I just wanna do things like that
    but for some unknown reasons,I fail
    I compared two codes but found nothing

    here I'm giving a simple sample code. Refer this..
    import javax.swing.*;
    import java.awt.event.*;
    import javax.swing.event.*;
    import javax.swing.table.*;
    import java.awt.*;
    public class Class1 extends JFrame {
    JScrollPane jScrollPane1 = new JScrollPane();
    JTable editableTable1 = new JTable(3, 3);     
    public Class1() {
    try {          
    JComboBox c = new JComboBox();
    c.setEditable(true);
    c.addItem("a");
    c.addItem("b");
    DefaultCellEditor cellEditor = new DefaultCellEditor(c);
    TableColumn tc = editableTable1.getColumnModel().getColumn(0);
    tc.setCellEditor(cellEditor);
    this.getContentPane().setLayout(null);
    jScrollPane1.setBounds(new Rectangle(25, 19, 330, 180));
    this.getContentPane().add(jScrollPane1, null);
    jScrollPane1.getViewport().add(editableTable1, null);
    addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent we) {
    System.exit(0);
    } catch(Exception e) {
    System.out.println("Exception in Class1:"+e);
    public static void main(String[] args) {
    Class1 class1 = new Class1();
    class1.setSize(400, 400);
    class1.setVisible(true);

  • Combobox in jtable

    suppose you are editing a combobox in a jtable.
    in the combobox, there are items like
    A0
    A20
    C0
    C20
    E0
    E20
    my main goal is traverse and edit the table by keyboard.
    when i go to a jcombobox, e.g. i hit the button C, it only focus the combo, not selecting item.
    JComboBox comboBox = new JComboBox(arr){
                   protected boolean processKeyBinding(KeyStroke ks, KeyEvent e,
                        int condition, boolean pressed) {
                    boolean retValue = super.processKeyBinding(ks, e, condition, pressed);
                    if (!retValue && isStartingCellEdit() && editor != null) {
                        //editor.setItem(String.valueOf(ks.getKeyChar()));
                        JComponent editorComponent = (JComponent) getEditor().getEditorComponent();
                        InputMap map = editorComponent.getInputMap(condition);
                        ActionMap am = editorComponent.getActionMap();
                        if(map!=null && am!=null && isEnabled()){
                            Object binding = map.get(ks);
                            Action action = (binding==null) ? null : am.get(binding);
                            if(action!=null){
                                 SwingUtilities.notifyAction(action, ks, e, editorComponent,
                                        e.getModifiers());
                    return retValue;
                private boolean isStartingCellEdit() {
                    JTable table = (JTable) SwingUtilities.getAncestorOfClass(
                            JTable.class, this);
                    return table != null
                            && table.isFocusOwner()
                            && !Boolean.FALSE.equals((Boolean) table
                                    .getClientProperty("JTable.autoStartsEdit"));
    };so if i want to write C20,
    when i pressed C, it selects the combo, so after pressing 2 and 0, it searches for 20.
    how can i do this not to lose the first char?

    suppose you are editing a combobox in a jtable.
    in the combobox, there are items like
    A0
    A20
    C0
    C20
    E0
    E20
    my main goal is traverse and edit the table by keyboard.
    when i go to a jcombobox, e.g. i hit the button C, it only focus the combo, not selecting item.
    JComboBox comboBox = new JComboBox(arr){
                   protected boolean processKeyBinding(KeyStroke ks, KeyEvent e,
                        int condition, boolean pressed) {
                    boolean retValue = super.processKeyBinding(ks, e, condition, pressed);
                    if (!retValue && isStartingCellEdit() && editor != null) {
                        //editor.setItem(String.valueOf(ks.getKeyChar()));
                        JComponent editorComponent = (JComponent) getEditor().getEditorComponent();
                        InputMap map = editorComponent.getInputMap(condition);
                        ActionMap am = editorComponent.getActionMap();
                        if(map!=null && am!=null && isEnabled()){
                            Object binding = map.get(ks);
                            Action action = (binding==null) ? null : am.get(binding);
                            if(action!=null){
                                 SwingUtilities.notifyAction(action, ks, e, editorComponent,
                                        e.getModifiers());
                    return retValue;
                private boolean isStartingCellEdit() {
                    JTable table = (JTable) SwingUtilities.getAncestorOfClass(
                            JTable.class, this);
                    return table != null
                            && table.isFocusOwner()
                            && !Boolean.FALSE.equals((Boolean) table
                                    .getClientProperty("JTable.autoStartsEdit"));
    };so if i want to write C20,
    when i pressed C, it selects the combo, so after pressing 2 and 0, it searches for 20.
    how can i do this not to lose the first char?

  • Combobox in jtable two tab problem

    Hi all,
    If i am using combobox for one of the columns of jtable with custom editor and renderer, it needs two tab for navigation between the cells.
    How can i make it as 'one tab navigation'. Even i tried with 'isManagingfocus() return true' but...no effect.
    thanx in advance.
    S.A.Radha.

    here I'm giving a simple sample code. Refer this..
    import javax.swing.*;
    import java.awt.event.*;
    import javax.swing.event.*;
    import javax.swing.table.*;
    import java.awt.*;
    public class Class1 extends JFrame {
    JScrollPane jScrollPane1 = new JScrollPane();
    JTable editableTable1 = new JTable(3, 3);     
    public Class1() {
    try {          
    JComboBox c = new JComboBox();
    c.setEditable(true);
    c.addItem("a");
    c.addItem("b");
    DefaultCellEditor cellEditor = new DefaultCellEditor(c);
    TableColumn tc = editableTable1.getColumnModel().getColumn(0);
    tc.setCellEditor(cellEditor);
    this.getContentPane().setLayout(null);
    jScrollPane1.setBounds(new Rectangle(25, 19, 330, 180));
    this.getContentPane().add(jScrollPane1, null);
    jScrollPane1.getViewport().add(editableTable1, null);
    addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent we) {
    System.exit(0);
    } catch(Exception e) {
    System.out.println("Exception in Class1:"+e);
    public static void main(String[] args) {
    Class1 class1 = new Class1();
    class1.setSize(400, 400);
    class1.setVisible(true);

  • Size of combobox in JTable with custom cell editor

    Hi All -
    I have a JTable that displays a combobox in certain cells. I have a custom table model, renderer, and editor. All of that works fine. I render the combobox with the renderer, and then return the combobox as an editor in the editor so that it can drop down and actually be of use. My problem is - I set the size of the combobox with a setBounds call in the renderer, I add it to a panel, and return the panel - because I dont want the combobox to take up the entire space of the cell. This approach fails in the editor. The setBounds and setSize calls have no effect. As soon as you click the combobox, the editor takes over and all of a sudden the combobox resizes to the entire area of the cell. I assume this is because in the editor you arent actually placing anything - your simply returning the "editing form" of the component.
    So - anybody know of a way to work around this? Worst case, I could just allow the combobox to use the entire area of the cell - but it makes it uglier so I figured I would run it by the forums.
    Eric

    Rather than just redirect you to my previous answer from ages ago, I'll just give it again. :-)
    You can actually do this, but you have to get tricky. By default, the dropdown's width will be the same width as the cell... but it doesn't have to be that way. Essentially what you have to do is override the UI (MetalComboBoxUI) for the combo component. In your new customized UI component subclass (that you set the combo to use), modify the the createPopup() method of this UI class, and add your own logic to set the size of the popup before you return it.
    Ideally the size would be based on the computed max width of a rendered item shown in the combo, but really you could set it to whatever just to see how it works.

  • Combobox in JTable question

    Hello,
    I have to make a button in a JTable that is activated with a right button and then like in a combobox appears a menue and every item in this menue should be activated with the left button and perform some action. Like in windows right click and then select smth.
    My question is should I do it with Combobox and if yes how to activate it with the right button because it always listens to left button. It is implemented with action listener and I tried mouse listener but it wouldn"t listen to that. I will be glad to any solutions.
    Thanx,
    Miroslav

    Hi,
    And thank you for the answer. i think I will use jpop menu as u sujested(Thank you for that). Now I should only see how to make the render and the editor to put it in a cell in a JTable.
    It should be activated with the right button, beacause my task is such and because I also think that it is better this way. II mean it is more natural than with the left button.
    Miroslav

  • Escape key "dies" in combobox and JTable

    I have set in my JDialog the default key ESCAPE as this standard code:
              KeyStroke escKey = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
              int param = JComponent.WHEN_IN_FOCUSED_WINDOW;
              root.getInputMap(param).put(escKey, "close");
              root.getActionMap().put("close", actionCancel);
         this.btCancel.setAction(actionCancel);
    The problem is when I have JComboBoxs and JTables. All key events seem to be consumed
    In this components (and maybe more components). So, if I press ESCAPE and my focus
    in a combobox, the dialog won't close.
    How could I work around this?
    thank you

    I've got the solution!
    I have a javaBean (JPanel) that has only one JComboBox. I trigger key pressed (don't know
    if should be key released in this case) on comboBox. Then I check if...
    this.comboBox.isPopupVisible().
    Simple. If popup is not visible and dispatch the event to this.
    I just wonder how the event goes to my javaBean, my javabean is in a dialog and this
    dialog of mine ends up to catch the event. ???
    Ok, this stays has a solution for future developers to found - in case they guess that
    right keywords :)

  • Click ComboBox in JTable to times before editing ?

    Hi,
    I have a JComboBox in a JTable.
    Now I want to open the ComboBox when
    you click the cell to times.
    There is a method in DefaultCellEditor called
    setClickCountToStart(int).
    But how can I get the reference to the DefaultCellEditor
    from my JTable. There is only a method theTable.getDefaultEditor
    which returns TableCellEditor ?
    Thanx Stephan

    I made it run right in jdk1.3.1 throgh chage the setSelectedItem Method, code is follow:
    public void setSelectedItem(Object item) {
        this.insertItemAt(item, 0);
        if(getItemCount() > 1) {
          this.removeItemAt(1);
        super.setSelectedItem(item);
    }

  • How to have a combobox in JTable column header?

    Any simple ways for doing this? I am trying to get a filter to a JTable, so that only the rows containing the selected value in that column would be shown.
    I first need to get this combobox into the header of a column.

    Thanks.
    I have already tried with this way, but it was too long and complicated to implement into my file.
    Could someone post the principles here.
    Like this:
    // create my combobox
    JComboBox myBox = new JComboBox();
    myBox.addItem("Cat");
    myBox.addItem("Dog");
    // put the combobox to column header
    ??? ANY CODE HERE ???
    Tnx ahead!
    OK!
    AUlo

  • How to add  ComboBox in Jtable Header

    Hello everyone,
    I want to add a Combox box in JTable Header .Basically it works as central access to whole table e.g. by selecting delete row in combo box then it should delete the current selected row.If somebody has any idea please share it.
    Thanks in advance.

    The individual headers are not Swing components and therefore do not respond to mouse events in the same way as Swing components. Why don't you just have a popup menu that is positioned over the currently selected row? If you want to apply an action to all selected rows then have a set of buttons placed above the table header.

  • Error.  Combobox in JTable in 10.1.3 EA

    (oracle.jbo.AttrSetValException) JBO-27010: Attribute set with value oracle.jbo.server.ViewRowImpl@1b for Ediz in AppModule.UgSfpView2 has invalid precision/scale
    Type of "Ediz" is VARCHAR2(5)

    Hi,
    can you provide a step-by-step description using the EMP Table of what you did to get to this state ?
    Frank

  • Need combobox with a Jtable to view client & server files

    Hellow Everybody,
    I am quite new to Java, although I have experience with other
    programming languages.
    I have searched for tutorials, code, examples etc. but have not found
    much that can help me so far. I am a BCA student & I am appearing for my last year exams. I studied about various Java programs in my course and I decided to make a Swing based FTP Server. Although I not expert in Java , but I have learnt the network programming very much clearly, and that�s why by the help these I wrote a program but it not complete. I have given the program below.
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.Cursor;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import java.awt.event.WindowListener;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.OutputStream;
    import java.util.StringTokenizer;
    import javax.swing.JButton;
    import javax.swing.JFileChooser;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JPasswordField;
    import javax.swing.JProgressBar;
    import javax.swing.JScrollPane;
    import javax.swing.JTextArea;
    import javax.swing.JTextField;
    import javax.swing.SwingUtilities;
    import javax.swing.border.BevelBorder;
    import javax.swing.border.EmptyBorder;
    import sun.net.TelnetInputStream;
    import sun.net.ftp.FtpClient;
    public class Client extends JFrame {
    public static int BUFFER_SIZE = 10240;
    protected JTextField userNameTextField = new JTextField("anonymous");
    protected JPasswordField passwordTextField = new JPasswordField(10);
    protected JTextField urlTextField = new JTextField(20);
    protected JTextField fileTextField = new JTextField(10);
    protected JTextArea monitorTextArea = new JTextArea(5, 20);
    protected JProgressBar m_progress = new JProgressBar();
    protected JButton putButton = new JButton("Upload <<");
    protected JButton getButton;
    protected JButton fileButton = new JButton("File");
    protected JButton closeButton = new JButton("Close");
    protected JFileChooser fileChooser = new JFileChooser();
    protected FtpClient ftpClient;
    protected String localFileName;
    protected String remoteFileName;
    public Client() {
    super("FTP Client");
    JPanel p = new JPanel();
    p.setBorder(new EmptyBorder(5, 5, 5, 5));
    p.add(new JLabel("User name:"));
    p.add(userNameTextField);
    p.add(new JLabel("Password:"));
    p.add(passwordTextField);
    p.add(new JLabel("URL:"));
    p.add(urlTextField);
    p.add(new JLabel("File:"));
    p.add(fileTextField);
    monitorTextArea.setEditable(false);
    JScrollPane ps = new JScrollPane(monitorTextArea);
    p.add(ps);
    m_progress.setStringPainted(true);
    m_progress.setBorder(new BevelBorder(BevelBorder.LOWERED, Color.white,
    Color.gray));
    m_progress.setMinimum(0);
    JPanel p1 = new JPanel(new BorderLayout());
    p1.add(m_progress, BorderLayout.CENTER);
    p.add(p1);
    ActionListener lst = new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    if (connect()) {
    Thread uploader = new Thread() {
    public void run() {
    putFile();
    disconnect();
    uploader.start();
    putButton.addActionListener(lst);
    putButton.setMnemonic('U');
    p.add(putButton);
    getButton = new JButton("Download >>");
    lst = new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    if (connect()) {
    Thread downloader = new Thread() {
    public void run() {
    getFile();
    disconnect();
    downloader.start();
    getButton.addActionListener(lst);
    getButton.setMnemonic('D');
    p.add(getButton);
    lst = new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    if (fileChooser.showSaveDialog(Client.this) != JFileChooser.APPROVE_OPTION)
    return;
    File f = fileChooser.getSelectedFile();
    fileTextField.setText(f.getPath());
    fileButton.addActionListener(lst);
    fileButton.setMnemonic('f');
    p.add(fileButton);
    lst = new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    if (ftpClient != null)
    disconnect();
    else
    System.exit(0);
    closeButton.addActionListener(lst);
    closeButton.setDefaultCapable(true);
    closeButton.setMnemonic('g');
    p.add(closeButton);
    getContentPane().add(p, BorderLayout.CENTER);
    fileChooser.setCurrentDirectory(new File("."));
    fileChooser
    .setApproveButtonToolTipText("Select file for upload/download");
    WindowListener wndCloser = new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
    disconnect();
    System.exit(0);
    addWindowListener(wndCloser);
    setSize(720, 240);
    setVisible(true);
    public void setButtonStates(boolean state) {
    putButton.setEnabled(state);
    getButton.setEnabled(state);
    fileButton.setEnabled(state);
    protected boolean connect() {
    monitorTextArea.setText("");
    setButtonStates(false);
    closeButton.setText("Cancel");
    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    String user = userNameTextField.getText();
    if (user.length() == 0) {
    setMessage("Please enter user name");
    setButtonStates(true);
    return false;
    String password = new String(passwordTextField.getPassword());
    String sUrl = urlTextField.getText();
    if (sUrl.length() == 0) {
    setMessage("Please enter URL");
    setButtonStates(true);
    return false;
    localFileName = fileTextField.getText();
    // Parse URL
    int index = sUrl.indexOf("//");
    if (index >= 0)
    sUrl = sUrl.substring(index + 2);
    index = sUrl.indexOf("/");
    String host = sUrl.substring(0, index);
    sUrl = sUrl.substring(index + 1);
    String sDir = "";
    index = sUrl.lastIndexOf("/");
    if (index >= 0) {
    sDir = sUrl.substring(0, index);
    sUrl = sUrl.substring(index + 1);
    remoteFileName = sUrl;
    try {
    setMessage("Connecting to host " + host);
    ftpClient = new FtpClient(host);
    ftpClient.login(user, password);
    setMessage("User " + user + " login OK");
    setMessage(ftpClient.welcomeMsg);
    ftpClient.cd(sDir);
    setMessage("Directory: " + sDir);
    ftpClient.binary();
    return true;
    } catch (Exception ex) {
    setMessage("Error: " + ex.toString());
    setButtonStates(true);
    return false;
    protected void disconnect() {
    if (ftpClient != null) {
    try {
    ftpClient.closeServer();
    } catch (IOException ex) {
    ftpClient = null;
    Runnable runner = new Runnable() {
    public void run() {
    m_progress.setValue(0);
    putButton.setEnabled(true);
    getButton.setEnabled(true);
    fileButton.setEnabled(true);
    closeButton.setText("Close");
    Client.this.setCursor(Cursor
    .getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    SwingUtilities.invokeLater(runner);
    protected void getFile() {
    if (localFileName.length() == 0) {
    localFileName = remoteFileName;
    SwingUtilities.invokeLater(new Runnable() {
    public void run() {
    fileTextField.setText(localFileName);
    byte[] buffer = new byte[BUFFER_SIZE];
    try {
    int size = getFileSize(ftpClient, remoteFileName);
    if (size > 0) {
    setMessage("File " + remoteFileName + ": " + size + " bytes");
    setProgressMaximum(size);
    } else
    setMessage("File " + remoteFileName + ": size unknown");
    FileOutputStream out = new FileOutputStream(localFileName);
    InputStream in = ftpClient.get(remoteFileName);
    int counter = 0;
    while (true) {
    int bytes = in.read(buffer);
    if (bytes < 0)
    break;
    out.write(buffer, 0, bytes);
    counter += bytes;
    if (size > 0) {
    setProgressValue(counter);
    int proc = (int) Math
    .round(m_progress.getPercentComplete() * 100);
    setProgressString(proc + " %");
    } else {
    int kb = counter / 1024;
    setProgressString(kb + " KB");
    out.close();
    in.close();
    } catch (Exception ex) {
    setMessage("Error: " + ex.toString());
    protected void putFile() {
    if (localFileName.length() == 0) {
    setMessage("Please enter file name");
    byte[] buffer = new byte[BUFFER_SIZE];
    try {
    File f = new File(localFileName);
    int size = (int) f.length();
    setMessage("File " + localFileName + ": " + size + " bytes");
    setProgressMaximum(size);
    FileInputStream in = new FileInputStream(localFileName);
    OutputStream out = ftpClient.put(remoteFileName);
    int counter = 0;
    while (true) {
    int bytes = in.read(buffer);
    if (bytes < 0)
    break;
    out.write(buffer, 0, bytes);
    counter += bytes;
    setProgressValue(counter);
    int proc = (int) Math
    .round(m_progress.getPercentComplete() * 100);
    setProgressString(proc + " %");
    out.close();
    in.close();
    } catch (Exception ex) {
    setMessage("Error: " + ex.toString());
    protected void setMessage(final String str) {
    if (str != null) {
    Runnable runner = new Runnable() {
    public void run() {
    monitorTextArea.append(str + '\n');
    monitorTextArea.repaint();
    SwingUtilities.invokeLater(runner);
    protected void setProgressValue(final int value) {
    Runnable runner = new Runnable() {
    public void run() {
    m_progress.setValue(value);
    SwingUtilities.invokeLater(runner);
    protected void setProgressMaximum(final int value) {
    Runnable runner = new Runnable() {
    public void run() {
    m_progress.setMaximum(value);
    SwingUtilities.invokeLater(runner);
    protected void setProgressString(final String string) {
    Runnable runner = new Runnable() {
    public void run() {
    m_progress.setString(string);
    SwingUtilities.invokeLater(runner);
    public static int getFileSize(FtpClient client, String fileName)
    throws IOException {
    TelnetInputStream lst = client.list();
    String str = "";
    fileName = fileName.toLowerCase();
    while (true) {
    int c = lst.read();
    char ch = (char) c;
    if (c < 0 || ch == '\n') {
    str = str.toLowerCase();
    if (str.indexOf(fileName) >= 0) {
    StringTokenizer tk = new StringTokenizer(str);
    int index = 0;
    while (tk.hasMoreTokens()) {
    String token = tk.nextToken();
    if (index == 4)
    try {
    return Integer.parseInt(token);
    } catch (NumberFormatException ex) {
    return -1;
    index++;
    str = "";
    if (c <= 0)
    break;
    str += ch;
    return -1;
    public static void main(String argv[]) {
    new Client();
    The above given code is not yet complete. I want some specific features to be implemented in this code that is given below.
    1.     A login Gridlayout or Borderlayout & within it the username & password textfield.
    2.     When the username and password will request to server and if it will success then the textfields of the username & password have to be disable.
    3 . Two Combobox. One will give client directories and files and another
    will give the server directories and files.
    4 . Below the Combobox two JTable will be given & the tables wll show the
    client and server directories and files.
    Could anybody give me the codes that I want. If anybody check this code please help me????
    With Regards,
    DILLU

    Well Mr Michael_Dunn,
    Thanks for responding my query. First of all I would like to tell that
    this FTP server is going to be my project and that's why I am submmiting my question. I told in my points that I want a Jcombobox & a JTable for displaying that files & directories. whenever I set the directories in the combobox the files will be displayed in the JTable
    I hope you understand my point

  • How to add a JMenubar and a JTable in a JFrame in a single application

    Hi all,
    I require an urgent help from you.I am a beginer in programming Swing.I want to add a menu,combobox,and a table in a single application.I did coding as below:
    package com.BSS;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.table.*;
    import javax.swing.border.*;
    import javax.swing.event.*;
    public class newssa extends JFrame
         public JMenuBar menuBar;
         public JToolBar toolBar;
         public JFrame frame;
         private JLabel jLabel1;
         private JLabel jLabel2;
         private JLabel jLabel3;
         private JLabel jLabel4;
         private JLabel jLabel5;
         private JLabel jLabel6;
         private JComboBox jComboBox1;
         private JComboBox jComboBox2;
         private JComboBox jComboBox3;
         private JComboBox jComboBox4;
         private JComboBox jComboBox5;
         private JComboBox jComboBox6;
         private JTable jTable1;
         private JScrollPane jScrollPane1;
         private JPanel contentPane;
         public newssa()
              super();
              initializeComponent();
              this.setVisible(true);
         private void initializeComponent()
              jLabel1 = new JLabel();
              jLabel2 = new JLabel();
              jLabel3 = new JLabel();
              jLabel4 = new JLabel();
              jLabel5 = new JLabel();
              jLabel6 = new JLabel();
              jComboBox1 = new JComboBox();
              jComboBox2 = new JComboBox();
              jComboBox3 = new JComboBox();
              jComboBox4 = new JComboBox();
              jComboBox5 = new JComboBox();
              jComboBox6 = new JComboBox();
              frame=new JFrame();
              //Included here
              JMenuBar menuBar = new JMenuBar();
              JMenu general = new JMenu("General");
         menuBar.add(general);
         JMenu actions =new JMenu("Actions");
         menuBar.add(actions);
         JMenu view=new JMenu("View");
         menuBar.add(view);
         JMenu Timescale=new JMenu("TimeScale");
         menuBar.add(Timescale);
         Timescale.add("Today CTRL+D");
         Timescale.add("Current Week CTRL+W");
         Timescale.add("Current Month CTRL+M");
         Timescale.add("Current Quarter CTRL+Q");
         Timescale.add("Current Year CTRL+Y");
         Timescale.add("Custom TimeScale CTRL+U");
         JMenu start=new JMenu("Start");
         menuBar.add(start);
         JMenu options=new JMenu("Options");
         menuBar.add(options);
         JMenu help=new JMenu("Help");
         menuBar.add(help);
         JFrame.setDefaultLookAndFeelDecorated(true);
         frame.setJMenuBar(menuBar);
         frame.pack();
         frame.setVisible(true);
         toolBar = new JToolBar("Formatting");
         toolBar.addSeparator();
              //Before this included new
              String columnNames[] = { "ColorStatus", "Flash", "Service Order","Configuration","Configuration Description"};
              // Create some data
              String dataValues[][] =
                   { "blue", "flash", "ORT001" },
                   { "AVCONF", "av configuration with warrenty"}
              // Create a new table instance
              //jTable1 = new JTable( dataValues, columnNames );
              jTable1 = new JTable(dataValues,columnNames);
              jScrollPane1 = new JScrollPane(jTable1);
              contentPane = (JPanel)this.getContentPane();
              //scrollPane = new JScrollPane( table );
              //topPanel.add( scrollPane, BorderLayout.CENTER );
              // jLabel1
              jLabel1.setText("Service Centers");
              // jLabel2
              jLabel2.setText("Service Areas");
              // jLabel4
              jLabel3.setText("Skills");
              jLabel4.setText("Availablity Types");
              // jLabel5
              jLabel5.setText("From Date");
              // jLabel6
              jLabel6.setText("To");
              // jComboBox1
              jComboBox1.addItem("Coimbatore");
              jComboBox1.addItem("Chennai");
              jComboBox1.addItem("Mumbai");
              jComboBox1.addItem("New Delhi");
              jComboBox1.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e)
                        jComboBox1_actionPerformed(e);
              // jComboBox2
              jComboBox2.addItem("North Zone");
              jComboBox2.addItem("South Zone");
              jComboBox2.addItem("Central Zone");
              jComboBox2.addItem("Eastern Zone");
              jComboBox2.addItem("Western Zone");
              jComboBox2.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e)
                        jComboBox2_actionPerformed(e);
              // jComboBox3
              jComboBox3.addItem("Microsoft Components");
              jComboBox3.addItem("Java Technologies");
              jComboBox3.addItem("ERP");
              jComboBox3.addItem("Others");
              jComboBox3.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e)
                        jComboBox3_actionPerformed(e);
              // jComboBox4
              jComboBox4.addItem("One");
              jComboBox4.addItem("Two");
              jComboBox4.addItem("Three");
              jComboBox4.addItem("Four");
              jComboBox4.addItem("Five");
              jComboBox4.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e)
                        jComboBox4_actionPerformed(e);
              // jComboBox5
              jComboBox5.addItem("12/12/2004");
              jComboBox5.addItem("13/12/2004");
              jComboBox5.addItem("14/12/2004");
              jComboBox5.setEditable(true);
              jComboBox5.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e)
                        jComboBox5_actionPerformed(e);
              // jComboBox6
              jComboBox6.addItem("12/11/2004");
              jComboBox6.addItem("13/11/2004");
              jComboBox6.addItem("14/11/2004");
              jComboBox6.setEditable(true);
              jComboBox6.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e)
                        jComboBox6_actionPerformed(e);
              // jTable1
              jTable1.setModel(new DefaultTableModel(4, 4));
              // jScrollPane1
              jScrollPane1.setViewportView(jTable1);
              // contentPane
              contentPane.setLayout(null);
              addComponent(contentPane, jLabel1, 2,29,84,18);
              addComponent(contentPane, jLabel2, 201,33,76,18);
              addComponent(contentPane, jLabel3, 384,32,59,18);
              addComponent(contentPane, jLabel4, 2,77,85,18);
              addComponent(contentPane, jLabel5, 197,79,84,18);
              addComponent(contentPane, jLabel6, 384,80,60,18);
              addComponent(contentPane, jComboBox1, 85,32,100,22);
              addComponent(contentPane, jComboBox2, 276,32,100,22);
              addComponent(contentPane, jComboBox3, 419,30,100,22);
              addComponent(contentPane, jComboBox4, 88,76,100,22);
              addComponent(contentPane, jComboBox5, 276,79,100,22);
              addComponent(contentPane, jComboBox6, 421,78,100,22);
              addComponent(contentPane, jScrollPane1, 33,158,504,170);
              // newssa
              this.setTitle("SSA Service Scheduler");
              this.setLocation(new Point(0, 0));
              this.setSize(new Dimension(560, 485));
         /** Add Component Without a Layout Manager (Absolute Positioning) */
         private void addComponent(Container container,Component c,int x,int y,int width,int height)
              c.setBounds(x,y,width,height);
              container.add(c);
         // TODO: Add any appropriate code in the following Event Handling Methods
         private void jComboBox1_actionPerformed(ActionEvent e)
              int index = jComboBox1.getSelectedIndex();
              switch(index)
                   case 0: System.out.println("Area Coimbatore Selected "); break;
                   case 1: System.out.println("Area Chennai selected"); break;
                   case 2: System.out.println("Mumbai being selected"); break;
                   case 3: System.out.println("New Delhi being selected"); break;
         private void jComboBox2_actionPerformed(ActionEvent e)
              int index = jComboBox2.getSelectedIndex();
              switch(index)
                   case 0: System.out.println("North Zone Selcted "); break;
                   case 1: System.out.println("South Zone being selected"); break;
                   case 2: System.out.println("Central Zone being selected"); break;
                   case 3: System.out.println("Eastern Zone being selected"); break;
                   case 4: System.out.println("Western Zone being selected"); break;
         private void jComboBox3_actionPerformed(ActionEvent e)
              int index = jComboBox3.getSelectedIndex();
              switch(index)
                   case 0: System.out.println("Microsoft Components being selected"); break;
                   case 1: System.out.println("Java Technologies being selected"); break;
                   case 2: System.out.println("ERP Tehnologies being selected"); break;
                   case 3: System.out.println("Other's selected"); break;
         private void jComboBox4_actionPerformed(ActionEvent e)
              int index = jComboBox4.getSelectedIndex();
              switch(index)
                   case 0: System.out.println("One selected"); break;
                   case 1: System.out.println("Two selected"); break;
                   case 2: System.out.println("Three selected"); break;
                   case 3: System.out.println("Four selected"); break;
                   case 4: System.out.println("Five selected"); break;
         private void jComboBox5_actionPerformed(ActionEvent e)
              int index = jComboBox5.getSelectedIndex();
              switch(index)
                   case 0: System.out.println("12/12/2004 being selected"); break;
                   case 1: System.out.println("13/12/2004 being selected"); break;
                   case 2: System.out.println("14/12/2004 being selected"); break;
         private void jComboBox6_actionPerformed(ActionEvent e)
              int index = jComboBox6.getSelectedIndex();
              switch(index)
                   case 0: System.out.println("12/11/2004 being selected"); break;
                   case 1: System.out.println("13/11/2004 being selected"); break;
                   case 2: System.out.println("14/11/2004 being selected"); break;
         public static void main(String[] args)
              newssa ssa=new newssa();
              //JFrame.setDefaultLookAndFeelDecorated(true);
              //JDialog.setDefaultLookAndFeelDecorated(true);
              //JFrame frame = new JFrame("SSA Service Scheduler");
    //frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    //frame.setJMenuBar(ssa.menuBar);
    //frame.getContentPane( ).add(ssa.toolBar, BorderLayout.NORTH);
    //frame.getContentPane( ).add(ssa.pane, BorderLayout.CENTER);
    //frame.pack( );
    //frame.setVisible(true);
              try
                   //UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
                   UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
              catch (Exception ex)
                   System.out.println("Failed loading L&F: ");
                   System.out.println(ex);
    But as a O/P ,I am getting menu in a seperate windos and the rest of the combobox and jtable in a seperate window.Kindly help me to solve the application.
    VERY URGENT PLEASE..
    Thanks in advance
    with kind regds
    Satheesh.K

    But did u mean this as the next problem,Which I will come across..Yes, the second setVisible(true) seemed to be producing a smaller frame behind the main frame.
    And your JMenuBar is declared twice, but not sure if this will affect the code - haven't read it all.

  • JComboBox in Jtable - Urgent!!!!

    Hi folks,
    I am using my owm editor for combobox in jtable. My problem is when I am editing the combobox, value is set only after I press enter or click on the other row. But I want to set the values when i change the selection in the combobox. How can I do that. It is very URGENT!! I appreciate any help.
    My code for editor :
    class comboEditor extends DefaultCellEditor
    public comboEditor (JComboBox b)
    super(new JComboBox()); //Unfortunately, the constructor
    //expects a check box, combo box,
    //or text field.
    editorComponent = b;
    setClickCountToStart(1); //This is usually 1 or 2.
    //Must do this so that editing stops when appropriate.
    b.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent e)
    fireEditingStopped();
    b.addItemListener(new ItemListener()
    public void itemStateChanged(ItemEvent e)
         fireEditingStopped();
    protected void fireEditingStopped()
    super.fireEditingStopped();
    public Object getCellEditorValue()
    return editorComponent;
    public Component getTableCellEditorComponent(JTable table,
    Object value,
    boolean isSelected,
    int row,
    int column)
    editorComponent = (JComboBox)value;
    return editorComponent;
    Thank you very much.

    Thanks Greg. But my problem is when I select an item in the combobox still that column contains combobox in the table which I don't want. I want the combobox to be dissappear as soon as I select an item. This is important for me as I can change the values in the table dynamically by selecting the different panels underneath the dialog which contains this table. So, if user selects an item in the combobox ( without clicking the enter key)and then selects another panel (which loads different data ), then the selected value is set for the second panel not for the first panel(actually value shud be set for first panel).
    And one more problem is samething is happening for even textfield in the table. So, how can I fire editing stopped event before setting the new data. Actually, now when I directly set the data , it is setting the data first and then firing editing stopped event, so it is setting the data for second selected panel.
    Any help is appreciated.
    Thanks.

  • SAMPLE CODE  + HOW ADD JCOMBOBOX IN JTABLE

    HI,
    ALL OF U
    PLZ SUGGEST ME HOW TO ADD COMBOBOX IN JTABLE.
    AND ALSO TELL HOW WE CAN ADD ITEMS IN COMBOBOX AT RUN TIME.
    PLZ SUGGEST ME.
    THANX IN ADVANCE.
    BYE

    Hi if you google you find a lot
    http://www.google.be/search?q=JTable+combobox&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:nl:official&client=firefox-a
    and
    http://www.google.be/search?q=JTable+combobox+example&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:nl:official&client=firefox-a
    Satanduvel

Maybe you are looking for

  • Input File repository server Error: The requested directory does not exist.

    Hi, Getting following error "The requested directory does not exist." for Input and Out put file repository server. The specfied directory exists and the user has local administrative privelges with full control of the IFRS and OFRS location. The loc

  • PO in excel sheet

    Dear Experts, How to export PO to excel format. Rgds

  • 10.5.5  Can't connect to airport

    I updated my Macbook Air to 10.5.5 today and have been unable to connect to my AEBS ever since. It asks for the password, but then tells me the connection failed. ( i used the correct password). Has anyone else run into this?

  • Tried using array, still no joy, why isnt it working?

    Hi, followed your advise and changed to array. i now get a java.lang.NullPointerException. Code is as follows: static XYRMIClient ORBLinks[]; for (int q = 0; q < count; q++){ ORBLinks[q] = new XYRMIClient(this, iparray[q], Port, Message); The object

  • MM pricing Tax procedure

    Dear All, There is no tax on purchase. Whatever tax mentioned in the invoice are capitalized/booked under expenses. Should i use FI  Tax procedure for it. The illustrative pricing is as follows: Please suggest an approach for it Price of item