JTable, verifying data before changing cell value

I am trying to trap erroneous dataentry into a JTable. I have some fields which are populated by objects which are a subclass of Number. My original though was to trap the data entry at the setValueAt method and verify it there; however, if I enter alpha characters into the cell, it never gets to setValueAt. Any ideas?

The easy fix was to short circuit getColumnClass to return the class of string. The constructor doesn't bomb and I can trap it at the setValueAt() method in my table model.
This is a database application which displays information from a three table join. I have written methods to set all of the master values to the editted values.
Basic idea is to create Hashmaps keyed off of the unique keys for each row of each master table. A vector is placed in a hashmap for each unique key. Each row with that key is then placed in the vector. If a cell from a master is updated, it is easy to grab the key, then grab the vector of all of the rows with that key in it, and update all of the associated rows.
Not sure if anyone else will find it useful, but here it is.
package com.cessna.ewt.bay;
import com.cessna.ewt.util.WeightNumber;
import com.cessna.ewt.util.WeightEmployee;
import java.awt.Toolkit ;
import java.util.Vector;
import javax.swing.JLabel ;
import javax.swing.table.AbstractTableModel;
import javax.swing.JOptionPane;
import java.awt.Color;
import java.util.HashMap;
* Table Model for the Bay application
public class BayTableModel extends AbstractTableModel{
public BayTableModel(WeightEmployee nUser) {
this(); user = nUser;
public BayTableModel()
{    super();
changed = false;
data = new Vector();
for (int iloop = 0; iloop < 20; iloop++) {
     data.add(new BayRecord());     }
public BayTableModel(Vector nData) {
super();
changed = false;
data = nData;
public int getColumnCount() {    
return BayRecord.VISABLE_COLUMN_COUNT ;
public int getRowCount() {    
return data.size();
public int getPreferredColumnWidth(int col) {
return COLUMN_WIDTH[col];
public Object getValueAt(int row, int col) {
BayRecord dataRecord = (BayRecord) data.get(row);
return dataRecord.get(col);
}public String getColumnName(int column) {
return BayRecord.COLUMN_NAMES[column];
public Class getColumnClass(int c) {
if(c == BayRecord.FS) {
System.out.println("DEBUG: GET COLUMN CLASS FOR FS");
return BayRecord.getColumnClass(c);
public boolean isCellEditable(int row, int col) {
if (user != null) {
if (user.canApprove()) {
//System.out.println(user + " can approve.");
return true;
//System.out.println(user + " can not approve.");
return false;
public Color getNonEditableBackground(int col) {
return Color.lightGray;
public Color getEditableBackground(int col) {
return Color.white;
public void setUser(WeightEmployee nUser) {
user = nUser;
public void setValueAt(Object aValue, int row, int column) {
System.out.println("into setValueAt");
BayApplet applet = BayApplet.bayApplet;
BayRecord dataRecord = (BayRecord) data.get(row);
String oldValue = dataRecord.get(column).toString();
String newValue = aValue.toString();
//Don't do anything if it hasn't changed     
if ( newValue.compareTo(oldValue) == 0 ) return;
// Do data validation here
switch ( column) {
case (BayRecord.BAY ):
case (BayRecord.BAY_DESCRIPTION ) :
     //update for the entire bay
     updateTable(column,dataRecord.get(BayRecord.EWTBMX_ID).toString(),newValue);
     dataRecord.setBayChanged(true);
     break;
case (BayRecord.SUBBAY_DESCRIPTION ) :
//update for all records associated with this subbay
          dataRecord.setSubBayChanged(true);
     updateTable(column,dataRecord.get(BayRecord.EWTSB_ID).toString(),newValue);
     break;
case (BayRecord.FS ) :
case (BayRecord.BL ) :
case (BayRecord.WL ) :
System.out.println("new value = " + newValue);
try {
Float.parseFloat(aValue.toString());
catch (Exception e) {
          JOptionPane.showMessageDialog(applet
     , e
, "BayTableModel.setValueAt(...) Format Error"
, JOptionPane.ERROR_MESSAGE) ;
return; // input value cannot convert to number
WeightNumber tempNumber =new WeightNumber(newValue,WeightNumber.CG_FORMAT );
dataRecord.set(column,tempNumber);
dataRecord.setBayPointChanged(true);
break;
default: if ( newValue.compareTo(oldValue) != 0 ) {
dataRecord.set(column,aValue);
applet.setModified(true);
* Updates all of the bay discriptions for table
public void updateTable (int column, String key ,String newValue ){
HashMap tempMap;
switch(column) {
case BayRecord.BAY :
case BayRecord.BAY_DESCRIPTION :
     tempMap = bayMap;
     break;
case BayRecord.SUBBAY_DESCRIPTION :
     tempMap = subBayMap;
     break;
default: return; }
// Does the master relationship exist?     
if (! tempMap.containsKey(key)){
     return;
if ( tempMap.get(key) == null) return;
// get the vector that is associated with this key
// associated with key
Vector tempVector = (Vector)tempMap.get(key);
for (int iloop = 0;iloop < tempVector.size();iloop++) {
     BayRecord tempRecord = (BayRecord) tempVector.get(iloop);
     tempRecord.set(column,newValue);
* Returns the alignment of the specified <I>col</I> in the table.
public int getAlignment(int col){
return (COLUMN_ALIGNMENT[col]) ;
public boolean isChanged () {
return changed;
public void setChanged (boolean nChanged) {
changed = nChanged;
public void updateData(Vector nData){
data.removeAllElements();
bayMap = new HashMap();
subBayMap = new HashMap();
WeightNumber ewtbmxID ;
WeightNumber ewtsbID ;
for (int iloop = 0; iloop < nData.size(); iloop++){
BayRecord tempRecord = (BayRecord)nData.get(iloop);
data.add(tempRecord);
addToMaps(tempRecord);;
* Places record hashmaps for easy access
private void addToMaps(BayRecord nRecord) {
// has ewtbmx_id been set?
if (nRecord.get(BayRecord.EWTBMX_ID) == null){
     return;
// is there a bayMap?
if (bayMap == null) {
     bayMap = new HashMap(); }
WeightNumber ewtbmxID = (WeightNumber) nRecord.get(BayRecord.EWTBMX_ID);
Vector bayVector;
//Does the vector for this key exist?
if (bayMap.containsKey(ewtbmxID.toString() )) {
bayVector = (Vector) bayMap.get(ewtbmxID.toString());
else {
     bayVector = new Vector();
bayMap.put(ewtbmxID.toString(),bayVector );
bayVector.add(nRecord );
if (nRecord.get(BayRecord.EWTSB_ID) == null) return;
// is there a subBayMap?
if (subBayMap == null) {
     subBayMap = new HashMap(); }
WeightNumber ewtsbID = (WeightNumber) nRecord.get(BayRecord.EWTSB_ID);
Vector subBayVector;
if (subBayMap.containsKey(ewtsbID.toString() )) {
subBayVector = (Vector) subBayMap.get(ewtsbID.toString());
else {
subBayVector = new Vector();
subBayMap.put(ewtsbID.toString(),subBayVector );
subBayVector.add(nRecord );
* Array of column widths for all displayed columns in the JTable.
public static final int COLUMN_WIDTH[] = {30,200,200,40,40,40};
* Array of column alignments for all displayed columns in the JTable.
private static final int COLUMN_ALIGNMENT[] = {    JLabel.LEFT, JLabel.LEFT, JLabel.LEFT    ,  JLabel.RIGHT, JLabel.RIGHT, JLabel.RIGHT} ;
private Vector data;
private WeightEmployee user;
//This map will contain references to
//Rows in the JTable associated with unique bays
//If someone changes a bay on one line, it will change it
//for all lines associated with that bay.
private HashMap bayMap;
private boolean changed;
//This map will contain references to
//Rows in the JTable associated with unique subbays
//If someone changes a subbay on one line, it will change it
//for all lines associated with that bay.
private HashMap subBayMap;
public static final String SOURCE = "$Source: /apps/csna/javaSource/com/cessna/ewt/weight/RCS/WeightTableModel.java,v $";
public static final String REV = "$Revision: 1.1 $";}

Similar Messages

  • JTable row selection on certain cell values

    Hi Everybody,
    Here is the scenario. I have MyTableModel.java, MyTable.java and MyTablePanel.java etc classes. I want that user can only able to select the row in the table when there is certain data in the cell, otherwise user should not able to select the row.
    I know in advance that only one value form a pole of value can be in the cell, and I know all these pole data. Let say we have the three constant values in the pole i.e.. A, B, and C. I want that when there is "B" value in the cell, then user can select the row, in other two cases should not.
    What I did I looked the value form the TableModel for that cell, if the value is "B" then set the "flag" true otherwise false, and used this flag in the table.setRowSelectionEnabled(flag).
    The problem is that this method just read the flag at the start, even when the flags value changed, doesn't make any change.
    Is some body have any idea, how I can solve this problem.
    Thanks in advance

    It sounds like you are trying to catch selections from the user at the point where they click on the row, right? The problem is that the clicking event is what selects the row, so by the time you catch it in an event handler, the selection has been done.
    I guess the best way to do it is to have a MouseListener on the table which intercepts the click and checks the value held in the cell. If the cell displays a value the user shouldnt be able to select, it should set the selection in the table selection model back to empty.
    DS

  • How to get a selector to react to a changing cell value?

    I am trying to overcome the apparent problem of unidirectional selectors in  Xcelsius.  They only input data into a cell but cannot respond to changing data in the cell.
    My Xcelsius model is a collection of different screens that display groups of indicators and metrics, fairly standard. 
    I currently have two different navigation mechanisms:
    (1) An accordion menu that is always visible on the left-hand side and
    (2) an executive summary screen that shows an overview of all the metrics and allows the user to click and drill-down to metric-specific screens.
    Both of these navigation methods drive visibility by inputing to one main control cell in my Excel model. 
    Example: The user selects metric #2 from the executive summary menu, it inserts a "2" in the control cell; then the user selects metric #3 from the accordion menu, and it inserts "3" into the control cell.
    The problem is that it seems that all the selector components are <b>unidirectional</b>.  They can only pass data <i>to</i> the spreadsheet, but do not react if that data is changed by another component.  If you go back to my above example, if the user went back to the executive summary, they would see #2 selected and if they tried to click #2, they would not be able to because the list box component does not realize that my accordion menu has changed the selection to #3.
    Is there any way to fix this?  I want my UI component to change its displayed selection if another component changes the control cell.<!break>

    No problem, glad I could help!
    1. Although there are no plans to implement the feature for additional components at this time, it may be included in a future release.
    2. Xcelsius components always have a selection made. Either the default selection when the SWF is ran or the value selected by the user. You may be able to work around this using Dynamic Visibility. Or, depending on your application, you can include a blank in your selector range and have that as the default. If the blank is at the end of your selector range, you would not be able to use the Ignore End Blanks feature (which you probably need to use for the dynamic selected item) so it would be necessary to insert it at the beginning of the range.

  • How to insert data into a table only when data has changed its value (when compared to the previous inserted value)

    I wish to insert data into a table only when the value of the inserted data has changed. Thus, in a time series, if the value of the data at time, t-1, is 206 then if the data to be inserted at time t is 206, then it is skipped (not entered).
    If the value of the data at time t+1 is 206, it is skipped also; until the value changes, so if the value at t+1 was 205, then that would be inserted, and if at time t+2 the data is 206, it would be inserted too.
    What is the best way to do it without increasing overheads?

    This view works:
    SELECT
    i.IDNO,i.[Date],i.[Level]
    FROM
    mytable i
    INNER
    JOIN mytable
    d
    ON
    d.IDNO
    = i.IDNO-1
    WHERE
    i.[Level]
    <> d.[Level]
    on this mytable below.  A trigger could be quite useful here although I am cautious using them. However I wish to avoid the overhead by not having a temp table (which could be sizable).  mytable below
    should give 3 lines. The IDNO is an identity column.
    IDNO
    Item
    Date
    Level
    1
    X24
    12/23/13 10:41
    22996
    2
    X24
    12/23/13 10:41
    22996
    3
    X24
    12/23/13 9:21
    23256
    4
    X24
    12/23/13 9:21
    23256
    5
    X24
    12/23/13 9:22
    23256
    6
    X24
    12/23/13 9:22
    23256
    7
    X24
    12/23/13 9:22
    22916

  • Alternative to Backing-Up data before changing HD?

    Is there a way to back-up, without having to log in to user profile? Snow Leopard, 10.6.8. I can no longer log in to my Macbook Pro, my last back up was 6 weeks ago. Information: Mactintosh HD says maximum capacity full.

    A good way in general to manage the changeover is to put the new drive in an external enclosure. Then you can use the existing system to help set up the new drive and test boot from it before you start swapping drives.
    In this case, you could install the new drive first (which is a little riskier) and use the old "full" drive in an external enclosure as the backup from which to copy or restore the files.
    USB enclosures are fast enough for backups, but if you use it for real storage, the slowness will drive you nuts. FireWire is much faster.
    "Any drive can fail at any time." so while you are thinking about what a disaster this could have been, think about buying a Backup external drive as well. Time machine never forgets to make copies of your files, and does its work fairly unobtrusively.

  • How to verify that the user has changed table row data before db update

    Hi all,
    Iam using Oracle ADF with EJBs.
    I have a single selection table that displays rows of data returned from a function of my data control.
    The columns of my table are editable so that the user can change the data. The user selects a row, changes the data in one or more columns of the row and saves the data by means of a submit button. The code in the submit button, identifies the row of the corresponding iterator that the user clicked on and updates the data in the database (using the 'mergeEntity' function of the EntityManager)
    Before saving the data, I want to put some logic to check whether the user has actually changed some data to avoid unnecessary updates in the database . But for this I need a technique to detect that the user has indeed changed some data in the table row.
    One technique I have been using so far was to isolate the iterator row of the table and then query the corresponding row in the database table and compare their values.
    Except from dummy, this technique is not efficient if the table contains many rows.
    Moreover, in my case I have observed that on successive updates on the same row , the query on the database returns the new values (user changed values) and not the actual values contained in the database table. This means that when the user updates an iterator row the cached data affect also the results of the SELECT statement from the actual database table!!! Isn't this strange ?
    Can somebody propose me a neat method to detect when the user has changed the the data of an iterator row ?

    Hey Alan,
    The below solution seems overly complicated to me and can not be implemented without a custom screen and/or the use of JavaScript. Also, if your main concern is that a user may accidentally loose all their data because they closed the browser window or the session times out before they hit the save button then this solution does not help you.
    There are a couple of simpler approaches you can take here:
    # If the use of JavaScript is permissible you can hook into the windows 'onUnload' event, and pop-up a message box which gives the user the opportunity to cancel closing the window and save their case if they haven't already.
    # Implement an autosave feature by hooking into one of events provided by web determinations. A simple (but rather naive) way of doing this would be to hook into the OnRenderScreenEvent and call save on the interview session every time the event fires. This guarantees that all the data the user has submitted will aways automatically be saved, thereby removing the need to make sure the user manually saves their data before closing the browser.
    Automatically making Web Determinations close a browser window has to be done using JavaScript. However, doing so means that a) it won't work for people who turn off JavaScript, which is commonly done for accessibility reasons b) you'll likely run afoul of the browser's security mechanism (they generally won't let you close a window that you didn't open and some really don't like you doing that at all).
    Thanks,
    Kristy

  • Programatically change( edit?? ) JTable cell value

    If my user changes the value in cell 'A', I'd like to change the value in cell 'B' to the results of a calculation performed using the new value in A with the present ( prior to changing ) value in B.
    Example:
    Cell: suggested_sell_price
    Cell: cost_this_item
    A change in the cost_this_item cell would be reflected in the suggested_sell_price,(upon hitting enter the values are stored in the DB)
    Any suggestions would be greatly appreciated,

    Thanks for the suggestions. I'm posting a test program of what I have at the moment, it has some of the behavior I'm looking for, but I can't seem to get the new value of an aedited cell and set the table model with the new value.
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.table.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    public class TE extends JFrame
         String[] cols = {"VAL_1", "VAL_2", "VAL_3"};
         Object[][] filler = {
                                       {new Double(100.00), new Double(100.00), new Double(100.00)},
                                       {new Double(200.00), new Double(200.00), new Double(200.00)},
                                       {new Double(400.00), new Double(400.00), new Double(400.00)}
         JTable table;
         TE(String title)
                   super(title);
                   this.setDefaultCloseOperation(EXIT_ON_CLOSE);
                   MTM mtm = new MTM(3, cols.length);
                   mtm.setColumnIdentifiers(cols);
                   int nRows = filler.length;
                   for(int i = 0; i < nRows; ++i)
                             mtm.setValueAt(filler[0], 0, i);
                             mtm.setValueAt(filler[1][i], 1, i);
                             mtm.setValueAt(filler[2][i], 2, i);
                   table = new JTable(mtm);
                   table.getColumnModel().getColumn(1).setCellEditor(new SimpleCellEditor());
                   table.getColumnModel().getColumn(2).setCellEditor(new SimpleCellEditor());
                   //table.getColumnModel().getColumn(2).setCellEditor(new SimpleCellEditor());
                   JScrollPane jsp = new JScrollPane(table);
                   Container c = getContentPane();
                   c.add(jsp);
                   setSize(300,300);
                   setVisible(true);
         class MyMouseListener extends MouseAdapter
                   public void mouseClicked(MouseEvent e)
                        if(e.getClickCount() == 2)
                                  table.setValueAt("QQQQQQQ", 1,1);
    class SimpleCellEditor extends AbstractCellEditor implements TableCellEditor, ActionListener
         JTextField tf = new JTextField();
         TableModel tm = table.getModel();
         protected EventListenerList listenerList = new EventListenerList();
         protected ChangeEvent changeEvent = new ChangeEvent(this);
         public SimpleCellEditor()
                   super();                              
                   tf.addMouseListener(new MyMouseListener());
                   tf.addActionListener(this);
    public void addCellEditorListener(CellEditorListener listener) {
    listenerList.add(CellEditorListener.class, listener);
    public void removeCellEditorListener(CellEditorListener listener) {
    listenerList.remove(CellEditorListener.class, listener);
    protected void fireEditingStopped()
              CellEditorListener listener;
              Object[] listeners = listenerList.getListenerList();
              for (int i = 0; i < listeners.length; i++)
                   if (listeners[i] == CellEditorListener.class)
                             listener = (CellEditorListener) listeners[i + 1];
                             listener.editingStopped(changeEvent);
    protected void fireEditingCanceled()
         CellEditorListener listener;
              Object[] listeners = listenerList.getListenerList();
                   for (int i = 0; i < listeners.length; i++)
                   if (listeners[i] == CellEditorListener.class)
                        listener = (CellEditorListener) listeners[i + 1];
                        listener.editingCanceled(changeEvent);
    public void cancelCellEditing()
              fireEditingCanceled();
    public boolean stopCellEditing()
              fireEditingStopped();
              return true;
    public boolean isCellEditable(EventObject event)
              return true;
         public boolean shouldSelectCell(EventObject event)
         return true;
    public Object getCellEditorValue()
         return tf.getText();
    public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column)
         if(tf.hasFocus() == true)
                   tf.setBackground(Color.CYAN);
              return tf;
         public void actionPerformed(ActionEvent e)
              int row = table.getSelectedRow();
              int col = table.getSelectedColumn();
              double nVal = 0.00;
              Object currCostVal;
              Object currSellVal;
              Double costVal;
              Double sellVal;
              double newSellVal;
              double currentCost;
              if(table.getSelectedColumn() == 1)
                   currCostVal = table.getValueAt(row, col+1);
                   currSellVal = table.getValueAt(row, col);
                   costVal = new Double(currCostVal.toString());
                   currentCost = costVal.doubleValue();
                   sellVal = new Double(currSellVal.toString());
                   newSellVal = sellVal.doubleValue();
                   nVal = newSellVal*currentCost*100/100;
                   System.out.println("Recommended sell-price after change: " + nVal);
              }else if(table.getSelectedColumn() == 2 )
                        currCostVal = table.getValueAt(row, col);
                        currSellVal = table.getValueAt(row, col-1);
                        costVal = new Double(currCostVal.toString());
                        currentCost = costVal.doubleValue();
                        sellVal = new Double(currSellVal.toString());
                        newSellVal = sellVal.doubleValue();
                        nVal = newSellVal*currentCost*100/100;
                        System.out.println("Recommended sell-price after change: " + nVal);
                        System.out.println("Cost column selected " + nVal);
    }// end simple cell editor
    class MTM extends DefaultTableModel
              MTM(int rows, int cols)
                        super(rows, cols);
    public static void main(String args[])
              TE te = new TE("Test of table cell update");

  • JTable cell value doesn't change with user input

    I'm making a program that uses a custom table model (extends AbstractTableModel). The problem is when I type a value in one of the table cells, then press enter (or click outside the cell), the value goes back to what it was originally. So for example, a cell has "oldvalue", I type in "newvalue", press enter, and now the cell still reads "oldvalue". I figured the renderer would automatically update the cell by calling MyTableModel.setValueAt (...), but maybe I need a listener to do this? let me know. thanks

    alright, well basically I'm making a database manager
    and thought it would be easier to extend
    AbstractTableModel and then do all the queries inside
    the methods instead of listening for events. Second
    thing, I put a debug statement and setValueAt never
    gets called when you type in a new cell value. How
    does it update the cell then is my question?It's your TableModel bug but a much better advice would be that you should use
    DefaultTableModel instead of extending AbstractTableModel. The DefaultTableModel
    is usually more than enough for an ordinary JTable application.
    The simplest and standard way of handling DB data from JTable is updating
    vectors for DefaultTableModel data with your new DB data set. You don't need
    to worry about low-level event firing, cell editor control etc. if you use
    DefaultTableModel. See API documentation of DefaultTableModel closely.

  • Error trying to change the value property of a cell with decimals

    This is a script question.
    I’m using a system defaulting to Spanish, so the decimal delimiter is the comma.
    During a script I need to change the property value of a cell multiplying it by -1. As an example, I want to change 1,25 into -1,25.
    This is how try to do it:
    tell application "Numbers" to tell document 1 to tell sheet 1 to tell table 1
    set selection range to first cell
    set mi_cell to (value of first cell of selection range) * -1
    set value of first cell of selection range to mi_cell
    end tell
    The expected result is wrong provided that the original value of the cell has decimal value. Otherwise is correct.
    See examples of what happen after running this piece of the script:
    1,25 becomes -125,00 instead of -1,25
    6,00 becomes -6,00 (in this case is correct)
    Does anybody know how to solve this problem?
    Thanks in advance.
    Ratz

    This was described here in several scripts.
    Before setting the value of a cell to a number or a date, the value must be coerced to a string.
    It's the only way available to take care of localization features.
    Your script must be
    tell application "Numbers" to tell document 1 to tell sheet 1 to tell table 1
    set selection range to first cell
    set mi_cell to (value of first cell of selection range) * -1
    set value of first cell of selection range to mi_cell as text
    end tell
    or better
    tell application "Numbers" to tell document 1 to tell sheet 1 to tell table 1
    set mi_cell to (value of first cell) * -1
    set value of first cell to mi_cell as text
    end tell
    CAUTION : don't code
    tell application "Numbers" to tell document 1 to tell sheet 1 to tell table 1
    set mi_cell to -(value of first cell)
    set value of first cell to mi_cell as text
    end tell
    which is supposed to do the same but would return the opposite of *_the integer value_* of the cell.
    Yvan KOENIG (VALLAURIS, France) dimanche 13 février 2011 16:06:39

  • Refresh data in a jtable when data changes

    I have a jtable grdTable and a tableModel mytableModel which extend abstract table model
    I have a jcheckbox in the column 1 which i want to uncheck all
    I am doing the following.The data is changed ,I could see by doing susyem.out.println() but the data in the table does not refreshes.
    public void showTablechanges()
    TableModel tm = grdTable.getModel;
    for(int i=0 ;i<grdTable.getRowCount();i++)
    grdTable.setValueAt(Boolean.FALSE, i, 1);
    ( (MyTableModel)tm).fireTableDataChanged();
    grdTable.repaint();
    What am i missing or what wrong I am doing.How can i make the data refresh.
    I tried do a sys out after seting the value and it is showing as false but the checkbox is still checked.I have tried a lot of things but I am not able to refresh the jtable.
    Please please help.
    Thanks

    Thanks so much for the reply I read the links.I modified my code as
    public void showTablechanges() {
    SwingUtilities.invokeLater(new Runnable() {
    public void run() {
    TableModel tm = grdTable.getModel;
    for (int i = 0; i < grdTable.getRowCount(); i++) {
    grdTable.setValueAt(Boolean.FALSE, i, 1);
    ((MyTableModel) tm).fireTableDataChanged();
    grdTable.repaint();
    This makes no difference.What strange thing is happening out of 12 checkboxes ,11 are unchecked but the first one always remains checked.EVen without the
    invoke later 11 are unchecked and 1 remains checked
    This method is in a panel and this panel is invoked from another MAin panel which has a changelistener for this panel.
    i.e if the method above is in myPanel.java then in my main panel,I have
    myPanel.addChangeListener(this)
    Also if i remove the line
    ((MyTableModel) tm).fireTableDataChanged();
    All checkboxes remains checked.
    I am really confused and this looks very tough to me ,Can you find out what is wrong
    Thanks,

  • Touble getting cell values from jTable

    Hi everybody, I need some hepl to understand this problem.
    I have jtable and I�m trying to get the values from the cells (first in the jOption panel then to jLabel and to jTextFields).
    All cell values are shown perfectly in the JOptionPanel.
    But I can�t get any values to the jLabel from the first column(0) no matter what row I press from the firts column.
    It gives me this error
    Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: java.lang.Integer
         at taulukko3.FTaulukko3.jTable1_mouseClicked(FTaulukko3.java:163)Here is my code where I think the problem is:
    public void jTable1_mouseClicked(MouseEvent e) {
       JOptionPane.showMessageDialog(this,jTable1.getValueAt(jTable1.getSelectedRow(),jTable1.getSelectedColumn()));
          try{
          int valittusarake = jTable1.getSelectedColumn();
           String tulos= "";
           if (valittusarake == 0) {
             tulos = (String) jTable1.getValueAt(jTable1.getSelectedRow(),
                                                      jTable1.getSelectedColumn());
            jLabel1.setText(tulos);
           if (valittusarake == 1) {
             tulos = (String) jTable1.getValueAt(jTable1.getSelectedRow(),
                                                       jTable1.getSelectedColumn());
             jTextField1.setText(tulos);
           if (valittusarake == 2) {
             tulos = (String) jTable1.getValueAt(jTable1.getSelectedRow(),
                                                       jTable1.getSelectedColumn());
             jTextField2.setText(tulos);
    }

    Hi everybody
    I got it workin by making this change to my code:
          if (valittusarake == 0) {
             Object tulos1 = jTable1.getValueAt(jTable1.getSelectedRow(),jTable1.getSelectedColumn());
             jLabel1.setText(tulos1.toString());
          }

  • How can I change the value in a stepper cell

    In Numbers 2.3 I was able to change the value in a stepper cell by highlighting the value and using the arrow keys to increase or decrease the value. This was a very easy way to input data. Numbers 3.0 when I do this is moves to another cell
    Is there a way to get the use of the arrow keys to change the values in 3.0?
    Thanks

    I use number to keep a running daily tally of the productivity of the members of my group. As each member performs certain tasks, all I had to do was click the up arrow and add to it. IE Jim made 4 widgets yesterday and then made 4 today, I would just hit the up 4 times total 8.
    I guess the good news is when I upgraded to Numbers 3.0, It did not delete Numbers 2.3
    I will continue to use 2.3 until it no longer works, I guess
    Thanks for the replies

  • Making a jtable row noneditable based on a value in a certain cell.

    I have a jTable (based on a database table) and one of the columns is OWNER. Is there a way to make an entire row noneditable based on the value in the OWNER column of the currently selected row?
    Here is the listener code that I have on the jTable. I want to be able to make the entire row noneditable if the value (of the currently selected row) of the OWNER column is "SYSTEM". If it is anything other than "SYSTEM" then the user would be able to change the values on the row.
    I can't override the isCellEditable method, because I only want the rows with the value of "SYSTEM" in the OWNER column to be noneditable.
    jTable2.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    ListSelectionModel rowSM = jTable2.getSelectionModel();
    rowSM.addListSelectionListener(new ListSelectionListener() {
    public void valueChanged(ListSelectionEvent e) {
    if (e.getValueIsAdjusting()) return;
    ListSelectionModel lsm = (ListSelectionModel)e.getSource();
    if (lsm.isSelectionEmpty()) {
    //no rows are selected
    } else {
    int selectedRow = lsm.getMinSelectionIndex();
    if (jTable2.getValueAt(selectedRow, 1).equals("SYSTEM"))
    System.out.println("Selected Row: " + selectedRow);
    System.out.println("Owner Value: " + jTable2.getValueAt(selectedRow, 1));
    //Make all cells in this row non-updateable???
    //Need code to make the currently selected row noneditable
    disableRetailerAddToList();
    } else
    enableRetailerAddToList();
    Any direction for this problem would be greatly appreciated.

    I've resolved it with some help by using the following:
    NOT ([<plCall_Back_Required_ITAG>]=LookupValue("OCC_CUST_LOV_SR_3", "Yes") AND [<stCall_Back_Number_ITAG>] IS NULL)

  • How to change the cell value in Excel Sheet in WD Java?

    HI,
    I have an application which is used to upload and download excel sheet.I can upload the excel sheet through Upload UI element and also able to download the same file through Download UI.But before download I want to validate the excel sheet.If data is not proper in the excel then I have to put some comment (cell comment).I am able to read each cell value,but not ble to put any comment.Once I pt commen in the cell,the download file should display the commented in the excel sheet.
    Please let me know how to update hte excel sheet.
    Sandip

    hi Sandeep,
    I'm not sure about the HSSF apis, however, i inserted the Cell Comments using jexcel apis. There is a method setComment(java.lang.String s, double width, double height) in class WritableCellFeatures using which you can insert cell comments
    For more details refer [link|http://jexcelapi.sourceforge.net/resources/javadocs/current/docs/jxl/write/WritableCellFeatures.html]
    Abhinav

  • Change item value before commit

    Hello,
    I have a form in which I issue an execute_query from a mouse click to retrieve database values from a data block onto a form. The user is then able to change the values of these items on the form and commit them via a button on the form. What I want to do is make sure that some of the values, based on another item in the block, are negative and if not, change them to a negative value. before the changes are commited. I can't seem to find the right trigger to accomplish this-- has anyone have an idea on how to do this?
    Thanks in advance.
    Jeff

    Hi,
    How about putting your code in :
    1. Pre-Update or
    2. When-Database-Record
    [Block Level trigger]
    The trigger text could be something like :
    If (:block.col is > 0 ) Then
    :block.col := :block.col * -1;
    End If;
    -- Shailender Mehta --

Maybe you are looking for

  • Why is it so difficult to print a photo?

    I have wasted about 20 4x6 pieces of photo paper trying to print a picture! I have a digital pic that is way larger than 4x6. I want to scale it down and print borderless 4x6, but there must be some magic incantation that I can't figure out! I have t

  • MacBook go to sleep mode when I use it

    Hello world, When I'm not connected to the sector but I am well on the battery, my screen turns off while I am trying to use it. It is regular and unwelcome. My configuration battery and energy saving is well configured. I tried to format the hard dr

  • How do I retrieve purchased tv shows without buying them again?

    I deleted from my laptope my tv shows by accident and when i go on Itunes store it says I have to buy them again. How can I get them back without paying?

  • Document Control Program

    Hi everyone, I would like to know, where do you have the document control program? I do this question because I use Primavera to plan and control the projects but I can´t use the documents (drawings) in Primavera Project Manager. I know that Primaver

  • Jersey implemtation with Business Components

    Hi, I would like to implement a REST interface based on jersey for my adf application. I my resource classes I want to return the data from my view objects. What would be the 'best practice' for creating the application module inside the jersey resou