Way to listen for change in JTable cell?

I am having troubles trying to catch a key event while the user is entering text inside a given JTable cell (x/y location). The JTable only seems to manage String objects in it's cells so I can't place a JTextField in there with a KeyListener on it.
Currently, I can only get control of the application once the user has left the cell they are editing.
Does anyone have an example of a JTable 'cell KeyListener' scenario? At this point I want to see if I can print 'hello world' each time I type a character within a cell. Then I'll go from there....

If you want to know when the contents of a cell have been updated you should use a TableModelListener.
If you want to know when a character is added/removed from the cell editor then you need to first understand how this works with a simple text field.
Typically you would use a DocumentListener to receive notifies of a change to the text field. However, within the DocumentEvent you wouldn't be able to change the text field as this notification comes after the text field has already been updated.
If you need to ability to intercept changes to the text field before they happen, then you would need to use a DocumentFilter. An example of using a DocumentFilter is given in the Swing tutorial on [url http://java.sun.com/docs/books/tutorial/uiswing/components/generaltext.html#filter]Text Component Features.
Once you get your regular text field working the way you want, the next step to create a DefaultCellEditor using this JTextField and use this editor in your JTable. The above tutorial also has a section on using editors in a table.

Similar Messages

  • Any way to listen for changes in Spark TextArea?

    Hello,
    What is the best way to listen for changes in a Spark TextArea? My scenario is simple: I need to know when some text is added or deleted (with from/to index).
    Regards,
    Dinko

    s:TextArea does have a chang event - http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/spark/components/TextAr ea.html.

  • How do I listen for change in the global position of a Node

    Hi there,
    I want to create a Wire/Connection node between two scene nodes. I want this Wire node to be updated when one of the nodes is moving. In the common scenario I would listen for change events in the target nodes position and update the Wire :
    targetNode1.translateXProperty().addListener(new ChangeListener<Number>() {
    public void changed(ObservableValue value, Number oldValue, Number newValue) {             
    wire.setStartX(targetNode1.getTranslateX());
    wire.setStartX(targetNode1.getTranslateY());
    wire.setEndX(targetNode2.getTranslateX());
    wire.setEndY(targetNode2.getTranslateY());
    The problem is that the target nodes are children of another container nodes(that are actually moving). So listening for change events in the translate properties of the target nodes does not work(their parent nodes are actually moving)
    Is there way to listent for change in the global position of the target nodes relative to the Scene?

    It sounds very similar to a problem I posted about earlier...
    How to implement a UI similar to a UML Diagram with connections?
    I ended up making my own special bounds property, that updates when the parent's special bounds property changes.
    I also had to listen to the parentProperty change event to add/remove my listener on the parent node.
    All in all, a pain in the butt. There should be an easier way.
    The shortcoming of the solution is that all the nodes in the hierarchy must have my special bounds property implemented (ie. they're all classes under my codebase such that I can implement it), which for the moment is true... I'd like a cleaner solution however.

  • How do I listen for changes in a container's components?

    I have a JScrollPane that contains a JTextPane. I want any Container that can possibly contain my JScrollPane to be able to listen for changes in the JTextPane's Document.
    For example, at the moment I'm using a JTabbedPane to hold a number of my JScrollPanes and I want to alter the tab title when any associated JScrollPane-JTextPane-Document is updated.
    Any suggestions on how best to handle this?

    I would use a controller object that manages all your gui components (tabs, scrolls, documents, text panes). Your controller object can register as a listener to the appropriate component, and when it changes, update the title of a tab (or do whatever else) as appropriate.
    Never put business logic like this stuff inside the actual gui components. Create, layout, etc. all the gui components (and related components like Document) from another controller like object instead. It makes handling the various listener stuff like this much easier. Read up on MVC (model view controller) stuff for more info.
    As for the actual mechanics, you could get the document that is used in the JTextPane and register as a DocumentListener. As a document listener, you get notified of all changes that are made to that document.

  • Is there any way to register for changes in a NetworkInterface?

    Greetings. I'm interested to know if there's a way to register for changes to a NetworkInterface. Changes could include ifup/ifdown, a change in the displayable name, adding/removing InterfaceAddress or InetAddress, or even a change in the hardware address. It doesn't look like it but I thought I'd check.
    Thanks. Jerry.

    The latest version of software for your iPod is shown in the iPod's Summary screen in iTunes.  If an update is available, notification will be there.  If it says "Your iPod software is up to date," you have the latest software.

  • Listening for Changes to JTextArea

    I am writing a program that listens for changes to the contents of a JTextArea to obtain input for its execution. But I have implemented DocumentListener, PropertyChangeListener to listen for changes to the JTextArea for deriving input without success. Please could anyone advice on what to do.
    My code is below.
       myListener implements DocumentListener{
       JTextArea txt = new JTextArea();
       txt.getDocument().addDocumentListener(this);
       public void changedUpdate(DocumentEvent e){}
       public void removeUpdate(DocumentEvent e){} 
       public void insertUpdate(DocumentEvent e){
        try{
         //my code for obtaining input from txt is here
         int start = e.getOffset();
         Document doc = e.getDocument();
        }catch(BadLocationException ble){
    }

    Here's a link to the Swing tutorial on "How to Write a Document Listener":
    http://java.sun.com/docs/books/tutorial/uiswing/events/documentlistener.html

  • Is there any way to listen for OS-commands like LINUX/UNIX "kill myApp"?

    Hello, world! ;)
    I would like to get help on the following problem:
    Situation:*
    Implementing my first server-daemon I was wondering if there is any way to listen for OS commands/events affecting the application.
    One particular handling I intend to implement is after an OS termination command (like *"kill myDaemon.jar"* on LINUX/UNIX) to shut down the daemon.
    This would be really helpful, because in this way I would not just shut down the daemon brutally but being able to handle an event like this to shutdown the Thread pool, send all connected peers that the server/daemon will be down for a while, close all connections ...
    Need help:*
    Am I completely forgetting something which solves this problem really quick? :D
    Is there any Listener Interface which I can use to achieve this?
    Is maybe the JVM/JRE handling this and running garbage collectors?
    Is there any site/tutorial/... focusing on problems like this?
    Thanks in advance for any help on this subject!
    JAVAnetic

    Thanks, this was indeed very helpful.
    I implemented a shutdownHook and it works like I hoped it would:
        Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
          @Override public void run() {
            // shut down commands
        }));After typing *"kill process_ID"* in a terminal the shutdownHook is invoked (like mentioned before) and the shut down commands are executed.
    Works fine.
    Am happy. :D

  • Document Listener for JTextArea in JTable

    I am trying to implement a DocumentListener for JTextArea in JTable, but its not happening.
    Can someone tell me what's wrong. SSCCE below.
    import java.awt.Component;
    import java.awt.Dimension;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import javax.swing.Icon;
    import javax.swing.JFrame;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.JTextArea;
    import javax.swing.UIManager;
    import javax.swing.event.DocumentEvent;
    import javax.swing.event.DocumentListener;
    import javax.swing.table.DefaultTableModel;
    import javax.swing.table.TableCellRenderer;
    import javax.swing.table.TableColumn;
    import javax.swing.text.Document;
    public class MyTable_TextArea extends JTable {
         private DefaultTableModel defaultTableModel;
         private Object[][] dataArray;
         private Object[] columnNameArray;
         public final int TEXT_COLUMN = 0;     
         // column headers
         public static final String TEXT_COLUMN_HEADER = "Text";
         // text area
         TextFieldRenderer3 textFieldRenderer3;
          * constructor
          * @param variableNameArray
          * @param columnNameArray
         public MyTable_TextArea(Object[][] variableNameArray, Object[] columnNameArray) {
              this.dataArray = variableNameArray;
              this.columnNameArray = columnNameArray;
              defaultTableModel = new DefaultTableModel(variableNameArray, columnNameArray);
              this.setModel(defaultTableModel)     ;
              // text field
            textFieldRenderer3 = new TextFieldRenderer3();
              MyDocumentListener myListener = new MyDocumentListener();
              textFieldRenderer3.getDocument().addDocumentListener(myListener);
            TableColumn modelColumn = this.getColumnModel().getColumn(TEXT_COLUMN);
              modelColumn.setCellRenderer(textFieldRenderer3);
          * nested class
         class MyDocumentListener implements DocumentListener {
             String newline = "\n";
             public void insertUpdate(DocumentEvent e) {
                  System.out.println ("insert update");
                 updateLog(e, "inserted into");
             public void removeUpdate(DocumentEvent e) {
                  System.out.println ("remove update");
                 updateLog(e, "removed from");
             public void changedUpdate(DocumentEvent e) {
                 //Plain text components do not fire these events
             public void updateLog(DocumentEvent e, String action) {
                 Document doc = (Document)e.getDocument();
                 int changeLength = e.getLength();
                 textFieldRenderer3.append(
                     changeLength + " character" +
                     ((changeLength == 1) ? " " : "s ") +
                     action + doc.getProperty("name") + "." + newline +
                     "  Text length = " + doc.getLength() + newline);
          * @param args
         public static void main(String[] args) {
              try{
                   UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
              catch (Exception e){
                   e.printStackTrace();
             String[] columnNameArray = {
                       TEXT_COLUMN_HEADER,
                       "1",
                       "2",
              Object[][]  dataArray = {      {"", "", ""},      };
              final MyTable_TextArea panel = new MyTable_TextArea(dataArray, columnNameArray);
              final JFrame frame = new JFrame();
              frame.getContentPane().add(new JScrollPane(panel));
              frame.setTitle("My Table");
              frame.setPreferredSize(new Dimension(500, 200));
              frame.addWindowListener(new WindowAdapter(){
                   @Override
                   public void windowClosing(WindowEvent e) {
              frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
              frame.setLocation(300, 200);
              frame.pack();
              frame.setVisible(true);
    class TextFieldRenderer3 extends JTextArea implements TableCellRenderer {
         Icon defaultIcon;
         boolean isChecked = false;
         public TextFieldRenderer3() {
              System.out.println ("TextFieldRenderer()");
              setToolTipText("Double click to type");
         @Override
         public Component getTableCellRendererComponent(JTable table,
                   Object value,
                   boolean isSelected,
                   boolean hasFocus,
                   int row,
                   int column) {
              System.out.println ("TextFieldRenderer.getTableCellRendererComponent() row/column: " + row + "\t"+ column);
              return this;
    }

    I've implemented in the cell editor. I don't see how to get the value being typed (and nothing appears in the text area)
    import java.awt.Component;
    import java.awt.Dimension;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import java.util.EventObject;
    import javax.swing.Icon;
    import javax.swing.JFrame;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.JTextArea;
    import javax.swing.UIManager;
    import javax.swing.event.CellEditorListener;
    import javax.swing.event.DocumentEvent;
    import javax.swing.event.DocumentListener;
    import javax.swing.table.DefaultTableModel;
    import javax.swing.table.TableCellEditor;
    import javax.swing.table.TableCellRenderer;
    import javax.swing.table.TableColumn;
    import javax.swing.text.Document;
    public class MyTable_TextArea extends JTable {
         private DefaultTableModel defaultTableModel;
         private Object[][] dataArray;
         private Object[] columnNameArray;
         public final int TEXT_COLUMN = 0;     
         // column headers
         public static final String TEXT_COLUMN_HEADER = "Text";
         // text area
         TextAreaEditor textAreaEditor;
          * constructor
          * @param variableNameArray
          * @param columnNameArray
         public MyTable_TextArea(Object[][] variableNameArray, Object[] columnNameArray) {
              this.dataArray = variableNameArray;
              this.columnNameArray = columnNameArray;
              defaultTableModel = new DefaultTableModel(variableNameArray, columnNameArray);
              this.setModel(defaultTableModel)     ;
              // text field
            textAreaEditor = new TextAreaEditor();
              MyDocumentListener myListener = new MyDocumentListener();
              textAreaEditor.getDocument().addDocumentListener(myListener);
            TableColumn modelColumn = this.getColumnModel().getColumn(TEXT_COLUMN);
              modelColumn.setCellEditor(textAreaEditor);
          * nested class
         class MyDocumentListener implements DocumentListener {
             String newline = "\n";
             public void insertUpdate(DocumentEvent e) {
                  System.out.println ("insert update");
                 updateLog(e, "inserted into");
             public void removeUpdate(DocumentEvent e) {
                  System.out.println ("remove update");
                 updateLog(e, "removed from");
             public void changedUpdate(DocumentEvent e) {
                 //Plain text components do not fire these events
             public void updateLog(DocumentEvent e, String action) {
                 Document doc = (Document)e.getDocument();
                 int changeLength = e.getLength();
                 textAreaEditor.append(
                     changeLength + " character" +
                     ((changeLength == 1) ? " " : "s ") +
                     action + doc.getProperty("name") + "." + newline +
                     "  Text length = " + doc.getLength() + newline);
          * @param args
         public static void main(String[] args) {
              try{
                   UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
              catch (Exception e){
                   e.printStackTrace();
             String[] columnNameArray = {
                       TEXT_COLUMN_HEADER,
                       "1",
                       "2",
              Object[][]  dataArray = {      {"", "", ""},      };
              final MyTable_TextArea panel = new MyTable_TextArea(dataArray, columnNameArray);
              final JFrame frame = new JFrame();
              frame.getContentPane().add(new JScrollPane(panel));
              frame.setTitle("My Table");
              frame.setPreferredSize(new Dimension(500, 200));
              frame.addWindowListener(new WindowAdapter(){
                   @Override
                   public void windowClosing(WindowEvent e) {
              frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
              frame.setLocation(300, 200);
              frame.pack();
              frame.setVisible(true);
    class TextAreaEditor extends JTextArea implements TableCellEditor {
         Icon defaultIcon;
         boolean isChecked = false;
         public TextAreaEditor() {
              System.out.println ("TextAreaEditor()");
              setToolTipText("Double click to type");
         @Override
         public Component getTableCellEditorComponent(JTable arg0,
                   Object arg1,
                   boolean arg2,
                   int arg3,
                   int arg4) {
              System.out.println ("TextAreaEditor() arg1: " + arg1 + "arg2: " + arg2  + " arg3: " + arg3  + " arg4: " + arg4  );
              return null;
         @Override
         public void addCellEditorListener(CellEditorListener arg0) {
              System.out.println ("TextAreaEditor().addCellEditorListener");
         @Override
         public void cancelCellEditing() {
              System.out.println ("TextAreaEditor().cancelCellEditing");
         @Override
         public Object getCellEditorValue() {
              System.out.println ("TextAreaEditor().getCellEditorValue");
              return null;
         @Override
         public boolean isCellEditable(EventObject arg0) {
              System.out.println ("TextAreaEditor().isCellEditable");
              return true;
         @Override
         public void removeCellEditorListener(CellEditorListener arg0) {
              System.out.println ("TextAreaEditor().removeCellEditorListener");          
         @Override
         public boolean shouldSelectCell(EventObject arg0) {
              System.out.println ("TextAreaEditor().shouldSelectCell");
              return false;
         @Override
         public boolean stopCellEditing() {
              System.out.println ("TextAreaEditor().stopCellEditing");
              return false;
    }

  • SWF panel listener for changed selection

    In short, my question is as follows. Is it possible to create a listener which
    detects when the current selection in the Flash authoring tool has changed,
    and informs my SWF panel? This does not have to be a listener per se,
    it can be some hand-crafted process which consumes some reasonable amount of processor time.
    I describe my question more precisely below.
    Suppose that I want to create an SWF extension panel for Flash (in Flash or Flex),
    and I would like the panel to display a property of the object currently selected on scene
    in the Flash IDE -- like the instance name of the object (if it exists).
    I can use JSFL to detect the instance name of the selected object, and pass the string to the
    SWF panel using call(), for instance. The problem is that I don't know how
    to detect that the user has selected the object, or that the selection has changed.
    Ideally, I would like to add an event listener that listens for such an action in the flash authoring tool.
    However, using JSFL, this does not seem to be possible (I can only listen to events such as frame changed
    or layer changed, but not selection changed).
    I tried the following solutions:
    1. Periodically check in JSFL whether the current selection has changed.
    The problem is that in JSFL, there is no sleep function, or anything alike. The javascript
    methods setInterval and setTimeout do not work in JSFL. Therefore, in order to periodically check for changes,
    one must actively loop. This is extremely resource-consuming -- in fact, it hangs the flash IDE.
    2. The periodic check can be triggered by the SWF panel itself. In actionscript, I can use setInterval to periodically
    invoke the selection update function via JSFL. I have set the interval to 400 milliseconds, which gives a reasonably quick
    reaction to changes. However, the functionality I want to implement is in fact more complicated than just retrieving the
    instance name of the selected object. As a consequence, performing this operation every 400 milliseconds still consumes
    too much processor time (the flash IDE consumes 30% of my processor time, even if the user doesn't do anything).
    Therefore, I still would like to find a solution which does not use the processor when the user does not do anything in the Flash IDE.

    I'm trying to do the same thing. Did you find a solution?

  • Listen for change in JTextField

    I would like to write an event listener to listen for any changes made to a JTextField. Normally I would think that keyListeners would do the trick except that the contents of this field can be altered by the application itself, and I would like to trap those changes too.
    Does anyone know of an event listener that listens for any changes made in the text of a JTextField, regardless of how those changes are made?

    use DocumentListener
    for more info see http://java.sun.com/docs/books/tutorial/uiswing/components/generaltext.html#doclisteners

  • 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

  • Is there any event listener for changing the selection of layer?

    Hi all,
    I am looking into an event listener which fires on changing the selection of layer. I found 'Select' event listener which fires on selecting the different object.
    Actually the problem with Select event listener is that when we select an object and move it and deselect it by clicking on the document, event fires on the selection of that object. But if we again select the same object and move it, no event is fired at that time.
    Is there any workaround of this? So that the event is fired every time when we select the same object.
    Please help me on this..
    Regards,
    VG.

    Thanks for the reply..
    Actually I want the same behaviour as in illustrator i.e
    - Select a layer. (Notifier calls the listener)
    - Move it.
    - Click on the document.
    - Again select the same layer. (Notifier calls the listener again)
    - Move it.
    But in photoshop,
    - Select a layer. (Notifier calls the listener)
    - Move it.
    - Click on the document.
    - Again select the same layer. (Notifier doesnot calls the listener again as the layer is already selected in panel as you explained.)
    - Move it.
    Is there any way to get the same behaviour of illustrator in photoshop?

  • Data changes in JTable cell.

    Hi all,
    On editing a cell in a Jtable ,necessary changes must get enforced in the corresponding cells of the same JTable.For example,I have fields called Quantity ,SalePrice and TotalAmount in a Jtable,where the Quantity field is editable.When i edit the Quantity value,a calculation (Changed Quantity *SalePrice)=TotalPrice must happen .Hence the Total Amount field must get Updated now.This must occur when I edit the Quantity and press Tab.No Button action is involved.Please tell me how to do this.the JTable does not use any TableModel.Thanks in advance.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    As I said in your other post, your table does have a model.
    What you seem to be saying is that your table has some calculated columns. If so then you should create an explicit table model so that when a cell is update the setValueAt() method performs any calculations based on this change and updates the rest of the model.
    Remember to fire the appropriate events after the change.

  • Is there some way to set focus on a JTable Cell?

    Hi,
    I have used JDK6 with a JTable that has some cells not-editabled and others editable.
    Then, when the user types TAB key, I would like to change to next editabled cell, jumping out the not-editables. Is there a way to do this?
    Thanks

    check out this thread:
    http://forum.java.sun.com/thread.jspa?forumID=57&threadID=509913
    Theoretically you could modify the FocusTraversalPolicy but I've never done that.
    Message was edited by:
    Jaspre

  • Listener for CheckBoxes in JTable

    Hi,
    I have a table that displays a checkbox in one of the fields. Which event handler/ listener should I use? Eg: Checkbox listener, List listener or otherwise?
    A change in the checkbox value (tick or untick) will trigger recalculation.
    Thanks.

    I can't really understand your problem.
    Here's a simple example that will print out the new check box state when you press the checkbox:
    import javax.swing.JDialog;
    import javax.swing.JFrame;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.event.TableModelEvent;
    import javax.swing.event.TableModelListener;
    import javax.swing.table.DefaultTableModel;
    import javax.swing.table.TableModel;
    public class TableCheckboxListenerExample {
        public static void main(String[] args) {
            try {
                JFrame frame = new JFrame();
                frame.setDefaultCloseOperation(JDialog.EXIT_ON_CLOSE);
                DefaultTableModel model = new DefaultTableModel(new Object[][] {{Boolean.FALSE, "Row 1"}, {Boolean.TRUE, "Row 2"}}, new String[] {"col1", "col2"}) {
                    public Class<?> getColumnClass(int columnIndex) {
                        if (getRowCount() > 0 && getValueAt(0, columnIndex) != null)
                            return getValueAt(0, columnIndex).getClass();
                        return super.getColumnClass(columnIndex);
                model.addTableModelListener(new TableModelListener() {
                    public void tableChanged(TableModelEvent e) {
                        int row = e.getFirstRow();
                        int column = e.getColumn();
                        TableModel model = (TableModel)e.getSource();
                        Object data = model.getValueAt(row, column);
                        if (data instanceof Boolean)
                            System.out.println("Value changed in Row: " + row + " Column: " + column + " New Value = " + data);
                JTable table = new JTable(model);
                frame.add(new JScrollPane(table));
                frame.pack();
                frame.setVisible(true);
            catch (Exception e) {e.printStackTrace();}       
    }

Maybe you are looking for

  • How to Hide BP Functions - Points will be awarded

    Dear Guru's, I would need to Block CRM Business Partner Functions which are not required to list out. I through with the following steps to block: (CRM 4.0) IMG --> CRM --> B.Functions --> Partner Processing --> Define Partner Functions. Here I Check

  • KER1-Changes not update in KE30

    Hi folks, i have sa problem with KER1. I have done a change on existing key figure scheme. I have added in a element formula 5010  a new element 9002. Now the formula is 9001+9002. I have saved, now i want to now why in KE30 i don't see any changes,

  • Safari developers menu won't go away

    I typed: defaults write com.apple.Safari IncludeDebugMenu 1 in Terminal to turn the Developers menu on, but when I typed: defaults write com.apple.Safari IncludeDebugMenu 0 to turn the developers menu off, *it won't turn off*. Did the command change?

  • Unistalling vista in parallels and installing xp in boot camp

    okay i have a macbook, running leopard. i currently have parallels running vista but i want to remove both and install boot camp and xp with a disk my friend has. i got my computer from macmall and so they installed vista and parallels. can i remove

  • How do I reinstate my toolbar with 'tools', 'bookmarks' etc. on it? It has vanished.

    My toolbar with 'tools', 'bookmarks' etc. has disappeared. Where is it and how can I reinstate it?