Events missing in JTable

In my application one of the table columns is boolean.Table is displaying checkboxex for that column.That is good.when i click check box i want to take table's other column value which is integer ,sum it to other vale and display that value in jlabel. This functionality is working great as long as i click checkboxe slowly.
But problem is when i click checkboxex very fast events getting missed and label value is not updating.I tried to synchronize code but it doesn't work.
help is greatly appreciated
thanks in advance

thanks for your reply.
i tried to create runnable in setvalueat method of my table model.iam new to threads.i might be doing something wrong.
here iam attaching same class that iam experimenting.
any help really appreciated.
i have deadline by friday
import javax.swing.JTable;
import javax.swing.table.AbstractTableModel;
import javax.swing.JScrollPane;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import javax.swing.JOptionPane;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
import java.awt.geom.*;
import java.awt.Dimension;
import java.text.*;
import javax.swing.event.TableModelListener;
import javax.swing.event.TableModelEvent;
import javax.swing.table.*;
public class TableSorterDemo extends JFrame {
private boolean DEBUG = true;
JTable table;
JLabel label=new JLabel();
public TableSorterDemo() {
super("TableSorterDemo");
MyTableModel myModel = new MyTableModel();
//TableSorter sorter = new TableSorter(myModel); //ADDED THIS
//JTable table = new JTable(myModel); //OLD
//JTable table = new JTable(sorter); //NEW
//table = new JTable(sorter);
table = new JTable();
table.setModel(myModel);
myModel.addTableModelListener(myModel);
//sorter.addMouseListenerToHeaderInTable(table); //ADDED THIS
table.setPreferredScrollableViewportSize(new Dimension(500, 70));
table.setSelectionMode(0);
//Create the scroll pane and add the table to it.
JScrollPane scrollPane = new JScrollPane(table);
//JLabel label=new JLabel();
label.setText("0");
//Add the scroll pane to this window.
getContentPane().add(scrollPane, BorderLayout.CENTER);
getContentPane().add(label, BorderLayout.SOUTH);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
public void run(){
class MyTableModel extends AbstractTableModel implements TableModelListener {
final String[] columnNames = {"First Name",
"Last Name",
"Sport",
"# of Years",
"Vegetarian"};
final Object[][] data = {
{"Mary", "Campione",
"Snowboarding", "10", new Boolean(false)},
{"Alison", "Huml",
"Rowing", "20", new Boolean(false)},
{"Kathy", "Walrath",
"Chasing toddlers", "50", new Boolean(false)},
{"Mark", "Andrews",
"Speed reading", "60", new Boolean(false)},
{"Angela", "Lih",
"Teaching high school", "10", new Boolean(false)}
public int getColumnCount() {
return columnNames.length;
public int getRowCount() {
return data.length;
public String getColumnName(int col) {
return columnNames[col];
public Object getValueAt(int row, int col) {
return data[row][col];
* JTable uses this method to determine the default renderer/
* editor for each cell. If we didn't implement this method,
* then the last column would contain text ("true"/"false"),
* rather than a check box.
public Class getColumnClass(int c) {
return getValueAt(0, c).getClass();
* Don't need to implement this method unless your table's
* editable.
public boolean isCellEditable(int row, int col) {
//Note that the data/cell address is constant,
//no matter where the cell appears onscreen.
if (col < 2) {
return false;
} else {
return true;
public void tableChanged(TableModelEvent e){
//final TableModelEvent e1=e;
//Runnable setSearchStatusLabel = new Runnable() {
//public void run() {
//AddSum(e.getFirstRow(),e.getColumn(),(table.getValueAt(e.getFirstRow(),e.getColumn())).toString());
//SwingUtilities.invokeLater(setSearchStatusLabel);
//System.out.println(e.getFirstRow());
//System.out.println(e.getColumn());
//System.out.println(table.getValueAt(e.getFirstRow(),e.getColumn()));
* Don't need to implement this method unless your table's
* data can change.
public synchronized void setValueAt(Object value, int row, int col) {
/*if (DEBUG) {
System.out.println("Setting value at " + row + "," + col
+ " to " + value
+ " (an instance of "
+ value.getClass() + ")");
final int row1=row;
final int col=col1;
final String value1=value;
Runnable setSearchStatusLabel = new Runnable() {
public void run() {
AddSum(row1,col1,value1);
/*int labelval=StringToInt(label.getText());
int newlabelval;
int tablesumval;
if(value1.equalsIgnoreCase("true")){
tablesumval=StringToInt((String)(table.getValueAt(row1,col1-1)));
//tablesumval=Integer.parseInt((String)(getScrollPaneTableLocHitRecords().getValueAt(selectedRow,13)));
newlabelval=labelval+tablesumval;
//String test=IntToCurrencyString(newlabelval);
label.setText(IntToString(newlabelval));
else{
tablesumval=StringToInt((String)(table.getValueAt(row1,col1-1)));
if(labelval==0){
newlabelval=tablesumval;
else{
newlabelval=labelval-tablesumval;
label.setText(IntToString(newlabelval));
//SwingUtilities.invokeLater(setSearchStatusLabel);
if (data[0][col] instanceof Integer
&& !(value instanceof Integer)) {
//With JFC/Swing 1.1 and JDK 1.2, we need to create
//an Integer from the value; otherwise, the column
//switches to contain Strings. Starting with v 1.3,
//the table automatically converts value to an Integer,
//so you only need the code in the 'else' part of this
//'if' block.
try {
data[row][col] = new Integer(value.toString());
fireTableCellUpdated(row, col);
} catch (NumberFormatException e) {
JOptionPane.showMessageDialog(TableSorterDemo.this,
"The \"" + getColumnName(col)
+ "\" column accepts only integer values.");
} else {
data[row][col] = value;
fireTableCellUpdated(row, col);
if (DEBUG) {
System.out.println("New value of data:");
printDebugData();
private void printDebugData() {
int numRows = getRowCount();
int numCols = getColumnCount();
for (int i=0; i < numRows; i++) {
System.out.print(" row " + i + ":");
for (int j=0; j < numCols; j++) {
System.out.print(" " + data[i][j]);
System.out.println();
System.out.println("--------------------------");
public static void main(String[] args) {
TableSorterDemo frame = new TableSorterDemo();
frame.pack();
frame.setBounds(100,100,500,150);
frame.setVisible(true);
private String IntToString(int val) {
     NumberFormat formatter = NumberFormat.getInstance();
     formatter.setMaximumFractionDigits(0);
     String result=formatter.format(val);
     return result;
private int StringToInt(String val) {
     NumberFormat formatter = NumberFormat.getInstance();
     formatter.setMaximumFractionDigits(0);
     //formatter.setGroupingUsed(false);
     Number numberValue=null;
     try{
          numberValue = formatter.parse(val);
     catch(ParseException e){};
     //return 3;
     return numberValue.intValue();
//private synchronized void AddSum( int row1,int col1,String value1){
private synchronized void AddSum(int row1,int col1,String value1){
int labelval=StringToInt(label.getText());
int newlabelval;
int tablesumval;
if(value1.equalsIgnoreCase("true")){
tablesumval=StringToInt((String)(table.getValueAt(row1,col1-1)));
//tablesumval=Integer.parseInt((String)(getScrollPaneTableLocHitRecords().getValueAt(selectedRow,13)));
newlabelval=labelval+tablesumval;
//String test=IntToCurrencyString(newlabelval);
label.setText(IntToString(newlabelval));
else{
tablesumval=StringToInt((String)(table.getValueAt(row1,col1-1)));
if(labelval==0){
newlabelval=tablesumval;
else{
newlabelval=labelval-tablesumval;
label.setText(IntToString(newlabelval));

Similar Messages

  • Events missing after Sync

    Hi all,
    Payed the £12 for the upgrade (Grrrr) and synced with Itunes as I always did. This time however I have loads of my iPhoto events missing, it should sync about 50 events but now only syncs 5 or so. The photo count in the 'Photo Library' section shows the full count of images btw. I've rebuilt the iPhoto library, rebooted, etc and still wont see or let me sync more than a few of the events I have!
    Anybody else having this problem?
    Thanks,
    Anthony

    i had the exact same thing, you have to go into the photo syncing options and select to sync events.

  • Events missing and photos in new iPhoto update

    Events missing and photos in new iPhoto update

    Moments are the new Events.  All of your events in iPhoto are not Moments in Photo and were also brought over as an album. Open the sidebar with the Option+Command+S key combination and look in the folder titled "iPhoto Events".  There's a way to simulate events in Photos.
    When the library was first migrated there was a folder created titled iPhoto Events and all migrated iPhoto Events are represented by an album in the folder.
    When new photos are imported into the Photos library go to the Last Import smart album, select all the photos and use the File ➙ New Album menu option or use the key combination Command+N.  Name it as desired.  It will appear just above the iPhoto Events folder where you can drag it into the folder
    When you click on the iPhoto Events folder you'll get a simulated iPhoto Events window.

  • ICal misbehaving with iPhone, month view, and events missing

    iCal is giving me problems.
    April will not display at all in month view, and 1 week's worth of events are completely missing, no matter which view I am in.
    My iPhone has all of my events and is up-to-date, but even though I've synced it several times, it doesn't work. I've deleted the com.apple.iCal.plist file as well as the cache, with no luck.
    I'm in Leopard 10.5.8, using iCal 3.0.8
    Thanks in advance for all of your help!

    Can I publish the calendar between two macs that are on a LAN?
    Publishing requires a .Mac account, or WebDAV-enabled server as I mentioned in my previous post.
    To simply share a calendar from on computer to another you can use iCals export and import features.
    Just export a calendar from one computer and import it on the other. It's as easy as sharing a file.
    Matt

  • How to catch the mouse event from the JTable cell of  the DefaultCellEditor

    Hi, my problem is:
    I have a JTable with the cells of DefaultCellEditor(JComboBox) and added the mouse listener to JTable. I can catch the mouse event from any editor cell when this cell didn't be focused. However, when I click the editor to select one JComboBox element, all the mouse events were intercepted by the editor.
    So, how can I catch the mouse event in this case? In other word, even if I do the operation over the editor, I also need to catch the cursor position.
    Any idea will be highly appreciated!
    Thanks in advance!

    Hi, bbritta,
    Thanks very much for your help. Really, your code could run well, but my case is to catch the JComboBox event. So, when I change the JTextField as JComboBox, it still fail to catch the event. The following is my code. Could you give me any other suggestion?
    Also, any one has a good idea for my problem? I look forward to the right solution to this problem.
    Thanks.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Test3
    extends JFrame {
    // JTextField jtf = new JTextField();
    Object[] as = {"aa","bb","cc","dd"};
    JComboBox box = new JComboBox(as);
    public Test3() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Container content = getContentPane();
    String[] head = {
    "One", "Two", "Three"};
    String[][] data = {
    "R1-C1", "R1-C2", "R1-C3"}
    "R2-C1", "R2-C2", "R2-C3"}
    JTable jt = new JTable(data, head);
    box.addMouseListener(new MouseAdapter() {
    // jtf.addMouseListener(new MouseAdapter() {
    public void mouseClicked(MouseEvent e)
    System.out.println("-------------------JComboBox mouseclick....");
    jt.addMouseListener(new MouseAdapter() {
    public void mouseClicked(MouseEvent e)
    System.out.println("-------------------JTable mouseclick....");
    // jt.setDefaultEditor(Object.class, new DefaultCellEditor(jtf));
    jt.setDefaultEditor(Object.class, new DefaultCellEditor(box));
    content.add(new JScrollPane(jt), BorderLayout.CENTER);
    setSize(300, 300);
    public static void main(String[] args) {
    new Test3().setVisible(true);
    }

  • IPhoto '08 stuck in July, recent events missing

    iPhoto 7.1.4 is behaving oddly. The last 12 Months folder is stuck on 08/07/2008 and all the imports since then are missing. The original images are there in the originals folder. I've tried rebuilding the library and using iPhoto Library Manager but still have the same problem with the new library.
    I've got over 4000 photos taking up 25G of disk space. Is this the problem?
    I have TimeCapsule - could this be to blame some how?

    Welcome to the Apple Discussions. Try the three fixes below in order as needed:
    1 - launch iPhoto with the Command+Option keys depressed and follow the instructions to rebuild the library. Select all options.
    2 - rebuild the library using iPhoto Library Manager as follows:
    Using iPhoto Library Manager to Rebuild Your iPhoto Library
    1 -Download iPhoto Library Manager and launch.
    2 -Click on the Add Library button, navigate to your User/Pictures folder and select your iPhoto Library folder.
    3 - Now that the library is listed in the left hand pane of iPLM, click on your library and go to the File->Rebuild Library menu option
    4 - In the next window name the new library and select the location you want it to be placed.
    5 - Click on the Create button.
    Note: It may take some time to create the new library if you have a lot of photos.
    3 - start over with a new library and import the Originals folder from your original library as follows:
    Creating a new library while preserving the Events from the original library.
    Move the existing library folder to the desktop.
    Open the library package like this.
    Launch iPhoto and, when asked, select the option to create a new library.
    Drag the Originals folder from the iPhoto Library on the desktop into the open Photo window
    This will create a new library with the same Events as the original library if you have the Finder checkbox unchecked in the Events preference pane.
    TIP: For insurance against the iPhoto database corruption that many users have experienced I recommend making a backup copy of the Library6.iPhoto (iPhoto.Library for iPhoto 5 and earlier) database file and keep it current. If problems crop up where iPhoto suddenly can't see any photos or thinks there are no photos in the library, replacing the working Library6.iPhoto file with the backup will often get the library back. By keeping it current I mean backup after each import and/or any serious editing or work on books, slideshows, calendars, cards, etc. That insures that if a problem pops up and you do need to replace the database file, you'll retain all those efforts. It doesn't take long to make the backup and it's good insurance.
    I've created an Automator workflow application (requires Tiger or later), iPhoto dB File Backup, that will copy the selected Library6.iPhoto file from your iPhoto Library folder to the Pictures folder, replacing any previous version of it. It's compatible with iPhoto 6 and 7 libraries and Tiger and Leopard. iPhoto does not have to be closed to run the application, just idle. You can download it at Toad's Cellar. Be sure to read the Read Me pdf file.
    Note: There now an Automator backup application for iPhoto 5 that will work with Tiger or Leopard.

  • JChecjBox and JTextField Event Handling in JTable

    Hi,
    I am creating a dynamic Jtable from data in Database. My table has x num of rows and 5 cols. I have 2 editable columns in Table. one is of type checkbox and other is textfield. I have also created a CustomTableModel which extends DefaultTableModel. My Question is How to trap an even on JCheckBox and JTextField when User changes the data in the table. I want trap the event, read the new data and save it to the database.
    Please help me with this problem.
    I am fairly new at JTable..Please help me. Do i need to create customeCellEditor??
    Thank you.

    Thank you for your help. From TableChanged event I can find out that table has been updated. But how do i know which rows were updated? I mean How do i know which checkbox was checked/unchecked, or JTextfield text was changed? I need to read them one by one and compare with previous data. TO do that Do i need customCellEditor? Editable Checkbox is in first col of table and Editable Jtextfield is in 4th col. Number of rows vary depending on my resultset from DB.
    Please help me.
    Thank you in Advance.

  • HT203477 Event missing in FCPX 10.1

    I have an event that's not showing up in FCPX, but it is there in the Finder, along with a CurrentVersion.fcpevent file
    The media from this event is not showing as 'missing' (red) in the project, but simply as blank (black) clips, so re-connecting does not work.
    How do i get these files back into the project?
    I've tried removing the CurrentVersion.fcpevent and re-starting , but no change...

    Everything except that event! In the Libraries window under that particular volume there should be an event called 'Creative Futures' but it's not there, neither is it's footage, though it is all quite clearly there in the Finder when I open that volume's Libraries and Events in the Finder

  • 10046 trace event - Missing privileges

    Hi,
    Version 11201
    Please advice what privileges are missing :
    SQL> ALTER SESSION SET events '10046 trace name context forever, level 12';
    ERROR:
    ORA-01031: insufficient privileges
    Thanks

    AllYourDataBase wrote:
    I would guess the "alter session" privilege.I'd also guess that, but i have the documentation to prove it as well :)
    http://download.oracle.com/docs/cd/B19306_01/network.102/b14266/appendixa.htm#CHDIBAJE
    Note that the ALTER SESSION privilege is required for setting events. Very few database users should require the alter session privilege.
    SQL> ALTER SESSION SET EVENTS ........
    The alter session privilege is not required for other alter session commands.
    SQL> ALTER SESSION SET NLS_TERRITORY = FRANCE;
    "

  • Listening for change events on a JTable

    Hi
    me = Java newbie!
    Well I've been building an app to read EXIF data from JPEG files using the imageio API and Swing. Learning both along the way.
    Stumbling block is that I am outputting the EXIF data into a JTable, inside a JScrollPane. These 2 components then become associated with a JInternalFrame container of the class MyInternalFrame.
    Works!
    Next job is to enable user to select a row in the table which then displays the image file.
    I know I can use ListSelectionEvent to detect a row selection and that 2 events are fired.
    I put some code into MyInternalFrame class to register a ListSelectionEvent, but I can't see how to reference MyInternalFrame from within this code....see below:
    package EXIFReader;
    import java.io.File;
    import java.io.FilenameFilter;
    import javax.swing.JInternalFrame;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.ListSelectionModel;
    import javax.swing.event.ListSelectionEvent;
    import javax.swing.event.ListSelectionListener;
    //This class constructs a table and displays it in a JInternalFrame
    public class MyInternalFrame extends JInternalFrame {
    static int openFrameCount = 0;
    static final int xOffset = 30, yOffset = 30;
    File file;
    File[] directoryMembers = null;
    public MyInternalFrame(File aFile) { //aFile rererences a directory containing jpeg files//
    super(null,
    true, //resizable
    true, //closable
    true, //maximizable
    true);//iconifiable
    file = aFile;
    //Set the window's location.
    this.setLocation(xOffset*openFrameCount, yOffset*openFrameCount);
    FilenameFilter filter = new FilenameFilter() {
    public boolean accept(File dir, String name) {
    return name.endsWith(".jpg");}};//Filter out any files in the directory that ain't jpegs
    directoryMembers = file.listFiles(filter);
    int i = 0;
    String[][] tableData= new String [directoryMembers.length][5];
    String[]headers = new String[]{"File Name","Date Taken",
    "F-Number","Exposure",
    "Flash Settings"};
    for (File dirfile: directoryMembers)
    try {
    if(dirfile!=null){
    tableData[i] = new ExifReader(dirfile).getEXIFData();//populate the table with jpeg file names
    i++;}}
    catch (Exception ex) {
    System.out.print("Error" + ex);
    if (tableData[0] != null){
    final JTable myTable = new JTable(tableData,headers);
    this.setSize(900,(50+(directoryMembers.length)*19));
    myTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    this.getContentPane().add(new JScrollPane(myTable),"Center");//add the JTable and JScrollPanel to this MyInternal Frame and display it! - cool it works!
    ListSelectionModel myLSM = myTable.getSelectionModel();
    myLSM.addListSelectionListener(new ListSelectionListener() {
    public void valueChanged(ListSelectionEvent le) {
    int[] rows = myTable.getSelectedRows();//want to respond to selections and then display the image as a JInternalFrame but got confused about references from within this listener - need help!
    Any gentle nudges?!
    P
    I can respond to these events using a JFrame, but how can I display the image in a JInternalFrame?

    Use code tags to post codes -- [code]CODE[/code] will display asCODEOr click the CODE button and paste your code between the {code} tags that appear.
    To get better help sooner, post a [_SSCCE_|http://mindprod.com/jgloss/sscce.html] that clearly demonstrates your problem.
    db

  • Events on empty JTable

    Thought I'd post a solution I found on comp.lang.java.gui from Christian Kaufhold.
    I have a scrollable JTable on which I establish a popup listener. This works fine as long as the event is received in the table rows. If the table contains fewer rows than occupy the view port and the user clicks below then the event is not received. This becomes crucial when the table model has no rows at all, when the event can never be received.
    I used this code:
    JTable table = new JTable(data)
         public boolean getScrollableTracksViewportHei�ght()
              Component parent = getParent();
              if (parent instanceof JViewport)
                   return parent.getHeight() > getPreferredSize().height;
              return false;
    }; Thus the table is always at least as high as the viewport.
    It has the effect that the entire viewport has the table background colour, but that's OK with me.

    Use code tags to post codes -- [code]CODE[/code] will display asCODEOr click the CODE button and paste your code between the {code} tags that appear.
    To get better help sooner, post a [_SSCCE_|http://mindprod.com/jgloss/sscce.html] that clearly demonstrates your problem.
    db

  • Some iPhone Calendar Events missing

    Have MobileMe (formerly Mac.com) for several years. Since last fall (2009) have tried to trust the 'Cloud' syncing Contacts and Calendars over the air. Worked for the most part. Lately have seen missing items or events on Calendar.
    Notice today that several calendar events are missing on the iPhone 3G (3.1.3). However, on MobileMe (using Firefox on a PC), the Calendar appears to be accurate as well as iCal on the iMac. Turned off the calendars in the Settings and then turned them back on, but to no avail. This is weird, because Contacts do not appear to be affected. Anyone else having issues. Thanks, Todd

    Ah, I figured it out.
    Under Settings/Mail, Contacts, Calendars/Calendars - there is a 'Sync' action that allows for 'Events' to be sync'd '2 Weeks Back', '1 Month Back', '3 Months Back', '6 Months Back' or ' All Events'. Originally, I had '1 Month Back' checked and thus older events did not show on the iPhone.
    I checked the 'Events 6 Months Back' and it brought in older events from iCal and MobileMe Calendar.

  • Selective Calendar Events Missing

    After recent system update noticed that some of my calendar events are missing. Checked Google Calendar and all my expected events are still there. Tried ticking and unticking Google Calendar and refreshing the Z2 calendar but missing events are still not showing.

    Do you have Google sync turned on?
    For a successful technology, reality must take precedence over public relations, for Nature cannot be fooled.   Richard P. Feynman

  • Old Calendar Events missing on iPhone & iPad?

    I recently realised old events from iCloud calendar are not appearing on my iPhone and iPad but are showing on my MacBook Pro. I'm missing events from before December 2013 and beyond.
    How can I recover them on my iPhone and iPad?

    Go to Settings>Mail,Contacts,Calendars>Sync (in the Calendars section) and set it to a longer time period.

  • Past calendar events missing

    since i have upgraded to iOS7, all my past calendat events have gone missing. Is there anyway to retrieve them.

    in settings/mail, calendars etc scroll down to the calendars section and set Sync to ALL events

Maybe you are looking for

  • AP - Controller connectivity issue

    Hi, I am trying to connect a bunch of APs (1131) to a 4404 controller. The problem I have is that the APs, everytime I connect them to the local- to the controller- network they keep on rebooting. I have hardcoded the IP address of the APs, as well a

  • Compare two columns and match ALL recurring values, not just the first instance

    Hi everybody... I was looking for a way to compare values in two columns, identifying every duplicate value instance on a third column. Searching around the forums, I found a solution, albeit a partial one; I am using this formula: =IFERROR("Duplicat

  • The rows of a query become columns

    Hi , everybody I have an aggregated query . The format of the result is : COL1 COL2 COL3 ==== ==== ==== VAL1 1800 CVAL1 VAL1 780 CVAL2 VAL1 800 CVAL3 VAL2 3450 CVAL2 VAL2 890 CVAL3 e.t.c. I want ,the quicker way, the format of the result to be as fol

  • KM Local Editing Issue

    Hi All, I have a strange issue with KM local editing feature. Whenever I try to edit an PDF file, it shows an error "The download of the document failed". Based on the sap notes available and previous KM post, I did check the internet explorer settin

  • Favicons on safari 7.1 are gone after update.

    My imac is a 2,9 Ghz Intel core I5 with a 8GO memory 1600 MHz DDR3 running on OSX Mavericks 10.9.5 I installed the safari 7.1 version, since then the favicons are disappearing one after the other, very frustrating! anybody with a solution?