Note that there are some explanatory texts on larger screens.

plurals
  1. POUpdating a specific cell in a JTable using a ComboBox
    text
    copied!<p>I am reading in data using DOM Parser to update a <code>JTable</code>. I have a Column (ValidValues) that may not necessarily be located in the XML. </p> <p>However, if this tag is located when reading in from the XML, I take the value and use this to from an SQL query to return a vector of the records available. </p> <p>I then wish to populate the JTable with a specific combo box of the values returned on the correct row that the tag was read. E.G I may not read a tag until the 17th row has been read in from the XML document.</p> <p>I have already completed two similar JCombo boxes in the same code but they remain constant, so there is no issue with them. </p> <p>As this changes between cells I'm unsure of how to proceed, I looked through Oracle tutorials but they only seem to demonstrate how one column can be changed. Further research has found nothing relating to this area either. </p> <p>Code for constant JComboBox updated through vector:</p> <pre><code> propColumn = table.getColumnModel().getColumn(ENV_PROPERTIES_COLUMN); propComboBox = new JComboBox(); propComboBox.addItem(""); constructEnvProperties(); propColumn.setCellEditor(new DefaultCellEditor(propComboBox)); public void constructEnvProperties(){ IWM781EnvProfilePropertiesCtl ctl = new IWM781EnvProfilePropertiesCtl(); Vector&lt;IWM781EnvProfileProperties&gt; recordSet = ctl.getRecordSet("TestEnvXXX", con); for(int i = 0; i &lt; recordSet.size(); i++){ logger.debug(recordSet.get(i).getProp781Property()); propComboBox.addItem(recordSet.get(i).getProp781Property()); } } </code></pre> <p>Attempt at a variant combo box:</p> <pre><code>if(tableEntryElement.getElementsByTagName("ValidValues").item(0) != null){ // Build combo box based on &lt;SystemCode&gt; tag logger.debug(tableEntryElement.getElementsByTagName("ValidValues").item(0).getTextContent()); TableColumn optionColumn = table.getColumnModel().getColumn(OPTION_COLUMN); JComboBox optionComboBox = new JComboBox(); optionComboBox.addItem(""); constructOptions(tableEntryElement); optionColumn.setCellEditor(new DefaultCellEditor(optionComboBox)); } </code></pre> <p>I know the issue here will be:</p> <pre><code> TableColumn optionColumn = table.getColumnModel().getColumn(OPTION_COLUMN); </code></pre> <p>as it's referencing the entire column, but any ideas would be greatly appreciated.</p> <p>I've also briefly read the API for <code>TableColumn</code> which I'm still in the middle of to see if I can find a way to reference the row of the column.</p> <p>Thanks in advance</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload