My JTable Column is not removing?

public class  ClassA extends JPanel
    private DefaultTableModel model = new DefaultTableModel();
    private JTable table = new JTable(model);
     public ClassA ()
     {  this.add(new Table1Panel() );
     public class Table1Panel extends JPanel
     {  clearTable();
        model.addColumn("col1");
        //add 5 rows
     public class Table2Panel extends JPanel
     {  clearTable();
        model.add("col2");
        //add 10 rows
     public void clearTable()
        while(model.getRowCount() != 0)
            model.removeRow(0);
        while(table.getColumnModel().getColumnCount() != 0)
            table.removeColumn(table.getColumnModel().getColumn(0));
}I've been researching for days and I can't seem to figure out interfacing with JTable.
How my program is supposed to work - program starts with Table1Panel. When a button is clicked, everything in Table1Panel should be removed and the variables, table and model, are supposed to be cleansed of all rows, data, and columns and Table2Panel is to be displayed with just "col2".
The problem: When the button is clicked, the columns in the table are never removed and the table displays as "col1 | col2" when it should only be "col2". If I click that button a second time, it will display as "col1 | col2 | col2".
This is the logic i use to removeColumns. What am I not understanding?
while(table.getColumnModel().getColumnCount() != 0)
table.removeColumn(table.getColumnModel().getColumn(0));

I think I found your problem, it can be demonstarted in the code below:
You kept adding more and more columns to your model. even though you took the columns away from your JTable because you added columns to your model and made your tables based on that model the columns just kept getting bigger and bigger. Every time you called new table1 or new table2 you added 2 more columns... Test this theory out, this is what I did with your code.
Not sure this is exactly what you want, but if it needs to do something different for a specific reason let me know and we can play around with it more..
Only thing about this, not sure if you want it this way or not is that it holds the users imput when switching back and forth.
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.table.DefaultTableModel;
public class ClassA extends JPanel
    private DefaultTableModel model1 = new DefaultTableModel();
    private JTable qtable1 = new JTable(model1);
    private DefaultTableModel model2 = new DefaultTableModel();
    private JTable qtable2 = new JTable(model2);
    private JButton jbButton1 = new JButton ("View Table1");
    private JButton jbButton2 = new JButton ("View Table2");
    private Boolean DEBUG = true;
    JPanel panel = new JPanel();
    public ClassA ()
         //Setup table 1
        model1.addColumn("col1");
        model1.addColumn("col2");
        for (int i=0; i<5; i++)
        { model1.addRow(new Object[]{null,null});  }
        qtable1.getColumnModel().getColumn(0).setPreferredWidth(600);
        qtable1.getColumnModel().getColumn(1).setPreferredWidth(200);
        qtable1.setRowHeight(20);
        qtable1.setPreferredScrollableViewportSize(new Dimension(500,500));
        //Setup table 2
        model2.addColumn("col3");
        model2.addColumn("col4");
        for (int i=0; i<5; i++)
         model2.addRow(new Object[]{null,null});
        qtable2.getColumnModel().getColumn(0).setPreferredWidth(600);
        qtable2.getColumnModel().getColumn(1).setPreferredWidth(200);
        qtable2.setRowHeight(20);
        qtable2.setPreferredScrollableViewportSize(new Dimension(500,500));
        this.setLayout(new FlowLayout());
        panel.add(new table1());
        this.add(panel);
        this.add(jbButton1);
        this.add(jbButton2);
        jbButton1.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent e){
                System.out.println("1");
                panel.removeAll();
                panel.add(new table1());
                panel.revalidate();
                repaint();
        jbButton2.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent e)
                System.out.println("2");
                panel.removeAll();
                panel.add(new table2());
                panel.revalidate();
                repaint();
private class table1 extends JPanel
    public table1 ()
    {    //qtable.setFillsViewportHeight(false);
            JScrollPane scrollPane = new JScrollPane(qtable1);
            this.add(scrollPane);
private class table2 extends JPanel
       public table2()
         //qtable.setFillsViewportHeight(false);
            JScrollPane scrollPane = new JScrollPane(qtable2);
            this.add(scrollPane);
    public static void main (String[] args)
        JFrame frame = new JFrame("Test ImportQuestionPanel");
        frame.getContentPane().add(new ClassA());
        frame.pack();
        frame.setVisible(true);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

Similar Messages

  • Custom JTable column (JCheckBox) not included in row selection.

    I am trying to use JCheckBox (for display only data) as one of my JTable columns. I have written custom cell renderer for the same. Every thing is working fine except that when I select a row, the new custom JCheckBox column is not included in selection. Here is the code that I am using.
        protected class CheckBoxColumnRenderer extends DefaultTableCellRenderer {
            JCheckBox ckb = new JCheckBox();
            public Component getTableCellRendererComponent(JTable table, Object value,
                        boolean isSelected, boolean hasFocus, int row, int column) {
                if (value instanceof Boolean) { // Boolean
                  ckb.setSelected(((Boolean) value));
                  ckb.setHorizontalAlignment(JLabel.CENTER);
                  ckb.setBackground(super.getBackground());
                  if (isSelected || hasFocus) {
                      ckb.setBackground(table.getSelectionBackground());
                return ckb;
        }How can I include the custom cell in the row selection.
    regards,
    nirvan.

    they have lots of dependencies and it is not always easy to strip out an SSCCE without a considerable effort.Exactly. And is the cause of the problem the dependencies or something else. The only way to know for sure is to strip out the code and simplify the problem, that way you truly understand what the problem is.
    The majority of time this can be done with minimal effort as in this case.
    Some times we are sure that the problem is with certain part of the code Is the problem the code or the way the code is invoked? How do we know the TableModel is created properly or that the column class is overwritten correctly when we can't see it?
    someone having a third look at it may actually find the enhancement required with ease.Exactly, but we need to see the big picture.
    So are you sure that I should post an SSCCE with every possible question where coding is involved ?In the majority of cases a SSCCE is easily created in 5-10 minutes, so if you want the fastest help then yes.
    Just twice this past week I was ready to ask a question on the forum and was preparing a SSCCE to post and sure enough both times the creation of the SSCCE caused me to look at the problem differently and I solved it. I would much rather solve a problem on my own then post a question and wait for hours (days) hoping someone else knows the answer.

  • 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

  • JTable, column names not appearing!

    I am using the following code:
    Vector columnNames = new Vector();
            Vector data = new Vector();
            try
                //  Connect to the Database
                Common.Data.DataAccesser da = new Common.Data.DataAccesser();
                Connection connection = da.getConnection();
                //  Read data from a table
                String sql = "Select * from schedule1";
                Statement stmt = connection.createStatement();
                ResultSet rs = stmt.executeQuery( sql );
                ResultSetMetaData md = rs.getMetaData();
                int columns = md.getColumnCount();
                //  Get column names
                for (int i = 1; i <= columns; i++)
                    columnNames.addElement( md.getColumnName(i) );
                //  Get row data
                while (rs.next())
                    Vector row = new Vector(columns);
                    for (int i = 1; i <= columns; i++)
                        row.addElement( rs.getObject(i) );
                    data.addElement( row );
                rs.close();
                stmt.close();
            catch(Exception e)
                System.out.println( e );
            //  Create table with database data
            JTable table = new JTable(data, columnNames);
            jPanel2.setLayout(new java.awt.BorderLayout());
            jPanel2.add(table, BorderLayout.CENTER);I know its a bit messy, wat im tryin to do is add the table to the panel. the rows are showing perfectly but the column names do not show! Can anyone help?

    1) Please ask Swing questions in the Swing forum.
    2) Don't forget to specifically make the table header display. You do this by adding the table header to the jpanel in the borderlayout NORTH position, and you get the table header by calling getTableHeader. Have a look here for instance:
    http://forum.java.sun.com/thread.jspa?threadID=5235339&tstart=0

  • JTable column is not displaying in JPanel

    I created a JTable with single column like
    New JTable(celldata, columndata);
    and added it into JPanel. In this case only table cells are displying but not the column. If I use JScrollPane, table column name does displyed.
    Any help would be appreciated.
    Thanks
    Satheesh

    That is the correct behaviour of the components. A table won't display the column headers unless it's in a JScrollPane. Though you can get the headers from the table yourself manually using getTableHeader and put them where you want.

  • JTable Column Names Not Displaying

    Hi there
    I create a JTable by passing the JTable constructor my custom TableModel which extends AbstractTableModel.
    For column names I have a String[] containing the column names in my custom TavleModel and have coded the TableModel methods accordingly.
    For some reason when I run the code the table is displayed, but the column names are not!?!
    Any advance is appreciated!

    Sorted!
    After looking at sample code in the JTable tutorial, it seems the table likes/needs to be added to a JScrollPane, as once I did this the column headings started appearing.
    e.g. JScrollPane scrollPane = new JScrollPane(table);

  • JTable column headers not showing up

    I have a JTable inside a JScrollPane which, in turn, is inside a JTabbedPane.
    I created a TableModel which extends AbstractTableModel as per the java Swing Tutorial examples.
    In that model is an Object[][] object for the data called rowData, and all the data displays in the table perfectly.
    I also have a String[] object called columnNames to define the column headers. ..the column names are coded directly into the object.
    i.e.: String[] columnNames = {"John", "Janet", "Jamie", "Jennifer"};But the column names don't display at all.....all I get in the column headers is 'A', 'B', 'C', etc.
    I need to know either
    1)how to set this up correctly in the first place or
    2)how I can reset the columns manually.
    I have tried adding the table 2 ways..as follows...but neither one gets the headers right:
    JScrollPane jScrollPane = new javax.swing.JScrollPane(getTable());or
    JScrollPane jScrollPane.setViewportView(getTable());Note: getTable()..is where the new javax.swing.JTabel(new TableModel())stuff is done.
    thx, ESW

    You mentioned the you columnNames array. I suggest you declare it as static and accessible from within your custom table modelprivate static final String[] COLUMN_NAMES = {"John", "Janet", "Jamie", "Jennifer"};Then you override/implement the following methods in your TableModel :public String getColumnName(int column) {
         return COLUMN_NAMES[column];
    public int getColumnCount() {
         return COLUMN_NAMES.length;
    }That should do the trick.

  • JTable Column Headings not displaying

    Hi
    I have recently made a Jtable a node of a Jtree.
    My table shows (semi-correctly) and is editable.
    I can't seem to see the headings of each column. and the left hand border line of the table is missing.
    Anyone know why this is?? I presume that I cant resize my columns due to the fact I cant see the headings.
    Thanks
    mike

    If you don't want to put the table in a scrollpane you can put it on a JPanel too...but use the BorderLayout and add the table to the center and the tableheader to the North portion.

  • F2 key not working with custom JTable Column

    I have a custom JTable Column (which is a JPanel with a JTextfield and JButton). Everything works as expected, except when the user presses "F2" to start editing the custom column cell. When the user presses F2, the custom cell goes into editing mode, but I am unable to type anything in it.
    Below is the SSCCE.
    Steps to Reproduce problem:
    1) Run the Program
    2) Select any cell in first Column.
    3) Press "F2" and try to type into the cell. Can't type anything.
    package com.ns;
    import java.awt.BorderLayout;
    import java.awt.Component;
    import java.awt.Dimension;
    import java.awt.Point;
    import java.awt.Toolkit;
    import java.awt.event.ActionEvent;
    import java.awt.event.KeyEvent;
    import java.util.EventObject;
    import javax.swing.DefaultCellEditor;
    import javax.swing.JButton;
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.JTextField;
    import javax.swing.SwingUtilities;
    import javax.swing.UIManager;
    import javax.swing.WindowConstants;
    import javax.swing.table.DefaultTableModel;
    import javax.swing.table.TableCellRenderer;
    public class TextButtonCellFrame extends javax.swing.JFrame {
        // Variables declaration - do not modify                    
        private JTextField inputText;
        private JScrollPane jScrollPane1;
        private JPanel testPanel;
        private JTable testTable;
        // End of variables declaration                  
        public TextButtonCellFrame() {
            initComponents();
        @SuppressWarnings("unchecked")
        // <editor-fold defaultstate="collapsed" desc="Generated Code">                         
        private void initComponents() {
            testPanel = new JPanel();
            jScrollPane1 = new JScrollPane();
            testTable = new JTable();
            inputText = new JTextField();
            setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
            testTable.setModel(new DefaultTableModel(
                new Object [][] {
                    {null, null, null, null},
                    {null, null, null, null},
                    {null, null, null, null},
                    {null, null, null, null}
                new String [] {
                    "Title 1", "Title 2", "Title 3", "Title 4"
            testTable.setCellSelectionEnabled(true);
            testTable.setRowHeight(52);
            testTable.setSurrendersFocusOnKeystroke(true);
            testTable.getColumnModel().getColumn(0).setCellRenderer(new MyTableCellRenderer());
            testTable.getColumnModel().getColumn(0).setCellEditor(new MyTableCellEditor(new JTextField()));
            testTable.getColumnModel().getColumn(0).setPreferredWidth(200);
            jScrollPane1.setViewportView(testTable);
            testPanel.add(jScrollPane1);
            inputText.setPreferredSize(new Dimension(50, 20));
            testPanel.add(inputText);
            getContentPane().add(testPanel, BorderLayout.CENTER);
            Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
            setBounds((screenSize.width-576)/2, (screenSize.height-417)/2, 576, 417);
        }// </editor-fold>                       
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new TextButtonCellFrame().setVisible(true);
        public class MyTableCellRenderer extends JPanel implements TableCellRenderer {
            Point point;
            JButton button1 = new JButton("Test 1");
            JTextField txtField = new JTextField();
            public MyTableCellRenderer() {
                setLayout(new BorderLayout());
                this.add(button1, BorderLayout.EAST);
                this.add(txtField,BorderLayout.CENTER);
            public Component getTableCellRendererComponent(JTable table, Object value,
                    boolean isSelected, boolean hasFocus, int rowIndex, int vColIndex) {
                if (isSelected) {
                    txtField.setBackground(testTable.getSelectionBackground());
                    txtField.setBorder(UIManager.getBorder("Table.focusCellHighlightBorder"));
                else {
                    txtField.setBackground(testTable.getBackground());
                    txtField.setBorder(null);
                return this;
        public class MyTableCellEditor extends DefaultCellEditor {
            JPanel panel = new JPanel();
            JButton button1 = new JButton ("Test 1");
            JTextField txtField;
            MyTableCellEditor(JTextField txtField) {
                super (txtField);
                this.txtField = txtField;
                panel.setLayout(new BorderLayout());
                panel.add(button1, BorderLayout.EAST);
                panel.add(txtField,BorderLayout.CENTER);
            public void actionPerformed(ActionEvent e) {
                if (e.getSource() == button1)
                    JOptionPane.showMessageDialog(null, "Action One Successful");
            public Component getTableCellEditorComponent(JTable table, Object value,
                                        boolean isSelected, int row, int column) {
                return panel;
           public boolean isCellEditable(final EventObject anEvent) {
              if (anEvent instanceof KeyEvent) {
                 final KeyEvent keyEvent = (KeyEvent) anEvent;
                 SwingUtilities.invokeLater(new Runnable() {
                    public void run() {
                       if (!Character.isIdentifierIgnorable(keyEvent.getKeyChar())) {
                          txtField.setText(txtField.getText() + keyEvent.getKeyChar());
                       txtField.setCaretPosition(txtField.getText().length());
                       txtField.requestFocusInWindow();
                return super.isCellEditable(anEvent);
    }The code for isCellEditable(final EventObject anEvent) which is needed to edit the cell using keyboard was provided by DarrylBurke here
    regards,
    nirvan.

    The F2 key when pressed generates an action event (either JTable generates it or some other component). I am not sure how to handle the action event in the isCellEditable() method. Also, F(X) range of keys other than F2 dump some junk character in the JTextfield when pressed. I am now stuck at this point and don't know how handle F(X) range of keys.
    regards,
    nirvan.

  • Few values of report column do not display in report while applying filter

    Post Author: anuragg11
    CA Forum: WebIntelligence Reporting
    There are 6 drill filters applied on the report to filter out the report column data. Few values of the report are not displaying in the report when using drill filter. Same issue is with report filter too. If filters are removed then values are appearing in the report. We are using version BO XI R2 & Java runtime JRE 1.4v. It doesn't look issue is with Java version because only few specific data of the report column are not shown in the report when using filter on the data. Example: One of Report data column contains below values: 24.2, 26.9, 120.1, 230, 274.9, 275.8, 333.2 Report is displaying all these values when there is no filter on any data. But report doesn't display data when applying filter on 274.9 or 120.1 howver filter on other values 24.2, 26.9, 230, 275.8, 333.2 are working fine.

    Hello,
    I think i know what your problem is.
    Although in table view your 2 requests combine perfectly and show separate results in pivot view BI unfortunaterly adds them up.
    One work around would be to go in your criteria add in each request a dummy column. This can be obtained the following way:
    1. click on a column to add it in the criteria (it doesnt matter which one)
    2. go into the edit formula of that column
    3. delete the formula and in its place write 'Dummy Column 1'
    Do the same for the second request by adding a "Dummy Column 2'
    Now the Pivot Table should also show up correctly
    Let me know if it goes well or if you have any further questions,
    Kostis

  • Alert message in javascript if drop down in 1 column is blank and other column is not blank

    What I’m trying to do is have a java window alert pop up if the PNR column is blank and the BOM column is not blank on each row. I also put a cold fusion If statement around this javascript that the CN_Entry column in the Items table has to be an “N”. This code all actually works, but it only works on the row with the latest or newest item with an “N” in the CN_Entry column. I would like this to work on every row, so that if someone does this on any row, or multiple rows, this alert box will keep popping up until all the conditions are satisfied. What do I need to change to make this javascript work? Thanks.
    <cfif CN_Entry EQ "N">
    <SCRIPT LANGUAGE="JavaScript">
    <!-- Begin
    function verify() {
    var themessage = "Please enter ";
    if (EditItem.PNR_Approval_Initials#ItemID#.selectedIndex == 0 && EditItem.BOM_Approval_Initials#ItemID#.selectedIndex > 0)
    alert("You must enter some PNR initials for ECO #ECID_SPEC# Part Number: #Part_Number#");
    EditItem.PNR_Approval_Initials#ItemID#.focus();
    return (false);
    else
    document.EditItem.submit();
    //  End -->
    </script>
    </cfif>
    Andy

    The first thing you have to do is to remove the ColdFusion conditional logic.  ColdFusion runs on the server.  JS runs on the client.
    The next thing is to call the function from an event that happens on the web page.  form onsubmit seems like a good choice.

  • After deleting users they are not removed from portal30.wwsec_person

    I am building a customized script to carry on users self registration.
    the script is going great and user is created and i can log into portal
    successfully with this new created user.
    I relogin as portal administrator and delete this new user and now if i tried
    to list portal users I cant see the user.
    But when I try to rerun my script to recreate this user again it fails when I
    investigated I found that it fails because the entry of this user is removed
    from portal30_sso.wwsec_person while it still exists in portal30.wwsec_person
    so the script fails as there is duplicate in primary key.
    Is this a bug in portal 309 that when the user is deleted it is not removed
    from portal30.wwsec_person

    This is actually a combination of intended behavior/design and a bug.
    Let me first explain why there is a user in both the PORTAL30_SSO schema as well as the PORTAL30 schema.
    The definition of the user, that can log in, and defines the single sign-on account, is the user's entry in the
    WWSEC_PERSON$ table in the PORTAL30_SSO schema. The SSO server actually just uses a subset of the
    columns in this table -- those defined in the WWSSO_SSO_USER view.
    The same table exists in the PORTAL30 schema, because there is a lot of common infrastructure code
    shared by both applications (Login Server, and Portal). The Security and Session Management code
    is common, and this code includes the dependency on the WWSEC_PERSON$ table.
    Now, assuming that the code was independent (for the sake of argument), why do we still have an entry
    for the user in both schemas? As I mentioned earlier, the user entry in the SSO schema is the "master".
    The SSO server can have multiple partner applications connected to it. Indeed, on my.oracle.com, the
    login server there has at least 4 portals hooked up to it, and a few other non-Portal partner applications,
    such as Oracle Mobile.
    Each partner application may have a local user profile that it uses to store application specific attributes
    of the user. This is stuff that the Login Server is not interested in, and could in no way predetermine for
    all conceivable partner applications. So, it is not unreasonable for each partner application to also have
    a user record which stores additional attributes of the user (not related to user authentication), and which
    can be used to reference other user-related data. For example in the Portal, all the user's privileges
    and group memberships are tied to the Portal's user record (foreign key constraints). So, the Portal
    being just one partner application of the Login Server, it adhere's to this model and has a user entry
    in it's schema corresponding to the user entry in the Login Server.
    When a user logs on and accesses a partner application for the first time, the partner application (read Portal)
    is expected to automatically create a local profile entry for the user on demand. The Portal does this.
    In 3.0.9 and previous versions, to delete a user, you need to delete the user in the Login Server AND the Portal.
    The only way to do this is to first delete the user in the Login Server, using the User Portlet.
    Then type the user's name into the Portal User Profile portlet (they won't be in the LOV anymore since
    you just deleted them from the login server), and click Edit, then Reset To Defaults (this means delete).
    You will then get a User Not Found error, since the page is trying to go back to show the details about this user.
    (All this has been fixed in 9.0.2 v2, by the way).

  • How to catch selected text in JTable Column

    Hi there,
    I am learning JTable. Need help for How to get the selected text from the JTable Column which is set to be editable.
    for example in JTextFiled you have method on getSelectedText(), is there any method for tracking the selected text.
    Thanks in advance
    Minal

    Here's an example of the model I used in my JTable. Not the "getValueAt" method & "getRecordAt" method. You will have to have a Record object - but it only contains the attributes of an inserted record (with appropriate getters & setters). Hope this helps.
    public class FileModel5 extends AbstractTableModel
    public boolean isEditable = false;
    protected static int NUM_COLUMNS = 3;
    // initialize number of rows to start out with ...
    protected static int START_NUM_ROWS = 0;
    protected int nextEmptyRow = 0;
    protected int numRows = 0;
    static final public String file = "File";
    static final public String mailName = "Mail Id";
    static final public String postName = "Post Office Id";
    static final public String columnNames[] = {"File", "Mail Id", "Post Office Id"};
    // List of data
    protected Vector data = null;
    public FileModel5()
    data = new Vector();
    public boolean isCellEditable(int rowIndex, int columnIndex)
    // The 2nd & 3rd column or Value field is editable
    if(isEditable)
    if(columnIndex > 0)
    return true;
    return false;
    * 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();
    * Retrieves number of columns
    public synchronized int getColumnCount()
    return NUM_COLUMNS;
    * Get a column name
    public String getColumnName(int col)
    return columnNames[col];
    * Retrieves number of records
    public synchronized int getRowCount()
    if (numRows < START_NUM_ROWS)
    return START_NUM_ROWS;
    else
    return numRows;
    * Returns cell information of a record at location row,column
    public synchronized Object getValueAt(int row, int column)
    try
    FileRecord5 p = (FileRecord5)data.elementAt(row);
    switch (column)
    case 0:
    return (String)p.file;
    case 1:
    return (String)p.mailName;
    case 2:
    return (String)p.postName;
    catch (Exception e)
    return "";
    public void setValueAt(Object aValue, int row, int column)
    FileRecord5 arow = (FileRecord5)data.elementAt(row);
    arow.setElementAt((String)aValue, column);
    fireTableCellUpdated(row, column);
    * Returns information of an entire record at location row
    public synchronized FileRecord5 getRecordAt(int row) throws Exception
    try
    return (FileRecord5)data.elementAt(row);
    catch (Exception e)
    throw new Exception("Record not found");
    * Used to add or update a record
    * @param tableRecord
    public synchronized void updateRecord(FileRecord5 tableRecord)
    String file = tableRecord.file;
    FileRecord5 p = null;
    int index = -1;
    boolean found = false;
    boolean addedRow = false;
    int i = 0;
    while (!found && (i < nextEmptyRow))
    p = (FileRecord5)data.elementAt(i);
    if (p.file.equals(file))
    found = true;
    index = i;
    } else
    i++;
    if (found)
    { //update
    data.setElementAt(tableRecord, index);
    else
    if (numRows <= nextEmptyRow)
    //add a row
    numRows++;
    addedRow = true;
    index = nextEmptyRow;
    data.addElement(tableRecord);
    //Notify listeners that the data changed.
    if (addedRow)
    nextEmptyRow++;
    fireTableRowsInserted(index, index);
    else
    fireTableRowsUpdated(index, index);
    * Used to delete a record
    public synchronized void deleteRecord(String file)
    FileRecord5 p = null;
    int index = -1;
    boolean found = false;
    int i = 0;
    while (!found && (i < nextEmptyRow))
    p = (FileRecord5)data.elementAt(i);
    if (p.file.equals(file))
    found = true;
    index = i;
    } else
    i++;
    if (found)
    data.removeElementAt(i);
    nextEmptyRow--;
    numRows--;
    fireTableRowsDeleted(START_NUM_ROWS, numRows);
    * Clears all records
    public synchronized void clear()
    int oldNumRows = numRows;
    numRows = START_NUM_ROWS;
    data.removeAllElements();
    nextEmptyRow = 0;
    if (oldNumRows > START_NUM_ROWS)
    fireTableRowsDeleted(START_NUM_ROWS, oldNumRows - 1);
    fireTableRowsUpdated(0, START_NUM_ROWS - 1);
    * Loads the values into the combo box within the table for mail id
    public void setUpMailColumn(JTable mapTable, ArrayList mailList)
    TableColumn col = mapTable.getColumnModel().getColumn(1);
    javax.swing.JComboBox comboMail = new javax.swing.JComboBox();
    int s = mailList.size();
    for(int i=0; i<s; i++)
    comboMail.addItem(mailList.get(i));
    col.setCellEditor(new DefaultCellEditor(comboMail));
    //Set up tool tips.
    DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
    renderer.setToolTipText("Click for mail Id list");
    col.setCellRenderer(renderer);
    //Set up tool tip for the mailName column header.
    TableCellRenderer headerRenderer = col.getHeaderRenderer();
    if (headerRenderer instanceof DefaultTableCellRenderer)
    ((DefaultTableCellRenderer)headerRenderer).setToolTipText(
    "Click the Mail Id to see a list of choices");
    * Loads the values into the combo box within the table for post office id
    public void setUpPostColumn(JTable mapTable, ArrayList postList)
    TableColumn col = mapTable.getColumnModel().getColumn(2);
    javax.swing.JComboBox combo = new javax.swing.JComboBox();
    int s = postList.size();
    for(int i=0; i<s; i++)
    combo.addItem(postList.get(i));
    col.setCellEditor(new DefaultCellEditor(combo));
    //Set up tool tips.
    DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
    renderer.setToolTipText("Click for post office Id list");
    col.setCellRenderer(renderer);
    //Set up tool tip for the mailName column header.
    TableCellRenderer headerRenderer = col.getHeaderRenderer();
    if (headerRenderer instanceof DefaultTableCellRenderer)
    ((DefaultTableCellRenderer)headerRenderer).setToolTipText(
    "Click the Post Office Id to see a list of choices");
    }

  • Output Column does not have a matching source column in the schema

    Hi Everyone,
                           Can you please help me in this. Already an ETL is loading the data from AS400 TO SQL server. I need to add a new
    column. In the Source (OLEDB source) am pulling the data from AS400 using ADO.NET connection manager.
    New column is added in AS400. To bring the new column from AS400, I added column name in the query in OLEDB source. Test connection is good. In the Source editor, when I click on preview it gives me the values of the new column and if I click on build
    new query also it gives me values for the new column.
    After mapping the columns and refreshing the data in OLEDB destination, I don't see any errors or warnings.
    But when I start executing the package it throws me the below error.
     Error: The output column  (4659) does not have a matching source column in the schema.
    [SSIS.Pipeline] Error: "component  (2861)" failed validation and returned validation status "VS_NEEDSNEWMETADATA".
    I need suggestion on this.
    Thanks
    Veeresh

    Hi Veeresh,
    As per my understanding, this error happens when the OLE DB Source component cannot find the corresponding source column in the database table. Possible reason is the the column name in the external database table has changed or
    the column has been removed.
    To verify this issue, please go to the Advanced Editor for OLE DB Source Input and Output Properties tab to see the External columns and Output columns. To fix it, please refresh the data or recreate the Source.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • Table with dynamic columns is not being correctly refreshed

    I am building a table view with maps of data according to the last section of this tutorial:
    http://docs.oracle.com/javafx/2/ui_controls/table-view.htm
    In my problem I need to add and delete rows and columns at runtime. Everything is working fine with the exception of the visualization of the table when all its rows and columns have been deleted programatically. I expect to see the default "Empty Table" message, and in fact I see it, but the last columns (before the columns were deleted) are still there.
    Is there a way to force the table to repaint itself when all its columns have been removed ?
    Just in case I tried with both:
    tableView.layout();
    tableView.requestLayout();But it did not help.
    Edited by: se**** on May 23, 2013 3:04 PM

    Ok, at least I know that it is not my fault :) thanks !
    I tried with JavaFX8 a couple of days ago for another issue and the layout of application was broken. The size of many fonts were arbitrarily changed (no idea wy), a button I added to the right of a tab header (for creating new tabs at runtime) was mislocated, and the layout components were reduced to a fraction of their size when I move the application to my retine display monitor (someone else told me it was a bug that it is going to be solved soon). In summary, I will try again with JavaFX 8 in a couple of months when hopefully it is going to be more stable.

Maybe you are looking for

  • ITunes 10.6.1, resize window problem

    I know this has been asked before, for earlier versions of iTunes, but I can't find a satisfactory answer. Just changed my 24" white iMac (running SL) to a 21.5" iMac with Lion and iTunes 10.6.1. With iTunes, it seems I have only 2 options: Full scre

  • Header Pricing Condition - distribution to items question

    we have a condition (Freight) that is a surcharge entered as a percentage.  If the condition is 10%, we would like the calcualtion 10% of net value at the header level and then distribute the amount to the line items distributed by weight or volume.

  • TextEdit's Unicode broken?

    I know it sounds ridiculous, but a year ago, when I saved TextEdit documents as Unicode (UTF-8) text files (.txt), everything worked fine. And when using non-Roman fonts everything looked great. Plus, I could drop those text files in my iPod's Notes

  • Mouse errors

    I am having issues with my trackpad on a 2007 Macbook Pro 15". Was working fine until the other day - maybe my kids hit a keyboard combination. Anyway it's driving me nuts. When I single click a file on the desktop it activates it and moves it around

  • CRM 2013: Updating a Entity form from WFA plugin

    I have created a dll (build with C# code) and registered it through  the plugin registration tool on to my CRM. I am  using this plugin (dll) as the first step of an Work Flow (Process) for "on create". The plugin is getting value for one of the fiel