JTable - JComboBox/List - JTable

My target: I would like to have multiple columns in my comboBox or list. When I choose one item, the result would be just a single column but not all columns. Moreover, the whole comboBox is actually one cell within a JTable. i.e. when I click one cell of a jtable, it shows a comboBox.
I have searched this forum but just found some ways to get multiple columns in comboBox, and it seem no one has tried to include it in a JTable cell. I just wonder if anyone can help and it would be thankful.

Let me post the code here:
//the init of comboBox model within jtable here
     private void initSupplierCombo(TableColumn col){
       String query = "select supplier_no, supplier_name from supplier_master group by supplier_no,supplier_name;";
       JComboBox comboBox = new JComboBox();
       Vector supplierList = itemDB.getComboResults(query);
       try {
         comboBox.setModel(new ResultSetComboBoxModel(supplierList));
         col.setCellEditor(new DefaultCellEditor(comboBox));
         DefaultTableCellRenderer renderer =
             new DefaultTableCellRenderer();
         renderer.setToolTipText(
             "Click for combo box & choose");
         col.setCellRenderer(renderer);
         //Set up tool tip for the sport column header.
         TableCellRenderer headerRenderer = col.getHeaderRenderer();
         if (headerRenderer instanceof DefaultTableCellRenderer) {
           ( (DefaultTableCellRenderer) headerRenderer).setToolTipText(
               "Click to see a list of choices");
       catch (Exception e) {
         e.printStackTrace();
//ResultSetComboBoxModel
import javax.swing.*;
import java.sql.*;
import java.util.Vector;
public class ResultSetComboBoxModel extends ResultSetListModel
    implements ComboBoxModel
    protected Object selected = null;
    public ResultSetComboBoxModel(Vector columnResults) throws Exception {
        super(columnResults);
    public Object getSelectedItem() {
      return selected;
    public void setSelectedItem(Object o) {
        if(o==null)
          selected = o;
        else{
          String value = (String) o;
          selected = (Object)(value.substring(0,value.lastIndexOf("  //  ")));
//ResultSetListModel
import javax.swing.*;
import java.util.*;
import java.sql.*;
public class ResultSetListModel extends AbstractListModel {
    List values = new ArrayList();
    public ResultSetListModel(Vector columnResults) throws Exception {
      for(Iterator item = columnResults.iterator();item.hasNext();){
        String[] value  = (String[])item.next();
        values.add(value[0] + "  //  " + value[1]);
    public int getSize() {
        return values.size();
    public Object getElementAt(int index) {
      return values.get(index);
}

Similar Messages

  • JComboBox List Rendering

    Hi All, I have JCombobox list with 2 Strings
    like String1 String 2
    I want to renderer both text like
    String1 is left alignment , String2 is Right alignment in the same item..
    exp:
    string1 string2
    otherStr1 otherStr2
    testStr1 testStr1
    Is there any way I can renderer in ComboBox List like above
    Thanks

    Thanks camickr
    I was also trying to override paintComponent method of DefaultListCellRenderer like below
    public void paintComponent(Graphics g) {
              //super.paintComponent(g);
              Graphics2D g2 = (Graphics2D) g;
              if(text.length() > 0) {
                   g2.setBackground(Color.white);
                   StringTokenizer st = new StringTokenizer(text, "-");
                   g2.drawString(st.nextToken().trim(), 5, 15);
                   g2.setColor(Color.BLUE);
                   g2.setFont(new Font("Arial", Font.BOLD, 12));
                   g2.drawString(st.nextToken().trim(), 100, 15);
         }But I think JPanel with two labels will works nice for me.,
    Thanks once again

  • JcomboBox list size is wrong if using PopupMenuListener

    Just wondering if someone else has already implmented the workaround for this bug and would be able to tell me if it was very difficult to get going.
    Basically, if you use PopupMenuListeners to populate a combo-box list dynamically when the user selects the combo, the size of the list which gets presented to the user is based on the number of entries the combo previously had, not teh size of the new list.
    http://developer.java.sun.com/developer/bugParade/bugs/4743225.html
    We were hoping that this would get fixed in v1.5, but customers are complaining so much, its getting to the point where we will have to code a work-around. Just wondering how nasty it is to do.

    Basically, if you use PopupMenuListeners to populate a combo-box list dynamically ...I guess I don't fully understand what you are attempting to do, so I guess the next question is why are you using a PopupMenuListener to dynamically change the contents of the comboBox? Why does clicking on the dropdown menu cause the contents do dynamically change? Usually the contents are change as a result of some other action by the user. Maybe some sample code will clarify what you are attempting do do and an alternative approach can be suggested.
    For example, this thread shows how to dynamically change the contents of a second combBox when a selection is made in the primary comboBox:
    http://forum.java.sun.com/thread.jsp?forum=57&thread=428181

  • Bug when using JComboBox as JTable CellEditor

    Hello! I have a JTable that displays database information, and one of the columns is editable using a JComboBox. When the user selects an item from the JComboBox, the database (and consequently the JTable) is updated with the new value.
    Everything works fine except for a serious and subtle bug. To explain what happens, here is an example. If Row 1 has the value "ABC" and the user selects the editable column on that row, the JComboBox drops down with the existing value "ABC" already selected (this is the default behavior, not something I implemented). Now, if the user does not select a new value from the JComboBox, and instead selects the editable column on Row 2 that contains "XYZ", Row 1 gets updated to contain "XYZ"!
    The reason that is happening is because I'm updating the database by responding to the ActionListener.actionPerformed event in the JComboBox, and when a new row is selected, the actionPerformed event gets fired BEFORE the JTable's selected row index gets updated. So the old row gets updated with the new row's information, even though the user never actually selected a new item in the JComboBox.
    If I use ItemListener.itemStateChanged instead, I get the same results. If I use MouseListener.mousePressed/Released I get no events at all for the JComboBox list selection. If anyone else has encountered this problem and found a workaround, I would very much appreciate knowing what you did. Here are the relavent code snippets:
    // In the dialog containing JTable:
    JComboBox cboRouteType = new JComboBox(new String[]{"ABC", "XYZ"));
    cboRouteType.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent ev) {
              doCboRouteTypeSelect((String)cboRouteType.getSelectedItem());
    private void doCboRouteTypeSelect(String selItem) {
         final RouteEntry selRoute = tblRoutes.getSelectedRoute();
         if (selRoute == null) { return; }
         RouteType newType = RouteType.fromString(selItem);
         // Only update the database if the value was actually changed.
         if (selRoute.getRouteType() == newType) { return; }
         RouteType oldType = selRoute.getRouteType();
         selRoute.setRouteType(newType);
         // (update the db below)
    // In the JTable:
    public RouteEntry getSelectedRoute() {
         int selIndx = getSelectedRow();
         if (selIndx < 0) return null;
         return model.getRouteAt(selIndx);
    // In the TableModel:
    private Vector<RouteEntry> vRoutes = new Vector<RouteEntry>();
    public RouteEntry getRouteAt(int indx) { return vRoutes.get(indx); }

    Update: I was able to resolve this issue. In case anyone is curious, the problem was caused by using the actionPerformed method in the first place. Apparently when the JComboBox is used as a table cell editor, it calls setValueAt on my table model and that's where I'm supposed to respond to the selection.
    Obviously the table itself shouldn't be responsible for database updates, so I had to create a CellEditListener interface and implement it from the class that actually does the DB update in a thread and is capable of reporting SQL exceptions to the user. All that work just to let the user update the table/database with a dropdown. Sheesh!

  • JComboBox, JTable, cellRendering CHALLENGE

    Hi all,
    I would like to ask a question of the resident guru concerning a Netbeans/MYSQL application. I based it on a tutorial found here: [http://www.netbeans.org/kb/61/java/gui-db-custom.html].
    I have two seperate JDialogs that write data to a master table. One of the JDialogs is called "Customer Editor" and it contains various text fields bound to cells on the masterTable, no big deal.
    Also in the "Customer Editor" JDialog there is a JComboBox that has a list of four values to choose from which are "Good", "Standby", "Failed", and "Complete".
    I would like the data selected from the JComboBox to color itself when it writes to the JTable row/cell on the masterTable. For example if the user selects "Good" from the list, in the masterTable the font color of the String will be GREEN. Similarly, if the user selects "Failed" from the JComboBox I would like the String to return RED...following on "Standby" - BLUE, "Complete" - no color change.
    Question: How do I write code that allows me to change the color of text in a cell when it comes from a JComboBox list?
    If anyone out there picks up this thread, I will of course supply the code I have so far. I won't do it now as I am not sure even where the code should go. I think it would go in the source code for the masterTable view but I am not certain.
    Any Java masters out there?
    David

    Thanks for the reply. I have been writing different cell renderers to get it working. Where should the code reside?
    This is my operations view class. Should it be in here.
    /CODE/
    package operationsrecords;
    import org.jdesktop.application.Action;
    import org.jdesktop.application.ResourceMap;
    import org.jdesktop.application.SingleFrameApplication;
    import org.jdesktop.application.FrameView;
    import org.jdesktop.application.TaskMonitor;
    import org.jdesktop.application.Task;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.util.ArrayList;
    import java.util.Collection;
    import java.util.Iterator;
    import java.util.LinkedList;
    import java.util.List;
    import javax.persistence.RollbackException;
    import javax.swing.Timer;
    import javax.swing.Icon;
    import javax.swing.JDialog;
    import javax.swing.JFrame;
    import javax.swing.JOptionPane;
    import javax.swing.event.ListSelectionEvent;
    import javax.swing.event.ListSelectionListener;
    import org.jdesktop.beansbinding.AbstractBindingListener;
    import org.jdesktop.beansbinding.Binding;
    import org.jdesktop.beansbinding.PropertyStateEvent;
    * The application's main frame.
    public class OperationsRecordsView extends FrameView {
    public OperationsRecordsView(SingleFrameApplication app) {
    super(app);
    initComponents();
    // status bar initialization - message timeout, idle icon and busy animation, etc
    ResourceMap resourceMap = getResourceMap();
    int messageTimeout = resourceMap.getInteger("StatusBar.messageTimeout");
         messageTimer = new Timer(messageTimeout, new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    statusMessageLabel.setText("");
         messageTimer.setRepeats(false);
    int busyAnimationRate = resourceMap.getInteger("StatusBar.busyAnimationRate");
    for (int i = 0; i < busyIcons.length; i++) {
    busyIcons[i] = resourceMap.getIcon("StatusBar.busyIcons[" + i + "]");
    busyIconTimer = new Timer(busyAnimationRate, new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    busyIconIndex = (busyIconIndex + 1) % busyIcons.length;
    statusAnimationLabel.setIcon(busyIcons[busyIconIndex]);
    idleIcon = resourceMap.getIcon("StatusBar.idleIcon");
    statusAnimationLabel.setIcon(idleIcon);
    progressBar.setVisible(false);
    // connecting action tasks to status bar via TaskMonitor
    TaskMonitor taskMonitor = new TaskMonitor(getApplication().getContext());
    taskMonitor.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
    public void propertyChange(java.beans.PropertyChangeEvent evt) {
    String propertyName = evt.getPropertyName();
    if ("started".equals(propertyName)) {
    if (!busyIconTimer.isRunning()) {
    statusAnimationLabel.setIcon(busyIcons[0]);
    busyIconIndex = 0;
    busyIconTimer.start();
    progressBar.setVisible(true);
    progressBar.setIndeterminate(true);
    } else if ("done".equals(propertyName)) {
    busyIconTimer.stop();
    statusAnimationLabel.setIcon(idleIcon);
    progressBar.setVisible(false);
    progressBar.setValue(0);
    } else if ("message".equals(propertyName)) {
    String text = (String)(evt.getNewValue());
    statusMessageLabel.setText((text == null) ? "" : text);
    messageTimer.restart();
    } else if ("progress".equals(propertyName)) {
    int value = (Integer)(evt.getNewValue());
    progressBar.setVisible(true);
    progressBar.setIndeterminate(false);
    progressBar.setValue(value);
    // tracking table selection
    masterTable.getSelectionModel().addListSelectionListener(
    new ListSelectionListener() {
    public void valueChanged(ListSelectionEvent e) {
    firePropertyChange("recordSelected", !isRecordSelected(), isRecordSelected());
    detailTable.getSelectionModel().addListSelectionListener(
    new ListSelectionListener() {
    public void valueChanged(ListSelectionEvent e) {
    firePropertyChange("detailRecordSelected", !isDetailRecordSelected(), isDetailRecordSelected());
    // tracking changes to save
    bindingGroup.addBindingListener(new AbstractBindingListener() {
    @Override
    public void targetChanged(Binding binding, PropertyStateEvent event) {
    // save action observes saveNeeded property
    setSaveNeeded(true);
    // have a transaction started
    entityManager.getTransaction().begin();
    public boolean isSaveNeeded() {
    return saveNeeded;
    private void setSaveNeeded(boolean saveNeeded) {
    if (saveNeeded != this.saveNeeded) {
    this.saveNeeded = saveNeeded;
    firePropertyChange("saveNeeded", !saveNeeded, saveNeeded);
    public boolean isRecordSelected() {
    return masterTable.getSelectedRow() != -1;
    public boolean isDetailRecordSelected() {
    return detailTable.getSelectedRow() != -1;
    @Action
    public void newRecord() {
    operationsrecords.Customers c = new operationsrecords.Customers();
    entityManager.persist(c);
    list.add(c);
    int row = masterTable.getRowCount() - 1;
    masterTable.setRowSelectionInterval(row, row);
    masterTable.scrollRectToVisible(masterTable.getCellRect(row, 0, true));
    setSaveNeeded(true);
    JFrame mainFrame = OperationsRecordsApp.getApplication().getMainFrame();
    CustomerEditor ce = new CustomerEditor(mainFrame, false);
    ce.setCurrentRecord(c);
    ce.setVisible(true);
    if (ce.isCustomerConfirmed()) {
    save().run();
    } else {
    refresh().run();
    @Action(enabledProperty = "recordSelected")
    public void deleteRecord() {
    Object[] options = {"OK", "Cancel"};
    int n = JOptionPane.showConfirmDialog(null, "Delete the records permanently?", "Warning",
    JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null);
    if (n == JOptionPane.YES_OPTION) {
    int[] selected = masterTable.getSelectedRows();
    List<operationsrecords.Customers> toRemove = new ArrayList<operationsrecords.Customers>(selected.length);
    for (int idx = 0; idx < selected.length; idx++) {
    operationsrecords.Customers c = list.get(masterTable.convertRowIndexToModel(selected[idx]));
    toRemove.add(c);
    entityManager.remove(c);
    list.removeAll(toRemove);
    save().run();
    } else {
    refresh().run();
    @Action(enabledProperty = "recordSelected")
    public void newDetailRecord() {
    int index = masterTable.getSelectedRow();
    operationsrecords.Customers c = list.get(masterTable.convertRowIndexToModel(index));
    Collection<operationsrecords.Orders> os = c.getOrdersCollection();
    if (os == null) {
    os = new LinkedList<operationsrecords.Orders>();
    c.setOrdersCollection(os);
    operationsrecords.Orders o = new operationsrecords.Orders();
    o.setShipDate(new java.util.Date());
    entityManager.persist(o);
    o.setCustomerId(c);
    os.add(o);
    masterTable.clearSelection();
    masterTable.setRowSelectionInterval(index, index);
    int row = os.size()-1;
    detailTable.setRowSelectionInterval(row, row);
    detailTable.scrollRectToVisible(detailTable.getCellRect(row, 0, true));
    setSaveNeeded(true);
    JFrame mainFrame = OperationsRecordsApp.getApplication().getMainFrame();
    OrderEditor oe = new OrderEditor(mainFrame, false);
    oe.setCurrentOrderRecord(o);
    oe.setVisible(true);
    if (oe.isOrderConfirmed()) {
    save().run();
    } else {
    refresh().run();
    @Action(enabledProperty = "detailRecordSelected")
    public void deleteDetailRecord() {
    Object[] options = {"OK", "Cancel"};
    int n = JOptionPane.showConfirmDialog(null, "Delete the records permanently?", "Warning",
    JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null);
    if (n == JOptionPane.YES_OPTION) {
    int index = masterTable.getSelectedRow();
    operationsrecords.Customers c = list.get(masterTable.convertRowIndexToModel(index));
    Collection<operationsrecords.Orders> os = c.getOrdersCollection();
    int[] selected = detailTable.getSelectedRows();
    List<operationsrecords.Orders> toRemove = new ArrayList<operationsrecords.Orders>(selected.length);
    for (int idx = 0; idx < selected.length; idx++) {
    selected[idx] = detailTable.convertRowIndexToModel(selected[idx]);
    int count = 0;
    Iterator<operationsrecords.Orders> iter = os.iterator();
    while (count++ < selected[idx]) {
    iter.next();
    operationsrecords.Orders o = iter.next();
    toRemove.add(o);
    entityManager.remove(o);
    os.removeAll(toRemove);
    masterTable.clearSelection();
    masterTable.setRowSelectionInterval(index, index);
    list.removeAll(toRemove);
    save().run();
    } else {
    refresh().run();
    @Action(enabledProperty = "saveNeeded")
    public Task save() {
    return new SaveTask(getApplication());
    private class SaveTask extends Task {
    SaveTask(org.jdesktop.application.Application app) {
    super(app);
    @Override protected Void doInBackground() {
    try {
    entityManager.getTransaction().commit();
    entityManager.getTransaction().begin();
    } catch (RollbackException rex) {
    rex.printStackTrace();
    entityManager.getTransaction().begin();
    List<operationsrecords.Customers> merged = new ArrayList<operationsrecords.Customers>(list.size());
    for (operationsrecords.Customers c : list) {
    merged.add(entityManager.merge(c));
    list.clear();
    list.addAll(merged);
    return null;
    @Override protected void finished() {
    setSaveNeeded(false);
    * An example action method showing how to create asynchronous tasks
    * (running on background) and how to show their progress. Note the
    * artificial 'Thread.sleep' calls making the task long enough to see the
    * progress visualization - remove the sleeps for real application.
    @Action
    public Task refresh() {
    return new RefreshTask(getApplication());
    private class RefreshTask extends Task {
    RefreshTask(org.jdesktop.application.Application app) {
    super(app);
    @SuppressWarnings("unchecked")
    @Override protected Void doInBackground() {
    setProgress(0, 0, 4);
    setMessage("Rolling back the current changes...");
    setProgress(1, 0, 4);
    entityManager.getTransaction().rollback();
    setProgress(2, 0, 4);
    setMessage("Starting a new transaction...");
    entityManager.getTransaction().begin();
    setProgress(3, 0, 4);
    setMessage("Fetching new data...");
    java.util.Collection data = query.getResultList();
    for (Object entity : data) {
    entityManager.refresh(entity);
    setProgress(4, 0, 4);
    list.clear();
    list.addAll(data);
    return null;
    @Override protected void finished() {
    setMessage("Done.");
    setSaveNeeded(false);
    @Action
    public void showAboutBox() {
    if (aboutBox == null) {
    JFrame mainFrame = OperationsRecordsApp.getApplication().getMainFrame();
    aboutBox = new OperationsRecordsAboutBox(mainFrame);
    aboutBox.setLocationRelativeTo(mainFrame);
    OperationsRecordsApp.getApplication().show(aboutBox);
    /** This method is called from within the constructor to
    * initialize the form.
    * WARNING: Do NOT modify this code. The content of this method is
    * always regenerated by the Form Editor.
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {
    bindingGroup = new org.jdesktop.beansbinding.BindingGroup();
    mainPanel = new javax.swing.JPanel();
    masterScrollPane = new javax.swing.JScrollPane();
    masterTable = new javax.swing.JTable();
    newButton = new javax.swing.JButton();
    deleteButton = new javax.swing.JButton();
    detailScrollPane = new javax.swing.JScrollPane();
    detailTable = new javax.swing.JTable();
    deleteDetailButton = new javax.swing.JButton();
    newDetailButton = new javax.swing.JButton();
    jButton1 = new javax.swing.JButton();
    jButton2 = new javax.swing.JButton();
    jLabel1 = new javax.swing.JLabel();
    jTextField1 = new javax.swing.JTextField();
    jLabel2 = new javax.swing.JLabel();
    menuBar = new javax.swing.JMenuBar();
    javax.swing.JMenu fileMenu = new javax.swing.JMenu();
    javax.swing.JMenuItem newRecordMenuItem = new javax.swing.JMenuItem();
    javax.swing.JMenuItem deleteRecordMenuItem = new javax.swing.JMenuItem();
    jSeparator1 = new javax.swing.JSeparator();
    javax.swing.JMenuItem saveMenuItem = new javax.swing.JMenuItem();
    javax.swing.JMenuItem refreshMenuItem = new javax.swing.JMenuItem();
    jSeparator2 = new javax.swing.JSeparator();
    javax.swing.JMenuItem exitMenuItem = new javax.swing.JMenuItem();
    javax.swing.JMenu helpMenu = new javax.swing.JMenu();
    javax.swing.JMenuItem aboutMenuItem = new javax.swing.JMenuItem();
    statusPanel = new javax.swing.JPanel();
    javax.swing.JSeparator statusPanelSeparator = new javax.swing.JSeparator();
    statusMessageLabel = new javax.swing.JLabel();
    statusAnimationLabel = new javax.swing.JLabel();
    progressBar = new javax.swing.JProgressBar();
    entityManager = java.beans.Beans.isDesignTime() ? null : javax.persistence.Persistence.createEntityManagerFactory("OperationsRecordsPU").createEntityManager();
    org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(operationsrecords.OperationsRecordsApp.class).getContext().getResourceMap(OperationsRecordsView.class);
    query = java.beans.Beans.isDesignTime() ? null : entityManager.createQuery(resourceMap.getString("query.query")); // NOI18N
    list = java.beans.Beans.isDesignTime() ? java.util.Collections.emptyList() : org.jdesktop.observablecollections.ObservableCollections.observableList(query.getResultList());
    rowSorterToStringConverter1 = new operationsrecords.RowSorterToStringConverter();
    mainPanel.setBackground(resourceMap.getColor("mainPanel.background")); // NOI18N
    mainPanel.setName("mainPanel"); // NOI18N
    masterScrollPane.setName("masterScrollPane"); // NOI18N
    masterTable.setBackground(resourceMap.getColor("masterTable.background")); // NOI18N
    masterTable.setGridColor(resourceMap.getColor("masterTable.gridColor")); // NOI18N
    masterTable.setName("masterTable"); // NOI18N
    masterTable.setShowVerticalLines(false);
    org.jdesktop.swingbinding.JTableBinding jTableBinding = org.jdesktop.swingbinding.SwingBindings.createJTableBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, list, masterTable);
    org.jdesktop.swingbinding.JTableBinding.ColumnBinding columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${jobId}"));
    columnBinding.setColumnName("Job Id");
    columnBinding.setColumnClass(String.class);
    columnBinding.setEditable(false);
    columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${statusId.status}"));
    columnBinding.setColumnName("Status Id.status");
    columnBinding.setColumnClass(String.class);
    columnBinding.setEditable(false);
    columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${company}"));
    columnBinding.setColumnName("Company");
    columnBinding.setColumnClass(String.class);
    columnBinding.setEditable(false);
    columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${rig}"));
    columnBinding.setColumnName("Rig");
    columnBinding.setColumnClass(String.class);
    columnBinding.setEditable(false);
    columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${well}"));
    columnBinding.setColumnName("Well");
    columnBinding.setColumnClass(String.class);
    columnBinding.setEditable(false);
    columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${county}"));
    columnBinding.setColumnName("County");
    columnBinding.setColumnClass(String.class);
    columnBinding.setEditable(false);
    columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${state}"));
    columnBinding.setColumnName("State");
    columnBinding.setColumnClass(String.class);
    columnBinding.setEditable(false);
    columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${companyMan}"));
    columnBinding.setColumnName("Company Man");
    columnBinding.setColumnClass(String.class);
    columnBinding.setEditable(false);
    columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${phone}"));
    columnBinding.setColumnName("Phone");
    columnBinding.setColumnClass(String.class);
    columnBinding.setEditable(false);
    columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${fax}"));
    columnBinding.setColumnName("Fax");
    columnBinding.setColumnClass(String.class);
    columnBinding.setEditable(false);
    columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${emailAddress}"));
    columnBinding.setColumnName("Email Address");
    columnBinding.setColumnClass(String.class);
    columnBinding.setEditable(false);
    bindingGroup.addBinding(jTableBinding);
    jTableBinding.bind();
    masterScrollPane.setViewportView(masterTable);
    masterTable.getColumnModel().getColumn(0).setHeaderValue(resourceMap.getString("masterTable.columnModel.title0")); // NOI18N
    masterTable.getColumnModel().getColumn(1).setHeaderValue(resourceMap.getString("masterTable.columnModel.title1")); // NOI18N
    masterTable.getColumnModel().getColumn(2).setHeaderValue(resourceMap.getString("masterTable.columnModel.title2")); // NOI18N
    masterTable.getColumnModel().getColumn(3).setHeaderValue(resourceMap.getString("masterTable.columnModel.title3")); // NOI18N
    masterTable.getColumnModel().getColumn(4).setHeaderValue(resourceMap.getString("masterTable.columnModel.title4")); // NOI18N
    masterTable.getColumnModel().getColumn(5).setHeaderValue(resourceMap.getString("masterTable.columnModel.title5")); // NOI18N
    masterTable.getColumnModel().getColumn(6).setHeaderValue(resourceMap.getString("masterTable.columnModel.title6")); // NOI18N
    masterTable.getColumnModel().getColumn(7).setHeaderValue(resourceMap.getString("masterTable.columnModel.title7")); // NOI18N
    masterTable.getColumnModel().getColumn(8).setHeaderValue(resourceMap.getString("masterTable.columnModel.title8")); // NOI18N
    masterTable.getColumnModel().getColumn(9).setHeaderValue(resourceMap.getString("masterTable.columnModel.title9")); // NOI18N
    masterTable.getColumnModel().getColumn(10).setHeaderValue(resourceMap.getString("masterTable.columnModel.title10")); // NOI18N
    javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(operationsrecords.OperationsRecordsApp.class).getContext().getActionMap(OperationsRecordsView.class, this);
    newButton.setAction(actionMap.get("newRecord")); // NOI18N
    newButton.setBackground(resourceMap.getColor("newButton.background")); // NOI18N
    newButton.setName("newButton"); // NOI18N
    deleteButton.setAction(actionMap.get("deleteRecord")); // NOI18N
    deleteButton.setBackground(resourceMap.getColor("jButton1.background")); // NOI18N
    deleteButton.setName("deleteButton"); // NOI18N
    detailScrollPane.setName("detailScrollPane"); // NOI18N
    detailTable.setGridColor(resourceMap.getColor("detailTable.gridColor")); // NOI18N
    detailTable.setName("detailTable"); // NOI18N
    detailTable.setShowVerticalLines(false);
    detailTable.getTableHeader().setReorderingAllowed(false);
    org.jdesktop.beansbinding.ELProperty eLProperty = org.jdesktop.beansbinding.ELProperty.create("${selectedElement.ordersCollection}");
    jTableBinding = org.jdesktop.swingbinding.SwingBindings.createJTableBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, masterTable, eLProperty, detailTable);
    columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${shipDate}"));
    columnBinding.setColumnName("Ship Date");
    columnBinding.setColumnClass(java.util.Date.class);
    columnBinding.setEditable(false);
    columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${tool}"));
    columnBinding.setColumnName("Tool");
    columnBinding.setColumnClass(String.class);
    columnBinding.setEditable(false);
    columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${collar}"));
    columnBinding.setColumnName("Collar");
    columnBinding.setColumnClass(String.class);
    columnBinding.setEditable(false);
    columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${xo}"));
    columnBinding.setColumnName("Xo");
    columnBinding.setColumnClass(String.class);
    columnBinding.setEditable(false);
    columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${xo2}"));
    columnBinding.setColumnName("Xo2");
    columnBinding.setColumnClass(String.class);
    columnBinding.setEditable(false);
    columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${surfaceKit}"));
    columnBinding.setColumnName("Surface Kit");
    columnBinding.setColumnClass(String.class);
    columnBinding.setEditable(false);
    columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${comments}"));
    columnBinding.setColumnName("Comments");
    columnBinding.setColumnClass(String.class);
    columnBinding.setEditable(false);
    columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${directions}"));
    columnBinding.setColumnName("Directions");
    columnBinding.setColumnClass(String.class);
    columnBinding.setEditable(false);
    jTableBinding.setSourceUnreadableValue(java.util.Collections.emptyList());
    bindingGroup.addBinding(jTableBinding);
    jTableBinding.bind();
    detailScrollPane.setViewportView(detailTable);
    detailTable.getColumnModel().getColumn(0).setResizable(false);
    detailTable.getColumnModel().getColumn(0).setPreferredWidth(10);
    detailTable.getColumnModel().getColumn(0).setHeaderValue(resourceMap.getString("detailTable.columnModel.title0")); // NOI18N
    detailTable.getColumnModel().getColumn(1).setResizable(false);
    detailTable.getColumnModel().getColumn(1).setPreferredWidth(5);
    detailTable.getColumnModel().getColumn(1).setHeaderValue(resourceMap.getString("detailTable.columnModel.title1")); // NOI18N
    detailTable.getColumnModel().getColumn(2).setResizable(false);
    detailTable.getColumnModel().getColumn(2).setPreferredWidth(5);
    detailTable.getColumnModel().getColumn(2).setHeaderValue(resourceMap.getString("detailTable.columnModel.title2")); // NOI18N
    detailTable.getColumnModel().getColumn(3).setResizable(false);
    detailTable.getColumnModel().getColumn(3).setPreferredWidth(5);
    detailTable.getColumnModel().getColumn(3).setHeaderValue(resourceMap.getString("detailTable.columnModel.title3")); // NOI18N
    detailTable.getColumnModel().getColumn(4).setResizable(false);
    detailTable.getColumnModel().getColumn(4).setPreferredWidth(5);
    detailTable.getColumnModel().getColumn(4).setHeaderValue(resourceMap.getString("detailTable.columnModel.title4")); // NOI18N
    detailTable.getColumnModel().getColumn(5).setResizable(false);
    detailTable.getColumnModel().getColumn(5).setPreferredWidth(5);
    detailTable.getColumnModel().getColumn(5).setHeaderValue(resourceMap.getString("detailTable.columnModel.title5")); // NOI18N
    detailTable.getColumnModel().getColumn(6).setResizable(false);
    detailTable.getColumnModel().getColumn(6).setPreferredWidth(300);
    detailTable.getColumnModel().getColumn(6).setHeaderValue(resourceMap.getString("detailTable.columnModel.title6")); // NOI18N
    detailTable.getColumnModel().getColumn(7).setResizable(false);
    detailTable.getColumnModel().getColumn(7).setPreferredWidth(300);
    detailTable.getColumnModel().getColumn(7).setHeaderValue(resourceMap.getString("detailTable.columnModel.title7")); // NOI18N
    deleteDetailButton.setAction(actionMap.get("deleteDetailRecord")); // NOI18N
    deleteDetailButton.setBackground(resourceMap.getColor("jButton1.background")); // NOI18N
    deleteDetailButton.setName("deleteDetailButton"); // NOI18N
    newDetailButton.setAction(actionMap.get("newDetailRecord")); // NOI18N
    newDetailButton.setBackground(resourceMap.getColor("jButton1.background")); // NOI18N
    newDetailButton.setName("newDetailButton"); // NOI18N
    jButton1.setAction(actionMap.get("editCustomer")); // NOI18N
    jButton1.setBackground(resourceMap.getColor("jButton1.background")); // NOI18N
    jButton1.setText(resourceMap.getString("jButton1.text")); // NOI18N
    jButton1.setName("jButton1"); // NOI18N
    jButton2.setAction(actionMap.get("editOrder")); // NOI18N
    jButton2.setBackground(resourceMap.getColor("jButton1.background")); // NOI18N
    jButton2.setText(resourceMap.getString("jButton2.text")); // NOI18N
    jButton2.setName("jButton2"); // NOI18N
    jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
    jLabel1.setName("jLabel1"); // NOI18N
    jTextField1.setName("jTextField1"); // NOI18N
    org.jdesktop.beansbinding.Binding binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, masterTable, org.jdesktop.beansbinding.ELProperty.create("${rowSorter}"), jTextField1, org.jdesktop.beansbinding.BeanProperty.create("text"));
    binding.setConverter(rowSorterToStringConverter1);
    bindingGroup.addBinding(binding);
    jLabel2.setIcon(resourceMap.getIcon("jLabel2.icon")); // NOI18N
    jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
    jLabel2.setName("jLabel2"); // NOI18N
    javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
    mainPanel.setLayout(mainPanelLayout);
    mainPanelLayout.setHorizontalGroup(
    mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(mainPanelLayout.createSequentialGroup()
    .addContainerGap()
    .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addComponent(detailScrollPane, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 1057, Short.MAX_VALUE)
    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, mainPanelLayout.createSequentialGroup()
    .addComponent(newDetailButton)
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
    .addComponent(jButton2)
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
    .addComponent(deleteDetailButton))
    .addComponent(masterScrollPane, javax.swing.GroupLayout.DEFAULT

  • Setting cell editor for individual cell in JTable

    Hi there,
    I want to provide individual cell editor for my JTable. Basically, my JTable shows property names and values. I want to show different cell editors for different properties.
    I followed the advice in this post:
    http://forum.java.sun.com/thread.jsp?forum=57&thread=423318
    but I have a question:
    I looked at the code of DefaultCellEditor. It just has a single editor component (the one provided in the constructor), so all the methods use the same component and certain aspects are customized for the type of component. Again, there can be only one type of component at a time.The problem that I am facing is that I will have different components for different row/column of the same table. So how do I implement some of the methods (for example, getCellEditorValue()), when I have multiple editor components?
    Also, how do I commit changes made by the user?
    I am extremely confused.
    Someone please help!
    Thanks.

    Actually, that's what I am currently doing.
    Here is my cell editor class:
    public class ObjectPropertyEditor extends DefaultCellEditor
           public ObjectPropertyEditor()
              super(new JTextField());
              Vector list = new Vector();
              list.add("Yes");
              list.add("No");
             myCombo = new JComboBox(list);
          public Component getTableCellEditorComponent(JTable table, Object value,
              boolean isSelected, int row, int column)
             String colName = (String)table.getValueAt(row,0);
             if(colName.equalsIgnoreCase("Leaf-Node?")) //if it is the "Leaf" property, return the combo box as the editor
                 return myCombo;
            else  //for all other properties, use JTextField of the super class
                return super.getTableCellEditorComponent(table,value,isSelected,row,column);
        private JComboBox myCombo;
    }The problem I have is that when I select a new item from the combo box, the new selection is not reflected in the tableModel. I don't know how I can achive that. I think I need the functionalities that DefaultCellEditor gives to its delegate when its constructor arguments is a combo box. But how can I get two different sets of functionalities (JTextField and JComboBox) ?
    Please help!
    Thanks.

  • JTable cell editor activate

    I am using many editors like JTextField & JButton, JComboBox, List etc. in my JTable
    All the things are working properly.
    Now i want the feature such that when table is navigated using Tab or Right-Left Arrow buttons the editor gets activated without pressing F2 or any key. ie Tab navigation should always keep my table editors always in edit state.

    Here's one way:
    JTable table = new JTable(...l)
         public void changeSelection(final int row, final int column, boolean toggle, boolean extend)
              super.changeSelection(row, column, toggle, extend);
              SwingUtilities.invokeLater( new Runnable()
                   public void run()
                        table.dispatchEvent(new KeyEvent(
                             table,
                             KeyEvent.KEY_PRESSED,
                             0,
                             0,
                             KeyEvent.VK_F2,
                             KeyEvent.CHAR_UNDEFINED) );
    };

  • How is it possible to show contents of JComboBox that aren't in list

    I have an application that I have developed over time that requires that I be able to select any item in a JComboBox list and send an actionEvent. In order to do this I set the value of the JComboBox selectedIndex to -1 indicating no selection. This enables me to select the first item in the list and send an actionEvent. The only problem is that the window where the items for the box appears is initially blank. (I don't know if window is the correct term). I would like the ability to place a message in this window such as "Please Select FooBar". Anyone know how to do this?

    Maybe something like this:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.plaf.basic.*;
    public class ComboBoxPrompt extends JFrame implements ActionListener
         JComboBox comboBox;
         public ComboBoxPrompt()
              String[] items = { "Bryan", "Nick", "Tom" };
              comboBox = new JComboBox( items );
              comboBox.setSelectedIndex(-1);
              comboBox.setRenderer( new PromptRenderer("Select Person") );
              getContentPane().add( comboBox, BorderLayout.NORTH );
              JButton button = new JButton("Clear Selection");
              getContentPane().add( button, BorderLayout.SOUTH );
              button.addActionListener(this);
         public void actionPerformed(ActionEvent e)
              comboBox.setSelectedIndex(-1);
         public static void main(String[] args)
              JFrame frame = new ComboBoxPrompt();
              frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
              frame.pack();
              frame.setLocationRelativeTo( null );
              frame.setVisible( true );
         class PromptRenderer extends BasicComboBoxRenderer
              private String prompt;
              public PromptRenderer(String prompt)
                   this.prompt = prompt;
              public Component getListCellRendererComponent(
                   JList list, Object value, int index, boolean isSelected, boolean cellHasFocus)
                   super.getListCellRendererComponent(list,
                        value, index, isSelected, cellHasFocus);
                   if (value == null)
                        setText( prompt );
                   return this;
    }

  • Imageicon in a JComboBox

    hi, i do a program to create "business case table", but i've a problem in the 2nd part of the table, because in my 2nd table i have a JComboBox with image, when i click the combobox the images are show, but when select some figure the cell don�t keep the image, only keep the text.
    Anyone can help me???
    Here is my principal class that create the principal screen and tables:
    /*                      Poseidon                                 */
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.border.*;
    import javax.swing.table.*;
    * Summary description for Poseidon
    *2052102
    public class Poseidon extends JFrame
         // Variables declaration
         private JTabbedPane jTabbedPane1;
         private JPanel contentPane, paineltabela, painelgrafo, painelvariavel, paineltarefa;
         private JTable tabelavariavel,tabelatarefa, tabelateste;
         private JScrollPane scrollvariavel, scrolltarefa;
         private int totallinhas, alt, al, linhastarefa,cont, linhas, tamanholinhas,
                        controlalinhas, index, contastring;
         private String variavel;
         private JComboBox combobox;
         JMenuItem sair, abrir, guardar, miadtarefa, miadvariavel;
         JTable [] tabelasvar = new JTable[30];
         JFrame w;
         // End of variables declaration
         public Poseidon()
              super("Poseidon");
              initializeComponent();
              this.setVisible(true);
          * This method is called from within the constructor to initialize the form.
          * WARNING: Do NOT modify this code. The content of this method is always regenerated
          * by the Windows Form Designer. Otherwise, retrieving design might not work properly.
          * Tip: If you must revise this method, please backup this GUI file for JFrameBuilder
          * to retrieve your design properly in future, before revising this method.
         private void initializeComponent()
              JMenuBar barra = new JMenuBar();
              setJMenuBar(barra);
              TratBarra trat = new TratBarra();
              tabelavariavel = new JTable();
              tabelatarefa = new JTable();
              tabelavariavel.getTableHeader().setReorderingAllowed(false);
              tabelavariavel.setModel(new DefaultTableModel());
              tabelavariavel.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
              tabelavariavel.setBackground(Color.cyan);
              tabelatarefa.getTableHeader().setReorderingAllowed(false);
              tabelatarefa.setModel(new DefaultTableModel());
              tabelatarefa.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
              tabelatarefa.setBackground(Color.white);
              CaixaCombinacao combobox = new CaixaCombinacao();
              DefaultCellEditor editor = new DefaultCellEditor(combobox);
              tabelatarefa.setDefaultEditor(Object.class, editor);
              painelvariavel = new JPanel();
              painelvariavel.setLayout(new GridLayout(1, 0));
              painelvariavel.setBorder(new TitledBorder("Variaveis"));
              painelvariavel.setBounds(15, 35, 490, 650);
              painelvariavel.setVisible(false);
              this.add(painelvariavel);
              scrollvariavel = new JScrollPane();
              scrollvariavel.setViewportView(tabelavariavel);
              painelvariavel.add(scrollvariavel);
              paineltarefa = new JPanel();
              paineltarefa.setLayout(new GridLayout(1,0));
              paineltarefa.setBorder(new TitledBorder("Tarefas"));
              paineltarefa.setBounds(506, 35, 490,650);
              paineltarefa.setVisible(false);
              this.add(paineltarefa);
              scrolltarefa = new JScrollPane();
              scrolltarefa.setViewportView(tabelatarefa);
              paineltarefa.add(scrolltarefa);
              tamanholinhas = 1;
              linhas=1;
              cont=0;
              JMenu arquivo = new JMenu("Arquivo");
              JMenu mtabela = new JMenu("Tabela");
              arquivo.setMnemonic(KeyEvent.VK_A);
              mtabela.setMnemonic(KeyEvent.VK_T);
              miadvariavel = new JMenuItem("Adicionar Variavel");
              miadtarefa = new JMenuItem("Adicionar Tarefa");
              abrir = new JMenuItem("Abrir");
              guardar = new JMenuItem("Guardar");
              sair = new JMenuItem("Sair");
              sair.addActionListener(trat);
              miadvariavel.addActionListener(trat);
              miadtarefa.addActionListener(trat);
              mtabela.add(miadvariavel);
              miadvariavel.setMnemonic(KeyEvent.VK_V);
              mtabela.add(miadtarefa);
              miadtarefa.setMnemonic(KeyEvent.VK_F);
              arquivo.add(abrir);
              abrir.setMnemonic(KeyEvent.VK_B);
              arquivo.add(guardar);
              guardar.setMnemonic(KeyEvent.VK_G);
              arquivo.addSeparator();
              arquivo.add(sair);
              sair.setMnemonic(KeyEvent.VK_S);
              barra.add(arquivo);
              barra.add(mtabela);
              jTabbedPane1 = new JTabbedPane();
              contentPane = (JPanel)this.getContentPane();
              paineltabela = new JPanel();
              painelgrafo = new JPanel();
              // jTabbedPane1
              jTabbedPane1.addTab("Tabela", paineltabela);
              jTabbedPane1.addTab("Grafo", painelgrafo);
              jTabbedPane1.addChangeListener(new ChangeListener() {
                   public void stateChanged(ChangeEvent e)
                        painelvariavel.setVisible(false);
              // contentPane
              contentPane.setLayout(null);
              addComponent(contentPane, jTabbedPane1, 11,10,990,690);
              // paineltabela
              paineltabela.setLayout(null);
              // painelgrafo
              painelgrafo.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
              // Poseidon
              this.setTitle("UMa Poseidon");
              this.setLocation(new Point(2, 1));
              this.setSize(new Dimension(558, 441));
              this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
              this.setExtendedState(MAXIMIZED_BOTH);
         /** 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 jTabbedPane1_stateChanged(ChangeEvent e)
              System.out.println("\njTabbedPane1_stateChanged(ChangeEvent e) called.");
              // TODO: Add any handling code here
         // TODO: Add any method code to meet your needs in the following area
         private class TratBarra implements ActionListener{
              public void actionPerformed(ActionEvent e){
                   if(e.getSource() == sair){
                        int op = JOptionPane.showConfirmDialog(null, "Deseja mesmo fechar o aplicativo?","Sair", JOptionPane.YES_NO_OPTION);
                        if(op == JOptionPane.YES_OPTION){
                             System.exit(0);
                   if(e.getSource() == miadvariavel){
                        final JFrame w = new JFrame();
                        new AdVariavel(w);
                   if(e.getSource() == miadtarefa){
                        final JFrame w = new JFrame();
                        new AdTarefa(w);
    //============================= Testing ================================//
    //=                                                                    =//
    //= The following main method is just for testing this class you built.=//
    //= After testing,you may simply delete it.                            =//
    //======================================================================//
         public static void main(String[] args)
              Spash sp = new Spash(3000);
              sp.mostraTela();
              JFrame.setDefaultLookAndFeelDecorated(true);
              JDialog.setDefaultLookAndFeelDecorated(true);
              try
                   UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
              catch (Exception ex)
                   System.out.println("Failed loading L&F: ");
                   System.out.println(ex);
              new Poseidon();
    //= End of Testing =
    private class AdVariavel extends JDialog
         // Variables declaration
         private JLabel jLabel1;
         private JTextField jTextField1;
         private JButton varOK;
         private JButton varCancel;
         private JPanel contentPane;
         private JTextField jTextField2;
         private JList listadominio;
         private JScrollPane jScrollPane1;
         private JButton varAdiciona;
         private JButton varRemove;
         private JPanel jPanel1;
         private DefaultListModel modelo1;
         // End of variables declaration
         public AdVariavel(Frame w)
              super(w);
              initializeComponent();
              // TODO: Add any constructor code after initializeComponent call
              this.setVisible(true);
          * This method is called from within the constructor to initialize the form.
          * WARNING: Do NOT modify this code. The content of this method is always regenerated
          * by the Windows Form Designer. Otherwise, retrieving design might not work properly.
          * Tip: If you must revise this method, please backup this GUI file for JFrameBuilder
          * to retrieve your design properly in future, before revising this method.
         private void initializeComponent()
              modelo1 = new DefaultListModel();
              jLabel1 = new JLabel();
              jTextField1 = new JTextField();
              varOK = new JButton();
              varCancel = new JButton();
              contentPane = (JPanel)this.getContentPane();
              jTextField2 = new JTextField();
              listadominio = new JList(modelo1);
              jScrollPane1 = new JScrollPane();
              varAdiciona = new JButton();
              varRemove = new JButton();
              jPanel1 = new JPanel();
              // jLabel1
              jLabel1.setText("Nome da vari�vel:");
              // jTextField1
              jTextField1.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e)
                        jTextField1_actionPerformed(e);
              // varOK
              varOK.setText("OK");
              varOK.setMnemonic(KeyEvent.VK_O);
              varOK.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e)
                        varOK_actionPerformed(e);
              // varCancel
              varCancel.setText("Cancelar");
              varCancel.setMnemonic(KeyEvent.VK_C);
              varCancel.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e)
                        varCancel_actionPerformed(e);
              // contentPane
              contentPane.setLayout(null);
              addComponent(contentPane, jLabel1, 12,12,105,18);
              addComponent(contentPane, jTextField1, 118,10,137,22);
              addComponent(contentPane, varOK, 170,227,83,28);
              addComponent(contentPane, varCancel, 257,227,85,28);
              addComponent(contentPane, jPanel1, 12,42,332,180);
              // jTextField2
              jTextField2.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e)
                        jTextField2_actionPerformed(e);
              // listadominio
              listadominio.addListSelectionListener(new ListSelectionListener() {
                   public void valueChanged(ListSelectionEvent e)
                        listadominio_valueChanged(e);
              // jScrollPane1
              jScrollPane1.setViewportView(listadominio);
              // varAdiciona
              varAdiciona.setText("Adicionar");
              varAdiciona.setMnemonic(KeyEvent.VK_A);
              varAdiciona.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e)
                        varAdiciona_actionPerformed(e);
              // varRemove
              varRemove.setText("Remover");
              varRemove.setMnemonic(KeyEvent.VK_R);
              varRemove.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e)
                        varRemove_actionPerformed(e);
              // jPanel1
              jPanel1.setLayout(null);
              jPanel1.setBorder(new TitledBorder("Dominio:"));
              addComponent(jPanel1, jTextField2, 17,22,130,22);
              addComponent(jPanel1, jScrollPane1, 165,21,154,144);
              addComponent(jPanel1, varAdiciona, 56,50,89,28);
              addComponent(jPanel1, varRemove, 57,84,88,28);
              // AdTarefas
              this.setTitle("Adicionar Variavel");
              this.setLocation(new Point(1, 0));
              this.setSize(new Dimension(367, 296));
              this.setLocationRelativeTo(null);
              this.setResizable(false);
         /** 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 jTextField1_actionPerformed(ActionEvent e)
              System.out.println("\njTextField1_actionPerformed(ActionEvent e) called.");
              // TODO: Add any handling code here
         private void varOK_actionPerformed(ActionEvent e)
              System.out.println("\nvarOK_actionPerformed(ActionEvent e) called.");
              if (jTextField1 == null){
                   return;
              if (jTextField1.getText().length()<1){
                   JOptionPane.showMessageDialog(null,"N�o introduziu nenhuma variavel","AVISO", 1 );
                   jTextField1.requestFocus();
                   return;
              else {
                   if (modelo1.getSize() == 0){
                        JOptionPane.showMessageDialog(null,"N�o introduziu nenhum dominio","AVISO", 1 );
                        return;
                   else{
                        painelvariavel.add(scrollvariavel);
                        index = 0;
                        variavel = jTextField1.getText();
                        contastring = variavel.length();
                        System.out.println(contastring);
                        DefaultTableModel dtm = (DefaultTableModel)tabelavariavel.getModel();
                        tabelavariavel.getTableHeader().setBackground(Color.yellow);
                        dtm.addColumn(variavel, new Object[]{});
                        al = modelo1.getSize();
                        totallinhas = al;
                        for(int i = 0;i < modelo1.getSize();i++){
                             listadominio.setSelectedIndex(index) ;
                             Object dominio = listadominio.getSelectedValue();
                             dtm.addRow(new Object[]{dominio});
                             index ++;
                        tabelasvar[cont] = tabelavariavel;
                        cont++;
                        System.out.println(cont);
                        for(int i=0;i<cont;i++){
                             tabelateste = tabelasvar;
                             linhas = tabelateste.getRowCount();
                             if (linhas >= tamanholinhas){
                                  tamanholinhas = linhas;
                        for (int i=0;i<cont;i++){
                             tabelateste = tabelasvar[i];
                             System.out.println(linhas);
                             linhas = tabelateste.getRowCount();
                             tabelateste.setRowHeight((tamanholinhas/linhas)*20);
                             tabelasvar[i] = tabelateste;
                             System.out.println(tabelateste);
                   tabelavariavel = new JTable();
              scrollvariavel = new JScrollPane();
              painelvariavel.add(tabelavariavel);
              tabelavariavel.setBackground(Color.cyan);
         tabelavariavel.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
                   scrollvariavel.setViewportView(tabelavariavel);
                   painelvariavel.setVisible(true);
         tabelavariavel.getTableHeader().setReorderingAllowed(false);
         this.setVisible(false);
         miadtarefa.setEnabled(true);
         miadvariavel.setEnabled(true);
         DefaultTableModel dtm = (DefaultTableModel)tabelatarefa.getModel();
                   tabelatarefa.getTableHeader().setBackground(Color.yellow);
                   controlalinhas = tamanholinhas - linhastarefa;
                   for(int i = 0;i < controlalinhas;i++){
                             dtm.addRow(new Object[]{});
                             linhastarefa++;
                   tabelatarefa.setRowHeight((tamanholinhas/linhas)*20);
              // TODO: Add any handling code here
         private void varCancel_actionPerformed(ActionEvent e)
              System.out.println("\nvarCancel_actionPerformed(ActionEvent e) called.");
              this.setVisible(false);
         private void jTextField2_actionPerformed(ActionEvent e)
              System.out.println("\njTextField2_actionPerformed(ActionEvent e) called.");
              // TODO: Add any handling code here
         private void listadominio_valueChanged(ListSelectionEvent e)
              System.out.println("\nlistadominio_valueChanged(ListSelectionEvent e) called.");
              if(!e.getValueIsAdjusting())
                   Object o = listadominio.getSelectedValue();
                   System.out.println(">>" + ((o==null)? "null" : o.toString()) + " is selected.");
                   // TODO: Add any handling code here for the particular object being selected
         private void varAdiciona_actionPerformed(ActionEvent e)
              System.out.println("\nvarAdiciona_actionPerformed(ActionEvent e) called.");
              if(jTextField2.getText().length()>=1){
                   modelo1.addElement(jTextField2.getText());
                   jTextField2.setText("");
                   jTextField2.requestFocus();
         private void varRemove_actionPerformed(ActionEvent e)
              System.out.println("\nvarRemove_actionPerformed(ActionEvent e) called.");
              int index = listadominio.getSelectedIndex();
              modelo1.remove(index);
         // TODO: Add any method code to meet your needs in the following area
    private class AdTarefa extends JDialog
         // Variables declaration
         private JLabel jLabel1;
         private JTextField jTextField1;
         private JButton tarOK;
         private JButton tarCancel;
         private JPanel contentPane;
         private JPanel jPanel1;
         // End of variables declaration
         public AdTarefa(Frame w)
              super(w);
              initializeComponent();
              // TODO: Add any constructor code after initializeComponent call
              this.setVisible(true);
         * This method is called from within the constructor to initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is always regenerated
         * by the Windows Form Designer. Otherwise, retrieving design might not work properly.
         * Tip: If you must revise this method, please backup this GUI file for JFrameBuilder
         * to retrieve your design properly in future, before revising this method.
         private void initializeComponent()
              jLabel1 = new JLabel();
              jTextField1 = new JTextField();
              tarOK = new JButton();
              tarCancel = new JButton();
              contentPane = (JPanel)this.getContentPane();
              // jLabel1
              jLabel1.setText("Nome da tarefa:");
              // jTextField1
              jTextField1.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e)
                        jTextField1_actionPerformed(e);
              // tarOK
              tarOK.setText("OK");
              tarOK.setMnemonic(KeyEvent.VK_O);
              tarOK.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e)
                        tarOK_actionPerformed(e);
              // tarCancel
              tarCancel.setText("Cancelar");
              tarCancel.setMnemonic(KeyEvent.VK_C);
              tarCancel.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e)
                        tarCancel_actionPerformed(e);
              // contentPane
              contentPane.setLayout(null);
              addComponent(contentPane, jLabel1, 12,12,105,18);
              addComponent(contentPane, jTextField1, 118,10,120,22);
              addComponent(contentPane, tarOK, 10,50,83,28);
              addComponent(contentPane, tarCancel, 153,50,85,28);
              // AdTarefas
              this.setTitle("Adicionar Tarefa");
              this.setLocation(new Point(1, 0));
              this.setSize(new Dimension(250, 120));
              this.setLocationRelativeTo(null);
              this.setResizable(false);
         /** 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 jTextField1_actionPerformed(ActionEvent e)
              System.out.println("\njTextField1_actionPerformed(ActionEvent e) called.");
              // TODO: Add any handling code here
         private void tarOK_actionPerformed(ActionEvent e)
              System.out.println("\ntarOK_actionPerformed(ActionEvent e) called.");
              if (jTextField1 == null){
                   return;
              if (jTextField1.getText().length()<1){
                   JOptionPane.showMessageDialog(null,"N�o introduziu nenhuma tarefa","AVISO", 1 );
                   jTextField1.requestFocus();
                   return;
              else{
                   String variavel = jTextField1.getText();
                   DefaultTableModel dtm = (DefaultTableModel)tabelatarefa.getModel();
                   dtm.addColumn(variavel,new Object[]{});
                   controlalinhas = tamanholinhas - linhastarefa;
                   for(int i = 0;i < controlalinhas;i++){
                             dtm.addRow(new Object[]{});
                             linhastarefa++;
                   for(int i=0; i < tabelatarefa.getColumnCount(); i++){
                        tabelatarefa.getColumnModel().getColumn(i).setPreferredWidth(100);
                   tabelatarefa.getColumnModel().getColumn(i).setResizable(false);
                   tabelatarefa.getTableHeader().setBackground(Color.yellow);
                   tabelatarefa.setRowHeight((tamanholinhas/linhas)*20);
                   paineltarefa.setVisible(true);
         tabelatarefa.getTableHeader().setReorderingAllowed(true);
         this.setVisible(false);
         miadtarefa.setEnabled(true);
         miadvariavel.setEnabled(true);
         // TODO: Add any handling code here
         private void tarCancel_actionPerformed(ActionEvent e)
              System.out.println("\ntarCancel_actionPerformed(ActionEvent e) called.");
              this.setVisible(false);
    now the code to create the JComboBox is here:
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class CaixaCombinacao extends JComboBox{
         ImageIcon[] imagens;
        String[] op = {"x", "check"};
    public CaixaCombinacao(){
         imagens = new ImageIcon[op.length];
        Integer[] intArray = new Integer[op.length];
        for (int i = 0; i < op.length; i++) {
             intArray[i] = new Integer(i);
            imagens[i] = createImageIcon("imagens/" + op[i] + ".gif");
            this.addItem(imagens);
    if (imagens[i] != null) {
    imagens[i].setDescription(op[i]);
         JComboBox lista = new JComboBox(intArray);
         ComboBoxRenderer renderer= new ComboBoxRenderer();
         lista.setRenderer(renderer);
    protected static ImageIcon createImageIcon(String path) {
    java.net.URL imgURL = CaixaCombinacao.class.getResource(path);
    if (imgURL != null) {
         return new ImageIcon(imgURL);
    return null;
    class ComboBoxRenderer extends JLabel
    implements ListCellRenderer {
    public ComboBoxRenderer() {
    setOpaque(true);
    setHorizontalAlignment(CENTER);
    setVerticalAlignment(CENTER);
    public Component getListCellRendererComponent(
    JList list,
    Object value,
    int index,
    boolean isSelected,
    boolean cellHasFocus) {
                   int selectedIndex = ((Integer)value).intValue();
                   if (isSelected) {
    setBackground(list.getSelectionBackground());
    setForeground(list.getSelectionForeground());
    } else {
    setBackground(list.getBackground());
    setForeground(list.getForeground());
                   ImageIcon icon = imagens[selectedIndex];
                   String opc = op[selectedIndex];
    setIcon(icon);
    return this;

    I'm sure 90% of the code posted here has nothing to do with displaying images in a JTable.
    Here is an example that shows how to display an icon in a table:
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.table.*;
    public class TableIcon extends JFrame
         public TableIcon()
              String[] columnNames = {"Picture", "Description"};
              Object[][] data =
                   {new ImageIcon("copy16.gif"), "Copy"},
                   {new ImageIcon("add16.gif"), "Add"},
              DefaultTableModel model = new DefaultTableModel(data, columnNames);
              JTable table = new JTable( model )
                   //  Returning the Class of each column will allow different
                   //  renderers to be used based on Class
                   public Class getColumnClass(int column)
                        return getValueAt(0, column).getClass();
              table.setPreferredScrollableViewportSize(table.getPreferredSize());
              JScrollPane scrollPane = new JScrollPane( table );
              getContentPane().add( scrollPane );
         public static void main(String[] args)
              TableIcon frame = new TableIcon();
              frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
              frame.pack();
              frame.setVisible(true);
    }If this doesn't help then post a similiar demo program that shows the problems you are having, not your entire application.

  • Editable JCombobox cell editor length limit

    Hi All,
    I have an editable JCombobox as a celleditor to one of the column in JTable, How do I limit the characters in the cell editor?
    Thanks

    A JComboBox uses a JTextField as it's cell editor. You should read up on how you would do this for a normal JTextField by using a custom Document:
    http://java.sun.com/docs/books/tutorial/uiswing/components/generaltext.html
    Here's an example using JComboBox. I haven't tried it in a JTable but I assume it should work.
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.text.*;
    import javax.swing.plaf.basic.*;
    public class ComboBoxNumericEditor extends BasicComboBoxEditor
         public ComboBoxNumericEditor(JComboBox box)
              editor.setDocument( new NumericListDocument(box.getModel()) );
         public static void main(String[] args)
              String[] items = { "one", "two", "three", "four" };
              JComboBox list = new JComboBox( items );
              list.setEditable( true );
              list.setEditor( new ComboBoxNumericEditor( list ) );
              JFrame frame = new JFrame();
              frame.getContentPane().add( list );
              frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
              frame.pack();
              frame.setLocationRelativeTo( null );
              frame.setVisible( true );
         class NumericListDocument extends PlainDocument
              ListModel model;
              public NumericListDocument(ListModel model)
                   this.model = model;
              public void insertString(int offset, String text, AttributeSet a)
                   throws BadLocationException
                   //  Accept all entries in the ListModel
                   for (int i = 0; i < model.getSize(); i++)
                        Object item = model.getElementAt(i);
                        if (text.equals( item.toString() ))
                             super.insertString(offset, text, a);
                             return;
                   //  Build the new text string assuming the insert is successfull
                   String oldText = getText(0, getLength());
                   String newText =
                        oldText.substring(0, offset) + text + oldText.substring(offset);
                   //  Edit the length of the new string
                   if (newText.length() > 2)
                        Toolkit.getDefaultToolkit().beep();
                        return;
                   //  Only numeric characters are allowed in the new string
                   //  (appending the "0" will allow an empty string to be valid)
                   try
                        Integer.parseInt(newText + "0");
                        super.insertString(offset, text, a);
                   catch (NumberFormatException e)
                        Toolkit.getDefaultToolkit().beep();
    }

  • How to get Date value from database and display them in a drop down list?

    Hello.
    In my Customers table, I have a column with Date data type. I want to create a form in JSP, where visitors can filter Customers list by year and month.
    All I know is this piece of SQL that is convert the date to the dd-mm-yyyy format:
    SELECT TO_CHAR(reg_date,'dd-mm-yyyy') from CustomersAny ideas of how this filtering possible? In my effort not to sound like a newbie wanting to be spoonfed, you can provide me link to external notes and resources, I'll really appreciate it.
    Thanks,
    Rightbrainer.

    Hi
    What part is your biggest problem?? I am not experienced in getting data out of a database, but the way to get a variable amount of data to show in a drop down menu, i have just messed around with for some time and heres how i solved it... In my app, what i needed was, a initial empty drop down list, and then using input from a text-field, users could add elements to a Vector that was passed to a JComboBox. Heres how.
    package jcombobox;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.Vector;
    import javax.swing.*;
    public class Main extends JApplet implements ActionListener {
        private Vector<SomeClass> list = new Vector<SomeClass>();
        private JComboBox dropDownList = new JComboBox(list);
        private JButton addButton = new JButton("add");
        private JButton remove = new JButton("remove");
        private JTextField input = new JTextField(10);
        private JPanel buttons = new JPanel();
        public Main() {
            addButton.addActionListener(this);
            remove.addActionListener(this);
            input.addActionListener(this);
            buttons.setLayout(new FlowLayout());
            buttons.add(addButton);
            buttons.add(remove);
            add(dropDownList, "North");
            add(input, "Center");
            add(buttons, "South");
        public void actionPerformed(ActionEvent e) {
            if (e.getSource() == addButton) {
                list.addElement(new SomeClass(input.getText()));
                input.setText("");
            } else if (e.getSource() == remove) {
                int selected = dropDownList.getSelectedIndex();
                dropDownList.removeItemAt(selected);
        public void init(String[] args) {
            setSize(400,300);
            getContentPane().setLayout(new BorderLayout());
            getContentPane().add(new Main());
    }And that "SomeClass" is show here
    package jcombobox;
    public class SomeClass {
        private String text;
        public SomeClass(String input) {
            text = input;
        public String toString() {
            return text;
    }One of the things i struggled a lot with was to get the dropdown menu to show some usefull result. If the list just contains class references it will show the memory code that points to that class. Thats where the toString cones in handy. But it took me some time to figure that one out, a laugh here is welcome as it should have been obvious :-)
    When the app is as simple as this one, using a <String> vector would have been easier, but this is just to demonstrate how to place classes in a vector and get some usefull info out of it, hope this answered some of your question :-)
    The layout might have been easier to write, than using the toppanel created by the JApplet and then the two additional JPanels, but it was just a small app brewed together in 15 minutes. Please comments on my faults, so that i can learn of it.
    If you need any of the code specified more, please let me know. Ill be glad to,

  • Onload JComboBox should display "Search" in it

    I want to display "Search" text by default in JComboBox. But it should not be added into JComboBox list, once I select something from drop down or click on JComboBox "Search" text should goes off. On loading the application I want to show to user that this is Search Box. The "Search" text should not be in the the JComboBox list.
    I am pasting the sample code below.
    package applet;
    import java.awt.BorderLayout;
    import javax.swing.JComboBox;
    import javax.swing.JFrame;
    public class ComboBox extends JFrame{
         public static void main(String args[])
              ComboBox frmCombo= new ComboBox();
              String[] pets = {"Alen", "Merry"};
              JComboBox cmbBox = new JComboBox(pets);
              cmbBox.setEditable(true);
              frmCombo.add(cmbBox, BorderLayout.NORTH);
              frmCombo.setSize(200, 200);
              frmCombo.setVisible(true);
    }

    import java.awt.*;
    import java.awt.event.FocusEvent;
    import javax.swing.*;
    import javax.swing.plaf.basic.BasicComboBoxEditor;
    public class ComboBoxSearch extends JFrame {
         public static void main( String args[] ) {
              ComboBoxSearch frmCombo = new ComboBoxSearch();
              String[] pets = { "Alen", "Merry" };
              JComboBox cmbBox = new JComboBox( pets );
              cmbBox.setEditable( true );
              cmbBox.setEditor( new IndicateSearchEditor() );
              frmCombo.setLayout( new BorderLayout() );
              frmCombo.add( new JTextField(), BorderLayout.NORTH );
              frmCombo.add( cmbBox, BorderLayout.SOUTH );
              frmCombo.pack();
              frmCombo.setVisible( true );
         static class IndicateSearchEditor extends BasicComboBoxEditor {
              private boolean once = false;
              private Object value;
              public IndicateSearchEditor() {
                   super();
                   editor.addFocusListener( this );
              public void focusGained( FocusEvent e ) {
                   if ( !once ) {
                        once = true;
                        setItem( value );
                        value = null;
              public void setItem( Object anObject ) {
                   super.setItem( anObject );
                   if ( !once ) {
                        value = anObject;
                        editor.setText( "Search" );
    }

  • Changing background of selected item in JComboBox when Uneditable

    I need to change the color of the items in a JComboBox list based on the values that change at runtime. I have accomplished this by creating and using a class extended from DefaultListCellRenderer.
    The combobox is enabled and uneditable. The problem is that in 1.5 the behavior changed and now the selected item gets a white background that is set by the UI or DefaultJComboBox. I can no longer set the background for the selected item.
    I have tried using the ComBox Editor. Also, the universal option of UIManager.put("ComboBox.background", Color.xxx) will not work since I have multiple boxes with different backgrounds.
    Does anyone no a work around?

    Unless I misread your problem you may find that your use of DefaultListCellRenderer is incorrect. The following snippet of code (using Java 1.5.0_07) will make the combo box red. The unselected items in the dropdown will be magenta and the selected item orange.
    combo.setBackground(Color.red);
    combo.setRenderer(new DefaultListCellRenderer()     {
         public Component getListCellRendererComponent(JList list,
                    Object value,
                    int index,
                    boolean isSelected,
                    boolean cellHasFocus)
                   Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
                   if(isSelected)
                        c.setBackground(Color.ORANGE);
                   else
                        c.setBackground(Color.MAGENTA);
                   return c;
         });

  • Jcombobox size

    hi guys, I have a JLabel follwed by a rigidarea followed by a JComboBox...omgggggggggggggggggg, the JComboBox takes up all the space, it is soooo bit, it looks sooooooooo stupid.
    I tried googling on setting the size, this person here asked the same question I want but no one replied to him
    https://lists.xcf.berkeley.edu/lists/advanced-java/2000-April/008693.html
    Please help me. I cant set the size hand-coded, cos the JComboBox lists the results of a SQL query, and so its size should be dependent on the longest value
    Thanks guys

    Thanks, I just decided to hand code it in...that code is too much to just copy and paste as it would probably be plagiarising!!!

  • Help - JComboBox Selection

    Need some help.
    I am developing an application that has two JComboBox. First box is Make and second box is Model. The first JComboBox (make) is used to select the approprate second JComboBox list. I am not able to display the updated second JComboBox. That is , the application uses (String)makeCombo.getSelectedItem() correctly, and returns the correct item selected from my makeCombo JComboBox, but I am unable to update the Model JComboBox. I am convinced the problem lies in some sort of update or set/get method that I am not calling.
    Any thoughts? Your time is appreciated.
    Craig

    there are 999,999,999 possibilities on why they wont response
    So, how bout start with posting your code section(s) with the stuff you're talking about?

Maybe you are looking for

  • Cannot Connect

    this morning when i woke up i could not do anything online. I Use a wifi network, I can use the WiFi netowk to connect to other computers but not the internet. All the other computers on the network can connect to the internet also so i know this pro

  • Offline Vs detach

    So I wanted to move the mdf and ldf for a specfic database to a new file location. I detached the database and then tried to copy the mdf to the new location. Access denied. I am domain admin, SA and had run windows explorer "as administrator" while

  • Question on best way to upgrade

    I am in the process of coming up with an upgrade plan. We are currently running IMS 5.2 and will be upgrading to the new 6.x product hopefully pretty soon. I have a couple of questions that I would like to get peoples input on. First we will be upgra

  • Dipslyaning Selection-screen values on ALV....

    Hi,   Please guide on Displaying Input parameters (selection screen) on the top of ALV grid in the output. Regards Krishna

  • Free samples

    I am getting some free samples from vendor of one material which is I am using regularly and material has certain cost in material master. I know I can get it by creating PO with free of charge indicator. But then when I will receive it and I want to