Using Table Model as a Grid?

Would it be possible to add JButtons(or JPanels) to create cells in a Table Model implementation? How would I go about this? Would I then be able to listen for events from these JButtons using the methods native to table model such as getValueAt(int row, int col) etc.
What I am trying to do is to implement a grid of 10X10 cells for a battleship game so that the user can click on cells on the grid and that this will trigger an event specifying to user whether it was a hit or miss etc. and change the color of cell (JButton) based on hit/miss etc.
Any help would be appreciated.
Thanks.

Well you need:
1) a custom cell renderer class that is able to manage the change of background and the contents of the cell by itself
2) a custom cell event listener that allows you to get and process the messages.
You can find a full-featured example at the address: http://www.java2s.com/Code/Java/Swing-JFC/TableEditorEditableColorColumn.htm

Similar Messages

  • JFreeReport(By using Table Model)

    Hi,
    Good Evening
    I got the sample coding for JFreeReport from
    jfreereport-0.8.3-A4.pdf.I understand the coding.
    But I couldnot understand What are the required libraries and how to add all in to my program.I didnot know how do set 'jfreereport-0.8.3.jar' file to my classpath. I couldnot understand it from the above pdf.So I got so many errors of "cannot find symbol".
    I unzip all the contents of jfreereport-0.8.3 and put in to a directory Jfree.
    And in C:\java\jdk1.5.0-05\bin I write the coding for HelloWorld.java
    My coding is
    import java.awt.*;
    import javax.swing.table.*;
    public class HelloWorld
    public HelloWorld()
    TableModel data = createData();
    JFreeReport report = createReportDefinition();
    report.setData(data);
    try
    PreviewFrame preview = new PreviewFrame(report);
    preview.pack();
    preview.setVisible(true);
    catch (ReportProcessingException e)
    Log.error("Failed to generate report ", e);
    private TableModel createData()
    Object[] columnNames = new String[] { "Column1", "Column2" };
    DefaultTableModel result = new DefaultTableModel(columnNames, 1);
    result.setValueAt("Hello", 0, 0);
    result.setValueAt("World!", 0, 1);
    return result;
    private JFreeReport createReportDefinition()
    JFreeReport report = new JFreeReport();
    report.setName("A Very Simple Report");
    TextElement t1 = ItemFactory.createStringElement(
    "T1",
    new Rectangle2D.Double(0.0, 0.0, 150.0, 20.0),
    Color.black,
    ElementAlignment.LEFT.getOldAlignment(),
    ElementAlignment.MIDDLE.getOldAlignment(),
    null, // font
    "-", // null string
    "Column1"
    report.getItemBand().addElement(t1);
    TextElement t2 = ItemFactory.createStringElement(
    "T2",
    new Rectangle2D.Double(200.0, 0.0, 150.0, 20.0),
    Color.black,
    ElementAlignment.LEFT.getOldAlignment(),
    ElementAlignment.MIDDLE.getOldAlignment(),
    null, // font
    "-", // null string
    "Column2"
    report.getItemBand().addElement(t2);
    return report;
    public static void main(String[] args)
    HelloWorld app = new HelloWorld();
    So Please help me how can I set classpath,where and how can I add the needed libraries to my program.
    Thank you so much,
    Meena.

    Hi,
    Good Morning,
    I tried with your reply.
    I first imported all my required packages .
    I am using jfreereport-0.8.3.
    But I got so many errors of "Cannot find Symbol".
    Will you please help me ?
    My code is:
    import java.awt.Color;
    import java.awt.geom.Rectangle2D;
    import javax.swing.table.DefaultTableModel;
    import javax.swing.table.TableModel;
    import com.jrefinery.report.JFreeReport;
    import com.jrefinery.report.util.log;
    import com.jrefinery.report.preview.PreviewFrame;
    import com.jrefinery.report.ItemFactory;
    import com.jrefinery.report.ElementAlignment;
    public class HelloWorld1
        public HelloWorld1()
            TableModel data = createData();
            JFreeReport report = createReportDefinition();
            report.setData(data);
            try
                PreviewFrame preview = new PreviewFrame(report);
                preview.pack();
                preview.setVisible(true);
            catch (ReportProcessingException e)
                Log.error("Failed to generate report ", e);
        private TableModel createData()
            Object[] columnNames = new String[] { "Column1", "Column2" };
            DefaultTableModel result = new DefaultTableModel(columnNames, 1);
            result.setValueAt("Hello", 0, 0);
            result.setValueAt("World!", 0, 1);
            return result;
        private JFreeReport createReportDefinition()
            JFreeReport report = new JFreeReport();
            report.setName("A Very Simple Report");
            TextElement t1 = ItemFactory.createStringElement("T1",new Rectangle2D.Double(0.0, 0.0, 150.0, 20.0),Color.black, ElementAlignment.LEFT.getOldAlignment(), ElementAlignment.MIDDLE.getOldAlignment(),null,"-","Column1");
            report.getItemBand().addElement(t1);
            TextElement t2 = ItemFactory.createStringElement("T2",new Rectangle2D.Double(200.0, 0.0, 150.0, 20.0),Color.black,ElementAlignment.LEFT.getOldAlignment(),ElementAlignment.MIDDLE.getOldAlignment(),null,"-","Column2");
            report.getItemBand().addElement(t2);
            return report;
        public static void main(String[] args)
            HelloWorld1 app = new HelloWorld1();
    }

  • Help on refreshing a table every second ? using table model

    hi there
    i have created a table using defaultTableModel. now i need to refresh the table every two seconds. to implement the refreshing, do i need to revalidate the container pane of the table every two second? i am just wondering since i use the tablemodel, maybe it can revalidate or repack automatically. please help me and thank you.

    hi there
    thank you for your help
    here is what my table does, the program connects to the database, retreive data and populate the table every two seconds to reflect the changes in the database. here is the run method that does the connecting and ...
    public void run()
    boolean okay = true;
    boolean updated = false;
    String strSQL = "sql statment"
    try{
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con = DriverManager.getConnection(".....")
    PreparedStatement ps = con.prepareStatement(strSQL);
    while (okay)
    rs = ps.executeQuery();
    //code to query the database.....
    tablemodel = (DefaultTableModel)jTable.getModel();
    //code to repaint the table......
    Thread.sleep(1000);
    }catch (ClassNotFoundException cnfe){
    }catch (SQLException sqle) {
    }catch (InterruptedException e){
    okay = false;
    }catch (Exception ee){
    System.out.println("Exception:" + ee.getMessage());
    what can tablemodel do for this kind of task?

  • How to use JTable model listener???

    Anyone got idea , how to use table model listener. Can explain in simple example with code?? how to pass back to resultset ??

    Well, your pretty good at asking questions, but not very good at thanking people for the help given to you so I don't think I'll waste too much time helping this time.
    A TableModelListener notifies you when the contents of a cell are changed. So simply take the data from the cell and update your ResultSet. You question is so general I don't know how you expect any more advice than that.

  • Table model and default model

    Hi All,
    can u tell me how to use table model or default table model. where i can references about it???
    thanks for all

    [http://java.sun.com/docs/books/tutorial/uiswing/components/table.html#data]

  • Use ComboBox TableCellEditor  - values are not saved to the table model

    Hi,
    I got a combobox cell editor that uses to edit one of the columns.
    And i got an ok button that uses to collect the data from the table and save it to the db.
    In case i started editing of a cell and the editor is still displayed- if i will click on the button the data that will be colected from the table model will not contained the updated value in the cell editor.
    In this case the user think his changes were saved but the last updated field is not updated.
    Is this a bug i got in the cell editor or this is the normal behaviour?
    Can it be fixed? (So that if the cell is in the middle of editing the value that will be saved is the last value that was selected).
    public class PriorityCellEditor extends StandardComboBox implements TableCellEditor {
        private boolean isEditMode=false;
         * A list of eventlisteners to call when an event is fired
        private EventListenerList listenerList = new EventListenerList();
         * the table model
        public StbAreaClusterPriorityCellEditor(boolean isEditMode) {
            super(StbAreaMapper.clustersPriorities);
            setEditMode(isEditMode);
            setEditable(false);
            this.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
            setAlignmentX(Component.LEFT_ALIGNMENT);
        public boolean isEditMode() {
            return isEditMode;
        public void setEditMode(boolean editMode) {
            isEditMode = editMode;
            setEnabled(editMode);
        public Component getTableCellEditorComponent(JTable table, Object value,boolean isSelecte, int row, int column) {
            int selectedIndex;
            if (isSelecte) {
                setForeground(table.getSelectionForeground());
                setBackground(table.getSelectionBackground());
            } else {
                setForeground(table.getForeground());
                setBackground(table.getBackground());
            if(value instanceof String){
                selectedIndex=StbAreaMapper.mapGuiPriorityDescToGuiCode((String)value);
                setSelectedIndex(selectedIndex);
            return this;
        public void cancelCellEditing() {
            fireEditingCanceled();
        public Object getCellEditorValue() {
            return getSelectedItem();
        public boolean isCellEditable(EventObject anEvent) {
            return isEditMode;
        public boolean shouldSelectCell(EventObject anEvent) {
            return false;
        public boolean stopCellEditing() {
            fireEditingStopped();
            return true;
         * Adds a new cellEditorListener to this cellEditor
        public void addCellEditorListener(CellEditorListener l) {
            listenerList.add(CellEditorListener.class, l);
         * Removes a cellEditorListener from this cellEditor
        public void removeCellEditorListener(CellEditorListener l) {
            listenerList.remove(CellEditorListener.class, l);
         * Notify all listeners that have registered interest for notification on
         * this event type.
         * @see javax.swing.event.EventListenerList
        protected void fireEditingStopped() {
            // Guaranteed to return a non-null array
            Object[] listeners = listenerList.getListenerList();
            // Process the listeners last to first, notifying
            // those that are interested in this event
            for (int i = listeners.length - 2; i >= 0; i -= 2) {
                if (listeners[i] == CellEditorListener.class) {
                    ((CellEditorListener) listeners[i + 1]).editingStopped(
                            new ChangeEvent(this));
         * Notify all listeners that have registered interest for notification on
         * this event type.
         * @see javax.swing.event.EventListenerList
        protected void fireEditingCanceled() {
            // Guaranteed to return a non-null array
            Object[] listeners = listenerList.getListenerList();
            // Process the listeners last to first, notifying those that are interested in this event
            for (int i = listeners.length - 2; i >= 0; i -= 2) {
                if (listeners[i] == CellEditorListener.class) {
                    ((CellEditorListener) listeners[i + 1]).editingCanceled(new ChangeEvent(this));
    }

    Try this
    yourTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);

  • JTable column headers not displaying using custom table model

    Hi,
    I'm attempting to use a custom table model (by extending AbstractTableModel) to display the contents of a data set in a JTable. The table is displaying the data itself correctly but there are no column headers appearing. I have overridden getColumnName of the table model to return the correct header and have tried playing with the ColumnModel for the table but have not been able to get the headers to display (at all).
    Any ideas?
    Cheers

    Class PublicationTableModel:
    public class PublicationTableModel extends AbstractTableModel
        PublicationManager pubManager;
        /** Creates a new instance of PublicationTableModel */
        public PublicationTableModel(PublicationManager pm)
            super();
            pubManager = pm;
        public int getColumnCount()
            return GUISettings.getDisplayedFieldCount();
        public int getRowCount()
            return pubManager.getPublicationCount();
        public Class getColumnClass(int columnIndex)
            Object o = getValueAt(0, columnIndex);
            if (o != null) return o.getClass();
            return (new String()).getClass();
        public String getColumnName(int columnIndex)
            System.out.println("asked for column name "+columnIndex+" --> "+GUISettings.getColumnName(columnIndex));
            return GUISettings.getColumnName(columnIndex);
        public Publication getPublicationAt(int rowIndex)
            return pubManager.getPublicationAt(rowIndex);
        public Object getValueAt(int rowIndex, int columnIndex)
            Publication pub = (Publication)pubManager.getPublicationAt(rowIndex);
            String columnName = getColumnName(columnIndex);
            if (columnName.equals("Address"))
                if (pub instanceof Address) return ((Address)pub).getAddress();
                else return null;
            else if (columnName.equals("Annotation"))
                if (pub instanceof Annotation) return ((Annotation)pub).getAnnotation();
                else return null;
            etc
           else if (columnName.equals("Title"))
                return pub.getTitle();
            else if (columnName.equals("Key"))
                return pub.getKey();
            return null;
        public boolean isCellEditable(int rowIndex, int colIndex)
            return false;
        public void setValueAt(Object vValue, int rowIndex, int colIndex)
        }Class GUISettings:
    public class GUISettings {
        private static Vector fields = new Vector();
        private static Vector classes = new Vector();
        /** Creates a new instance of GUISettings */
        public GUISettings() {
        public static void setFields(Vector f)
            fields=f;
        public static int getDisplayedFieldCount()
            return fields.size();
        public static String getColumnName(int columnIndex)
            return (String)fields.elementAt(columnIndex);
        public static Vector getFields()
            return fields;
    }GUISettings.setFields has been called before table is displayed.
    Cheers,
    garsher

  • How to Add and delete a row while using Abstract Table Model

    Hi,
    I need to do the following functionalities in JTable.I've done tht but a small problem.
    1. Adding a row (Using addRow() method from DefaultTableModel).
    2. Deleting a row(Using setRowCount() method from Default Table Model).
    3. Sorting the table based on the selection of column(Using TableSorter which is using AbstracTableModel).
    As the sorting is mandatory i've to change my model to Abtract Table Model
    The problem is this Abstract Table Model doesn't have any methods to Add a row or deleting a row (setRowCount()).If anybody has written any utility method for this using Abstract Table Model help me.

    Using TableSorter which is using AbstracTableModel).If your talking about the TableSorter class from the Swing tutorial, then you create the TableSorter class by passing it a TableModel. There is no reason you can't use the DefaltTableModel.
    I changed the code in TableSorterDemo as follows:
            String[] columnNames = {"First Name",
                                            "Last Name",
                                            "Sport",
                                            "# of Years",
                                            "Vegetarian"};
            Object[][] data = {
                {"Mary", "Campione",
                 "Snowboarding", new BigDecimal(1), new Boolean(false)},
                {"Alison", "Huml",
                 "Rowing", new BigDecimal(3), new Boolean(true)},
                {"Kathy", "Walrath",
                 "Knitting", new BigDecimal(2), new Boolean(false)},
                {"Sharon", "Zakhour",
                 "Speed reading", new BigDecimal(20), new Boolean(true)},
                {"Philip", "Milne",
                 "Pool", new BigDecimal(10), new Boolean(false)}
              DefaultTableModel model = new DefaultTableModel(data, columnNames)
                   public Class getColumnClass(int c)
                        return getValueAt(0, c).getClass();
            TableSorter sorter = new TableSorter(model);
    //        TableSorter sorter = new TableSorter(new MyTableModel()); //ADDED THIS

  • Custom table model, table sorter, and cell renderer to use hidden columns

    Hello,
    I'm having a hard time figuring out the best way to go about this. I currently have a JTable with an custom table model to make the cells immutable. Furthermore, I have a "hidden" column in the table model so that I can access the items selected from a database by their recid, and then another hidden column that keeps track of the appropriate color for a custom cell renderer.
    Subject -- Sender -- Date hidden rec id color
    Hello Pete Jan 15, 2003 2900 blue
    Basically, when a row is selected, it grabs the record id from the hidden column. This essentially allows me to have a data[][] object independent of the one that is used to display the JTable. Instinctively, this does not seem right, but I don't know how else to do it. I know that the DefaultTableModel uses a Vector even when it's constructed with an array and I've read elsewhere that it's not a good idea to do what I'm trying to do.
    The other complication is that I have a table sorter as well. So, when it sorts the objects in the table, I have it recreate the data array and then set the data array of the ImmutableTableModel when it has rearranged all of the items in the array.
    On top of this, I have a custom cell renderer as well. This checks yet another hidden field and displays the row accordingly. So, not only does the table sort need to inform the table model of a change in the data structure, but also the cell renderer.
    Is there a better way to keep the data in sync between all of these?

    To the OP, having hidden columns is just fine, I do that all the time.. Nothing says you have to display ALL the info you have..
    Now, the column appears to be sorting properly
    whenever a new row is added. However, when I attempt
    to remove the selected row, it now removes a seemingly
    random row and I am left with an unselectable blank
    line in my JTable.I have a class that uses an int[] to index the data.. The table model displays rows in order of the index, not the actual order of the data (in my case a Vector of Object[]'s).. Saves a lotta work when sorting..
    If you're using a similar indexing scheme: If you're deleting a row, you have to delete the data in the vector at the INDEX table.getSelectedRow(), not the actual data contained at
    vector.elementAt(table.getSelectedRow()). This would account for a seemingly 'random' row getting deleted, instead of the row you intend.
    Because the row is unselectable, it sounds like you have a null in your model where you should have a row of data.. When you do
    vector.removeElementAt(int), the Vector class packs itself. An array does not. If you have an array, when you delete the row you must make sure you dont have that gap.. Make a new array of
    (old array length-1), populate it, and give it back to your model.. Using Vectors makes this automatic.
    Also, you must make sure your model knows the data changed:
    model.fireTableDataChanged(); otherwise it has no idea anything happened..
    IDK if that's how you're doing it, but it sounds remarkably similar to what I went thru when I put all this together..

  • Using custom table model with the Net Beans JTable

    I am using the net beans editor to create an application. For the JTable that net beans provides, I would like to use my own Table Model instead of the default one that is provided. How do I specify to the form editor that I want to use my own TableModel instead of the DeafaultTableModel?

    I am using the net beans editor to create an application. For the JTable that net beans provides, I would like to use my own Table Model instead of the default one that is provided. How do I specify to the form editor that I want to use my own TableModel instead of the DeafaultTableModel?

  • Physical attributes for index on temp tables (using physical model)

    I need create index on temp tables.
    When I generate DDL, it includes physical attributes like ‘LOGGING NOCOMPRESS NOPARALLEL’.
    I get error "ORA – 14451 (unsupported feature w/temporary tables)"
    I’ve to use physical model in OSDM. How do I get rid of physical attributes in DDL for index?

    Hi,
    Thanks for reporting this problem.
    You can remove the LOGGING clause by opening the Properties dialog for the Index in the Physical model and setting its Logging property to the blank option.
    However it's not possible to suppress the NOCOMPRESS and NOPARALLEL at the moment.
    I've logged a bug on this.
    As a workaround, you could do a global edit on the DDL file to remove all instances of NOCOMPRESS and NOPARALLEL.
    David

  • Calc problem with fact table measure used as part of bridge table model

    Hi all,
    I'm experiencing problems with the calculation of a fact table measure ever since I've used it as part of a calculation in a bridge table relationship.
    In a fact table, PROJECT_FACT, I had a column (PROJECT_COST) whose default aggregate was SUM. Whenever PROJECT_COST was used with any dimension, the proper aggregation was done at the proper levels. But, not any longer. One of the relationships PROJECT_FACT has is with a dimension, called PROJECT.
    PROJECT_FACT contains details of employees and each day they worked on a PROJECT_ID. So for a particular day, employee, Joe, might have a PROJECT_COST of $80 for PROJECT_ID 123, on the next day, Joe might have $40 in PROJECT_COST for the same project.
    Dimension table, PROJECT, contains details of the project.
    A new feature was added to the software - multiple customers can now be charged for a PROJECT, where as before, only one customer was charged.
    This percentage charge break-down is in a new table - PROJECT_BRIDGE. PROJECT_BRIDGE has the PROJECT_ID, CUSTOMER_ID, BILL_PCT. BILL_PCT will always add up to 1.
    So, the bridge table might look like...
    PROJECT_ID CUSTOMER_ID BILL_PCT
    123          100     .20
    123          200     .30
    123          300     .50
    456 400 1.00
    678 400 1.00
    Where for project 123, is a breakdown for multiple customers (.20, .30. .50).
    Let's say in PROJECT_FACT, if you were to sum up all PROJECT_COST for PROJECT_ID = 123, you get $1000.
    Here are the steps I followed:
    - In the Physical layer, PROJECT_FACT has a 1:M with PROJECT_BRIDGE as does PROJECT to PROJECT_BRIDGE (a 1:M).
    PROJECT_FACT ===> PROJECT_BRIDGE <=== PROJECT
    - In the Logical layer, PROJECT has a 1:M with PROJECT_FACT.
    PROJECT ===> PROJECT_FACT
    - The fact logical table source is mapped to the bridge table, PROJECT_BRIDGE, so now it has multiple tables it maps to (PROJECT_FACT & PROJECT_BRIDGE). They are set for an INNER join.
    - I created a calculation measure, MULT_CUST_COST, using physical columns, that calculates the sum of the PROJECT_COST X the percentage amount in the bridge table. It looks like: SUM(PROJECT_FACT.PROJECT_COST * PROJECT_BRIDGE.BILL_PCT)
    - I brought MULT_CUST_COST into the Presentation layer.
    We still want the old PROJECT_COST around until it get's phased out, so it's in the Presentation layer as well.
    Let's say I had a request with only PROJECT_ID, MULT_CUST_COST (the new calculation), and PROJECT_COST (the original). I'd expect:
    PROJECT_ID MULT_CUST_COST PROJECT_COST
    123          $1000     $1000
    I am getting this for MULT_CUST_COST, however, for PROJECT_COST, it's tripling the value (possibly because there are 3 percent amounts?)...
    PROJECT_ID MULT_CUST_COST PROJECT_COST
    123          $1000 (correct)      $3000 (incorrect, it's been tripled)
    If I were to look at the SQL, it would have:
              SELECT SUM(PROJECT_COST),
    SUM(PROJECT_FACT.PROJECT_COST * PROJECT_BRIDGE.BILL_PCT),
                   PROJECT_ID
              FROM ...
              GROUP BY PROJECT_ID
    PROJECT_COST used to work correctly before modeling a bridge table.
    Any ideas on what I did wrong?
    Thanks!

    Hi
    Phew, what a long question!
    If I understand correctly I think the problem lies with your old cost measure, or rather combining that with you new one in the same request. If you think about it, your query as explained above will bring back 3 rows from the database which is why your old cost measure is being multiplied. I suspect that if you took it out of the query, your bridge table would be working properly for the new measure alone?
    I would consider migrating your historic data into the bridge table model so that you have a single type of query. For the historic data each would have a single row in the bridge with a 1.0 BILL_PCT.
    Best of luck,
    Paul
    http://total-bi.com

  • PageUp/PageDown By using Default Table Model

    Hi all,
    iam using Default Table model for my jtable i want to do pageup and pagedown operation .
    TableColumnModel cm1 = new DefaultTableColumnModel();
    DefaultTablemodel md = new DefaultTableModel(row,col);
    JTable t = new JTable(md,cm1);
    i have 500 rows currently in my database i want to display 100 in the first page and if i press the pagedown button the next 100 has to be diplayed wether this is possible here.. if possible please help mee.

    Hi,
    could you please avoid double posting:
    http://forum.java.sun.com/thread.jsp?forum=57&thread=566380&tstart=0&trange=15
    especially with different subjects.
    It considerably reduces the overall efficiency as people will try to
    help you while the answer could already have been given in the another thread.
    If you want to push up the stack your message, reply to it,
    post more code, list the ideas that you've envisaged and so on.
    regards.

  • Is it posiible to paging up paging down in Jtable using Default Table Model

    Hi All!
    Is it possible to do Page up and Page down in JTable using Default Tble Model?
    Kindly reply!

    yes
    it is posiible to paging up paging down in Jtable using Default Table Model. just go thru the JAVA API you will get the results.

  • Adding data to a table model at run time

    hiii
    i want to add data to the table model at runtime.
    i have used TableModel.My code looks like this
    public class CaptureTableModel extends AbstractTableModel {
         private String[] columnNames = { "No", "Source", "Destination", "Protocol",
                   "Flags" };
         private TCPPacket tcpPacket;
         private List data;
         private static int counter = 0;
         private int columnCount = columnNames.length;
         public CaptureTableModel(){}
         public CaptureTableModel(TCPPacket tcp) {
              try{
              tcpPacket=tcp;
              counter++;
              byte[] tcpdata = tcpPacket.getData();
              String srcHost = tcpPacket.getSourceAddress();
              String dstHost = tcpPacket.getDestinationAddress();
              String tcpPacketData = new String(tcpdata, "ISO-8859-1");
              if (tcpPacketData == null)
                   tcpPacketData = "";
              int protocol = tcpPacket.getProtocol();
              String proto = null;
              if (protocol == 6)
                   proto = "TCP";
              long sequenceNumber = tcpPacket.getSequenceNumber();
              data = new ArrayList();
              String[] info = {
                        Integer.toString(counter),
                        srcHost,
                        dstHost,
                        proto,
                        "[ACK " + tcpPacket.isAck() + " ; FIN " + tcpPacket.isFin()
                                  + " ; PUSH " + tcpPacket.isPsh() + " ; RESET "
                                  + tcpPacket.isRst() + " ; SYN " + tcpPacket.isSyn()
                                  + " ; URGENT " + tcpPacket.isUrg() };
              data.add(info);
         } catch (Exception e) {
              e.printStackTrace();//return null;
         public int getRowCount() {
              return counter;
         public int getColumnCount() {
              return columnCount;
         public String getColumnName(int column) {
              return columnNames[column];
         public Object getValueAt(int rowIndex, int columnIndex) {
              System.out.println("the value in getValueAt"+((Object[])data.get(rowIndex))[columnIndex]);
              return ((Object[])data.get(columnIndex))[rowIndex];
              //return null;
    the method getValueAt is not bieng called..where am i going wrong.
    can anyone help me??

    Use the "code" formatting tags when posting code so the code retains its original formatting.
    i want to add data to the table model at runtime.Use the DefaultTableModel it supports dynamic methods like addRow(...), removeRow().

Maybe you are looking for

  • How to run Windows on top of Linux

    Just an idea for those of you who are using Linux but still need to run Windows XP or Vista for one reason or another. When I bought my machine, I immediately reformatted the HD getting rid of Vista and all of that other prebundeled junk that made my

  • Does Oracle XML Publisher version 5.6.2 integrate with Oracle Portal?

    We want to know if XMLP is just an external application to Oracle Portal or if it integrates with Oracle Portal.

  • Problem while adding XL-Reporter

    hi All, i added the Addon XL-Reporter on the client side and when i started teh Addon , i'm getting that class not registered,Presently i'm using the SBO20042B SP00 PL00 can anybody help me. Thanks & Regards shiva shanker.

  • Reporting errors while filling a JTable

    Hello all, this is my first post here. When i implement a class derived from AbstractTableModel to show some data in a JTable, sometimes, specially when this data is coming from databases, i need to be able to report any errors that ocur while geting

  • My KeyListener doesn´t work, why?

    Hi! I am trying to ge my KeyListener working. My code is as follows: class C extends JPanel           public C()                addMouseListener(new MListener());                         addKeyListener(new KListener());Furher down in the code I have