Dynamic JComboBox

Hello ,
Is it possible to implement a dynamic combobox.
I mean, e.g.:
A combobox that originally takes on the following values:
e.g.: color, function and identity
and if you press color, the list changes to contain only colors: e.g.: blue, brown, cyan, ...?
Is it possible to reply with an example?
Thanx a lot!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Evi

ComboBoxModel handle both selected value and all values at the same time. Write your own ComboBoxModel to do something more or less like:
1) trap selection change through setSelectedItem
2) load in data for that item,
3) reset the selection
4) fire listeners

Similar Messages

  • Dynamic JComboBox small bug...

    Hey,
    I have made the following script to create a JComboBox containing car makes, which has an actionListener on it, so when a car make is selected the model can be set and a JComboBox for the model is created:
            String[] carManString = { "Audi", "BMW", "Ford", "Fiat", "Nissan", "Rover", "Volkswagen", "Vauxhall" };
            JComboBox carManList = new JComboBox(carManString);
            carManList.setSelectedIndex(0);
            carManList.setBounds( 125, 20, 120, 20 );
            policyPanel.add( carManList );
            // add actionListener to set specific model for make
            carManList.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {           
                    JComboBox carManList = (JComboBox)e.getSource(); //find out car make
                    final String carMake = (String)carManList.getSelectedItem();          
                    Runnable updateAComponent = new Runnable() {
                    public void run() {
                    if( carMake == "Audi" )
                    {   String[] carModelString = { "Audi_1", "Audi_2", "Audi_3", "Audi_4", "Audi_5" }; 
                    JComboBox carModelList = new JComboBox(carModelString); //create combo box for model
                    carModelList.setSelectedIndex(0);
                    carModelList.setBounds( 305, 20, 120, 20 );
                    policyPanel.remove( carModelList ); // remove previously selected models from panel
                    policyPanel.add( carModelList ); // add new combobox of models
                    else if ( carMake == "BMW" )
                    {   String[] carModelString = { "BMW_1", "BMW_2", "BMW_3", "BMW_4", "BMW_5" }; 
                    JComboBox carModelList = new JComboBox(carModelString);
                    carModelList.setSelectedIndex(0);
                    carModelList.setBounds( 305, 20, 120, 20 );
                    policyPanel.remove( carModelList );
                    policyPanel.add( carModelList );  
                    else if ( carMake == "Ford" )
                    {   String[] carModelString = { "Ford_1", "Ford_2", "Ford_3", "Ford_4", "Ford_5" }; 
                    JComboBox carModelList = new JComboBox(carModelString);
                    carModelList.setSelectedIndex(0);
                    carModelList.setBounds( 305, 20, 120, 20 );
                    policyPanel.remove( carModelList );
                    policyPanel.add( carModelList );  
                    else if ( carMake == "Fiat" )
                    {   String[] carModelString = { "Fiat_1", "Fiat_2", "Fiat_3", "Fiat_4", "Fiat_5" }; 
                    JComboBox carModelList = new JComboBox(carModelString);
                    carModelList.setSelectedIndex(0);
                    carModelList.setBounds( 305, 20, 120, 20 );
                    policyPanel.remove( carModelList );
                    policyPanel.add( carModelList );  
                    else if ( carMake == "Nissan" )
                    {   String[] carModelString = { "Nissan_1", "Nissan_2", "Nissan_3", "Nissan_4", "Nissan_5" }; 
                    JComboBox carModelList = new JComboBox(carModelString);
                    carModelList.setSelectedIndex(0);
                    carModelList.setBounds( 305, 20, 120, 20 );
                    policyPanel.remove( carModelList );
                    policyPanel.add( carModelList );          
                    else if ( carMake == "Rover" )
                    {   String[] carModelString = { "Rover_1", "Rover_2", "Rover_3", "Rover_4", "Rover_5" }; 
                    JComboBox carModelList = new JComboBox(carModelString);
                    carModelList.setSelectedIndex(0);
                    carModelList.setBounds( 305, 20, 120, 20 );
                    policyPanel.remove( carModelList );
                    policyPanel.add( carModelList );   
                    else if ( carMake == "Volkswagen" )
                    {   String[] carModelString = { "Volkswagen_1", "Volkswagen_2", "Volkswagen_3", "Volkswagen_4", "Volkswagen_5" }; 
                    JComboBox carModelList = new JComboBox(carModelString);
                    carModelList.setSelectedIndex(0);
                    carModelList.setBounds( 305, 20, 120, 20 );
                    policyPanel.remove( carModelList );
                    policyPanel.add( carModelList );  
                    else if ( carMake == "Vauxhall" )
                    {   String[] carModelString = { "Vauxhall_1", "Vauxhall_2", "Vauxhall_3", "Vauxhall_4", "Vauxhall_5" }; 
                    JComboBox carModelList = new JComboBox(carModelString);
                    carModelList.setSelectedIndex(0);
                    carModelList.setBounds( 305, 20, 120, 20 );
                    policyPanel.remove( carModelList );
                    policyPanel.add( carModelList );  
    SwingUtilities.invokeLater(updateAComponent);
            });This seems to work fine apart from a few small problems.
    The first is that the model comboBox only update after the make is chosen, then if you click somewhere on the JFrame it will update...should it not update immediatly when a selection is made?
    The second problem is, if I click on the model combobox and select a model, the models change back to whatever the first make was selected...so if i choose Audi, then BMW and click the model combobox it will change back to the Audi models...
    Any help greatly appretiated...
    -Ross

    removing/adding you need to include a validate, but looking at your code a bit more , this
    might be all you need to do (you'll need additional code for any event of picking eg Audi_3)
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    class Testing extends JFrame
      String[] carManString = { "Audi", "BMW", "Ford", "Fiat", "Nissan", "Rover", "Volkswagen", "Vauxhall" };
      JComboBox carManList = new JComboBox(carManString);
      public Testing()
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        setSize(200,100);
        setLocation(400,300);
        carManList.setSelectedIndex(0);
        carManList.addActionListener(new ActionListener(){
          public void actionPerformed(ActionEvent e){
            String[][] modelStrings =
              {{ "Audi_1", "Audi_2", "Audi_3", "Audi_4", "Audi_5" },
               { "BMW_1", "BMW_2", "BMW_3", "BMW_4", "BMW_5" },
               { "Ford_1", "Ford_2", "Ford_3", "Ford_4", "Ford_5" },
               { "Fiat_1", "Fiat_2", "Fiat_3", "Fiat_4", "Fiat_5" },
               { "Nissan_1", "Nissan_2", "Nissan_3", "Nissan_4", "Nissan_5" },
               { "Rover_1", "Rover_2", "Rover_3", "Rover_4", "Rover_5" },
               { "Volkswagen_1", "Volkswagen_2", "Volkswagen_3", "Volkswagen_4", "Volkswagen_5" },
               { "Vauxhall_1", "Vauxhall_2", "Vauxhall_3", "Vauxhall_4", "Vauxhall_5" }};
            DefaultComboBoxModel newModel = new DefaultComboBoxModel(modelStrings[carManList.getSelectedIndex()]);
            carManList.setModel(newModel);
            carManList.removeActionListener(this);}});
        JPanel jp = new JPanel();
        jp.add(carManList);
        getContentPane().add(jp);
      public static void main(String[] args){new Testing().setVisible(true);}
    }

  • Dynamic JCombobox for a very big database resulset

    I want to use a JCombobox or similar for selecting values from a big database resultset. I'm using an editable one with SwingX autocomplete decorator. My strategy is:
    * show only first Xs regs.
    * let the user to enter some text in the combobox and refine the search reloading the model.
    Someone have some sample code or know some components that do that.
    Or can point me to some implementation details?�
    A lot of thanks in advance,
    PD:
    I need something efficient that don't query database to much.

    what is the size of the table and how many lines are you going to delete?
    I would recommend you to delete only up to 5000 or 10000 records in one step.
    do 100 times.
    select *
              from
              into table itab.
              where
              up to 10.000 records.
    if ( itab is initial )
      exit.
    endif.
    delete ... from table itab.
    commit work.
    If this is still too slow, than you should create a secondary index with zone.
    You can drop the index after the deletion is finished.
    Siegfried

  • 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);
    }

  • JComboBox contents dont get updated(repainted) dynamically

    Hi,
    I have 2 Combo Boxes as 2 columns of a Table and the contents of the second combo box depend on the selection in the first one.
    So I added an ActionListener to the first Combo Box and depending on selection, I update the contents of the other. The contents do get updated. But I see the change only when I click on the second Combo Box. I am trying to get the user to see the change w/o him touching the other combo box. The code snippet is as below:
    public void actionPerformed(ActionEvent e) {
    if (e.getActionCommand().equals(FIRSTCOMBO)) {
    combo1Index = ((JComboBox)(e.getSource())).getSelectedIndex();
    DefaultComboBoxModel model = (DefaultComboBoxModel)comboBox2.getModel();
    model.removeAllElements();
    model.addElements(as obtained);
    comboBox2.setSelectedItem(0);
    comboBox2.revalidate();
    comboBox2.repaint();
    Doesn't seem to work. Any ideas?
    Thanks a ton!

    I don't understand the design of your table. A combo box is used in a table to give the user a choice of values to choose from. Assume the combo box contains the values "a", "b", "c", "d", "e". As a user I choose "c". The "c" now gets stored in the data model and displayed in the table cell.
    Now assume you change the contents of the combo box to "1", "2", "3", "4", "5". The value in the data model has not changed , it is still "c", so there is nothing to repaint.
    When the user clicks on the cell then the new values in the combo box are displayed, allowing the user to choose a new value.
    If you want the table cell to repaint a new value when the second combo box is changed then you must change the data model value. Use the table.setValueAt(row, column) method.

  • Dynamic JTable and rendering column as JComboBox

    I originally posted this to the "Java Programming" topic, but it was suggested that I move it over here.
    I'm new to cell renderers and editors, so I'm hoping someone can put me on the right path.
    I've got a JTable that is initially empty. I've set one column to use a custom cell renderer that extends JComboBox and implements TableCellRenderer.
    The user can add rows to the table at any time, I'm using TableModel.addRow() for this. When I call addRow, I pass the entryies for the JComboBox column as a String[], with one array element for each entry in the JComboBox.
    In my custom renderer, I take the values from the array and use JComboBox.addItem() to add them to the JComboBox.
    When I run the code, it appears fine, but the JComboBox doesn't function, i.e. it is not editable (yes, the column is set as editable). I assume I need to add a custom editor. I tried
    table.setCellEditor(new DefaultCellEditor(ComboBoxCellRenderer);
    and the combobox was now editable, but it was empty and I got nullpointer exceptions.
    What am I missing?
    Any help is appreciated. Here is what I'm trying:
    **************** Constructing the table **************
    DefaultTableModel tablemodel = new DefaultTableModel(columnnames,0);
    datasourcestable = new JTable(tablemodel) ;
    // Set custom renderer for particular columns in this JTable
    ComboBoxCellRenderer renderer = new ComboBoxCellRenderer();
    TableColumn waveformscalarcolumn = datasourcestable.getColumnModel().getColumn(datasourcestable.getColumn("Title").getModelIndex());
    waveformscalarcolumn.setCellRenderer(renderer);
    // tried the following, combobox becomes editable but empty
    //waveformscalarcolumn.setCellEditor(new DefaultCellEditor(renderer));
    *************** Adding rows to the table (Event Code)*********************
    DefaultTableModel tablemodel = (DefaultTableModel)datasourcestable.getModel();
    Object[] rowdata = new Object[3];
    rowdata[0] = "gaga";
    String[] cboxentries = {"cbox entry 1","cbox entry 2"};
    rowdata[1] = cboxentries;
    rowdata[1] = "gaga"'
    tablemodel.addRow(rowdata);
    **************** Custom Cell Renderer **********************
    class ComboBoxCellRenderer extends JComboBox implements TableCellRenderer {
    public ComboBoxCellRenderer() {
    setOpaque(true);
    public Component getTableCellRendererComponent(JTable table, Object value,boolean isSelected, boolean hasFocus, int row, int column) {
    String[] stringarray = (String[]) value;
    for (int i=0; i<stringarray.length; i++){
    this.addItem(stringarray);
    return this;
    }

    Ah! Using the ArrayList of editors in getCellEditor() is very clever, that's the solution I couldn't come up with. Now I just have to remember to add and delete editors as I add and delete rows.
    Thanks, I've got everything working now. Here's are some code snippets, for anyone interested. I used Vector rather than ArrayList to be thread safe.
    // ******************* Global variables ***********
    Vector<TableCellEditor> editors = new Vector<TableCellEditor>(24,8);
    JTable table;
    // *************** construct table ****************
    DefaultTableModel tablemodel = new DefaultTableModel(columnnames,0);
    table = new JTable(tablemodel) {
         public TableCellEditor getCellEditor(int row,int col) {
              int modelcolumn = convertColumnIndexToModel(col);
              int fancycol = table.getColumn("Title").getModelIndex();
              if (modelcolumn == fancycol) {
                   return (TableCellEditor)editors.elementAt(row);
              } else {
                   return super.getCellEditor(row,col);
    // Set custom renderer for particular column in this JTable
    ComboBoxCellRenderer comboboxrenderer = new ComboBoxCellRenderer();
    TableColumn column = table.getColumnModel().getColumn(table.getColumn("Title").getModelIndex());
    column.setCellRenderer(comboboxrenderer);
    //*************** Adding rows to the table (Event Code)*********************
    DefaultTableModel tablemodel = (DefaultTableModel)table.getModel();
    Object[] rowdata = new Object[3];
    rowdata[0] = "gaga";
    String[] cboxentries = {"cbox entry 1","cbox entry 2"};
    JComboBox cellcombo = new JComboBox();
    cellcombo.addItem(cboxentries[0]);
    cellcombo.addItem(cboxentries[1]);
    DefaultCellEditor editor = new DefaultCellEditor(cellcombo);
    editors.add(editor);
    rowdata[1] = cellcombo.getItemAt(0);          // don't know if this matters
    rowdata[2] = "gaga2";
    tablemodel.addRow(rowdata);
    //**************** Custom Cell Renderer *********************
    class ComboBoxCellRenderer extends JComboBox implements TableCellRenderer {
         public ComboBoxCellRenderer() {
         public Component getTableCellRendererComponent(JTable table, Object value,boolean isSelected, boolean hasFocus, int row, int column) {
    // display value in our JComboBOx
              this.addItem(value);
              this.setSelectedItem(value);
              return this;
    }

  • Dynamically remove and add element into the JCOmboBox

    Hi all ,
    I have one JComboBox .
    and I have 3 sets of values in vector form -- Vector<String> v1 , Vector<String> v2 , Vector<String> v3 .
    Depending on certain condtion I have set the values in the JComboBox .
    Can any body tell how can I achieve this
    Thanks and regards
    Anshuman Srivastava

    Replace the model.
    [http://java.sun.com/docs/books/tutorial/uiswing/components/combobox.html]

  • 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.

  • Dynamically changing the functions in a menu based on the user (in SSHR)

    Dear All,
    I have a requirement to change the functions in a menu dynamically.
    For Ex: An employee is allowed to apply Advance only in the first one month of his/her joining. I created it as an EIT and attached the function, to the menu. Now, i want to remove it automatically from the menu if his/her term in the company crossed one month.
    Can any one tell me how to automatically disable it after one month.
    Thanks and Regards
    Raj
    Edited by: SuperStar_Krishna on Jul 5, 2010 12:22 AM

    The following code should do it. In this example, MyCellRenderer is the renderer class implementing TableCellRenderer, used for displaying combo box.
    TableCellRenderer renderer= new MyCellRenderer();
    (JComboBox)renderer.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent e) {
            //Your event handling goes here
    });

  • Event to watch for JComboBox _finished_ selection?

    When my app's JComboBoxes are clicked I can capture every
    single change while the user is trying to decide with the
    up arrow and down arrow keys. This allows some really neat
    and dynamic things such as changing other components "live" or
    in real time as the user navigates up and down. I make
    extensive use of this Java event capture. The tutorial with
    a little pig is a good example of that kind of event.
    However, what I need additionally is to detect when the user has
    made up her mind and the selecting process is finished. This
    occurs for instance, when the <TAB> key is pressed and as a
    result, the focus is transfered to the next component.
    So, how can I detect not the fine grain event, up&down event,
    but the higher level selection?
    TIA,
    -Ramon F. Herrera

    I would suggest adding an action listener to the combo box and seeing if that will capture the event you are looking for.

  • JComboBox selection and highlight problem of the selected item

    Hi,
    I have a question how can I make my newly added item to the combo-box selectable and highlighted. I am adding new items to my custom comboBox dynamically and I want whatever item I add to be selected by default. I am using my own custom ComboBoxModel that extends AbstractListModel and implements ComboBoxModel and TreeModelListener, and my custom Renderer that extends JLabel and implements ListCellRenderer. Because I am trying to get a tree structure in my comboBox model and that's why I have my own custom model and renderer. Now when I add a new node or item to my comboBox it is being added and shown in the combo-box textField, but as soon I pull down the combo-box my parent directory is selected though my current selection is the last node added. That's how I am adding new nodes and making it selectable
    treeModel.insertNodeInto(tempNode, (DefaultMutableTreeNode)nodeCollection.lastElement(), 0);
    int nodeTotal =((CMRGlobals.myTreeGlobals).getModel()).getSize();
    Object lastNode = CMRGlobals.myTreeGlobals).getModel()).getElementAt(nodeTotal - 1);
    ((CMRGlobals.myTreeGlobals).getModel()).setSelectedItem(lastNode);
    when I do this my node is added under my parentNode and is shown in the comboBox but when I try to pull down the combo my parent node is high lighted and when I move out of the combo-box my parent node gets selected and show in the combo-box though I haven't selected it,and the contents of my last node are shown. I am just writing my own custom model that simulates the effect of JTree. I am using these......
    DefaultMutableTreeNode and
    DefaultTreeModel
    and in my JComboBox I am setting my model as
    this.setModel(new myModel(treemodel));
    this.setRenderer(new myRenderer());
    I am building my own FileDialog that just works like FileDialog I have all the functionality except this problem.Thanks for any help. I know I have posted this same thread yesterday but I didn't get any response hoping now may somebody can help me.Thanks again

    never mind I got it
    Thanks

  • Populating dynamic components in a remotely connected desktop application

    Hii Javaties
    I develping a desktop appliaction, which will remotely connect to internet.
    My requiremnets for the project are
    1)- Combo boxes, lists are dynamic(they need 2 be populated from databse).Since user will not be always connected to internet , so i need to devise some other way 2 do this .
    the solution tht i m thinking upon is tht , the comboboxes ,lists will be populated fom XML file tht will be stored in user P.C(rather tht this file will be in jar file of the desktop application).
    So now whenever user has access to net, then he can click on a menu
    button (UPDATE FILES), so tht he can get the latest copy from the central server .
    In the central server , the data will be stored in an RDBMS , and this data will be sent 2 the application on client computer as an XML file.
    and this will rewrite the (XML)files , tht the appliaction needs for poplulating Combo boxes and lists.
    2)User needs to transmit data back to central server remotely.
    I plan to use XML for this.
    Now My questions are -------
    1) Is this approach Correct ?
    2) if the data is large , is it wise to store it as an XML file
    3) How 2 go abt it.
    If anythng is not clear , plz tell me ?
    U can also click on the link below to see the original question posted by me
    http://forum.java.sun.com/thread.jspa?threadID=734442

    I don't understand why you need xml for jcombobox content? A flat file for each combobox will serve its purpose quite well.the contents of combo boxes will be fetched , from a repository (XML) file, which will contain data from database.
    This repository can be aslo updated by connecting to server,and updating it with new data from database.
    If u still have dobt do tell me .?

  • Dynamic Field in Swing

    hi friends
    I have a JCombobox having 3 items and a JList. Now suppose some one selects the first item from the combobox say Item1 then according to that item the contents of list should be displayed and if he selects Item2 then according to that item the contents of list would be changed dynamically.
    so anyone plz help me to solve my this problame i also paste the code which i thought to solve the above problame but i can't work.
    String[] mah = {"listItem1","listItem2"};
    Object[] mahObj = (Object[])mah;
    private void sStateItemStateChanged(java.awt.event.ItemEvent evt) {                                       
    // TODO add your handling code here:
    if(evt.getStateChange() == ItemEvent.SELECTED)
    state = (String)evt.getItem();
    if(state.equalsIgnoreCase("Item1")){
    mCombo.setListData(mahObj);
    ishan

    Please post Swing questions in the Swing forum: http://forum.java.sun.com/forum.jspa?forumID=57

  • Dynamic table generation, an OOP question, and .

    I am attempting to teach myself Java using the Sun tutorials (mostly DiveLog) and these forums. So far, things are going well.
    My application is a scheduling program for my current boss. I work in retail, and the app would (ideally) faciliate creating the weekly schedules. I am using Swing to generate the windows and such.
    There are two main parts to the app, each corresponding to a tabbed pane. The first part will be a table with the employees listed down the left, the days of the week across the top, and with each cell being that employee's shift for the day. Totals for hours worked that week will be the farmost right column and totals for hours of coverage that day will be the bottom row. The second part of the app allows the user to enter in a new employee or display/edit an existing employee's information, including a list of scheduling constraints (e.g., can't work mornings Tu/Th because of class).
    My intuition is that the schedule table and the list of scheduling constraints should be dynamically generated and displayed depending on the number of employees and the number of constraints. It would also seem that both parts of the application need access to the current set of data encompassing all employees and their information. As I am just starting, the work I have done so far has been in the employee info section where I am in the process of implementing an MVC architecture with the model as a sort of employee datagram.
    The questions....
    1. How do I draw tables with a dynamic number of rows? I want the scheduler table to have a row for each employee and have the number of employees not hardcoded in. With the list of scheduling constraints, could I just have Swing draw each new row from a loop that counts down the number of constraints?
    2. What is the smart move regarding having multiple parts of the app/GUI access employee data? Would I just load the data into an object when the app starts and have the two parts access the info via 'get' functions? (And subsequently have the second part of the app be able to edit the data via 'set' functions and then tell the first part of the app update itself?)
    3. Is it appropriate to use reading and writing to and from a file for this sort of activity? (As opposed to a database of some sort.) The DiveLog app uses object serialization, and I'm feeling sketchy in this area, particularly with accessing specific pieces of data from whatever gets read from a file. If the user selects an employee from a JComboBox, how do I take that selection and grab the right object from the stuff that's been read back from a file? Similarly with the scheduling table.

    Hi,
    I am new to Jave programming. As a first step of learning, I want to do a Automated Employee Schedule Project in Java. (JSP)
    Could you please help me to understand the flow for creating Automated Employee Schedule project?
    Thanks in advance.
    Amitava

  • 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.

Maybe you are looking for

  • VL02N:Post Goods Issue Error: PXA_NO_FREE_SPACE

    Hi gurus, i am testing post goods issue under vl02n after posting&delivering a sales order with type OR. the ' PXA_NO_FREE_SPACE' error occured after my clicking post good issue. PFB the error log, can anyone help to solve it out. TIA.     No PXA sto

  • How do you reset the PMU on an ibook G3?

    My man just got a refurbed ibook G3 and on the first night it went to sleep and it won't seem to charge and I've read that the PMU needs to be reset but I don't know how to do this.  Can someone help?

  • I recently installed Adobe Reader X successfully on a Vista desktop running IE8.  Since installing,

    I recently installed Adobe Reader X successfully on a Vista desktop running IE8.  Since installing, I am no longer able to open a second PDF document without refreshing.  For example if I go to my credit card company, I can open up this month's state

  • SAXParserFactory on jdk1.4

    I use jdk1.4 to compile my java files which includes the using of SAXParserFactory class. The compile failed, and say that the bad class found in rt.jar(javax.xml.parsers.SAXParserFactory), the version 48 found but version 47 expected. I cannot figur

  • Encore CS5, pre-built Menu Templates?

    Hi, Are there pre-built templates for Encore rather than having to build each section from scratch?