JTable Help To add a column

Hi friends
I hava a problem:-
IN SHORT I WANT TO ADD A COLUMN TO THE JTABLE. Please read to understand the problem...
I made a class called clsViewUsers which implements AbstractTableModel. This class fetches data and this data is put in the JTable with the constructor JTable(javax.swing.table.TableModel dm).
Now I want to add a column to the table without disturbing the TableModel.
I tried JTable.addColumn(javax.swing.table.TableColumn aColumn).
I made TableColumn UserStatusColumn = new TableColumn();
This TableColumn class has a function called setCellRenderer(TableCellRenderer aRenderer). This function takes a TableCellRenderer.
I made a class which implements this TableCellRenderer. This class compiles well but when this returns the java.awt.Component class to setCellRenderer(TableCellRenderer aRenderer)(Function above). Then it gives compile error as setCellRenderer(javax.swing.table.TableCellRenderer) in javax.swing.table.TableColumn cannot be applied to (java.awt.Component).
IN SHORT I WANT TO ADD A COLUMN TO THE JTABLE.
Please help
Vishwajeet Wadhwa

You can use a vector called columNames to store the column names and create a method like
public void addColumn(String columnName) {
columnNames.add(columnName);
you can make your model implement an interface that has a method for adding columns like
public interface ChangeableColumn{
public void addColumn(String columnName);
and have some other object like a panel with a button hold a reference to the TableModel which implements the interface
somePanel.addChangeableColumnListener(ChangeableColumListener tablemodel){
this.columnListener = tablemodel;
and the panel can have a method called addColumn(String columnName){}
that will called the method in the interface which will be implemented in the model
something like that maybe

Similar Messages

  • Add new columns in result of Transaction ME2L

    Hello,
    My requirement is to add two fields from table EKPO (BEDNR and AFNAM) in the result of ME2L.
    Does anyone know how to proceed?
    Is there an exit which will enable me to do so?
    Thanks a lot for your help.

    Hi,
    Add new columns in result of Transaction ME2L
    Regarding on your problem. The below link will helps to you.
    Modifying ME2L, ME2M with out copying into Z program
    Regards,
    Sekhar

  • How to add one column in existing search help.

    Hi Folks,
    My quesion is
    How to add one column in existing search help and also Now search help on that field is not an explicit search help. It should be implement using check table.
    Shivam

    Hi,
    If you want to add a field in Elementary search help, get the search help name for the and go to change mode and add the field in it.
    If you want to add a field in collective search help, go to included search helps tab and a new search help name and add the fields to it.
    I think this should help you to certain extent.
    Regards,
    Kranthi
    Edited by: Kranthi on Jan 14, 2010 11:15 AM

  • Is there any option in JTable to add the column number

    Hi,
    I am using JTable to show some data read from database.
    I want to add the column number autometically.(Without by talking a variable and incrementing that by 1.After that add that to the first column.)
    I want just like a auto increment row number.
    Is there any option in JTable?
    Thanks

                        for(int i = 0; i < table.getRowCount(); i++){
                            table.setValueAt(i, i, 0);
                        }

  • Hi I'm a total novice, as you will see. But Iam trying to use template of an employee schedule but when I try to add extra columns it does not add the preset formula with it, so it works out total hours and total pay?   If any one can help please.

    Hi I'm a total novice, as you will see. But Iam trying to use template of an employee schedule but when I try to add extra columns it does not add the preset formula with it, so it works out total hours and total pay?   If any one can help please before I throw it through the window!

    Grum12 wrote:
    Hi I'm a total novice, as you will see. But Iam trying to use template of an employee schedule but when I try to add extra columns it does not add the preset formula with it, so it works out total hours and total pay?   If any one can help please before I throw it through the window!
    Hi Grum,
    If the formulas aren't filling to the new column, you must have changed something in the template since you first opened it. Numbers is rather fussy about filling row content in columns as they are added. Only rows with the same expression in every Body Column will fill when a column is added. Just as an experiment, start a new Employee Schedule document from the Template Chooser and then add a column by clicking the Add Column handle in the upper right corner of the table. If that works, as it should, then think about what might have changed in your working document to disconnect that feature. Maybe we can figure it out together.
    Jerry

  • JTable + add a column

    hey all!!
    i have posted this post
    http://forum.java.sun.com/thread.jspa?threadID=5218799
    previously and as you can read there everything worked out ok.
    well now i have another, similar problem. now i know how to dispaly boolean values, in a table, as a check box. what i would like to do now is to select from database lets say
    first name, last name show the names in a table and then add a column what would be again a check box and the header would say 'delete?'. if user ticks the check box then on a button press i would get and delete the data that is marked as to be deleted.
    i have worked out how to add a clumn, set the header value but now i do not know how to get the check box in there. the advice i got in the previous post can be used for data that si being extracted from a database and check box can be show with getColumnClass() method. but how to go about showing a check box in a column that has been added to already existing ResultSet??
    anybody any suggestions, thoughts,links to tuts, or sample code??
    thanks
    v.v

    The advice you already got is pretty good, you do need to override getColumnClass() and return Boolean.class for the column which needs the checkbox.
    You have two options really.
    1. If the table model was written by you, adding a column should be fairly easy, you just need to modify all the methods which take a column index and appropriately change them.
    2. If the table model was written by someone else you still have an option, in which you decorate their table model, resulting in a table model with one more column.
    #2 would look something like...
        public class CustomTableModel implements TableModel {
            private TableModel inner;
            private int myColIndex;
            private int myColCount;
            private BitSet deleteFlags;
            public CustomTableModel(TableModel inner) {
                this.inner = inner;
                myColIndex = inner.getColumnCount();
                myColCount = myColIndex + 1;
                deleteFlags = new BitSet();
            public Class<?> getColumnClass(int columnIndex) {
                if (columnIndex == myColIndex) {
                    return Boolean.class;
                } else {
                    return inner.getColumnClass(columnIndex);
            public int getColumnCount() {
                return myColCount;
            public String getColumnName(int columnIndex) {
                if (columnIndex == myColIndex) {
                    return "Delete?";
                } else {
                    return inner.getColumnName(columnIndex);
            public int getRowCount() {
                return inner.getRowCount();
            public Object getValueAt(int rowIndex, int columnIndex) {
                if (columnIndex == myColIndex) {
                    return deleteFlags.get(rowIndex);
                } else {
                    return inner.getValueAt(rowIndex, columnIndex);
            public boolean isCellEditable(int rowIndex, int columnIndex) {
                if (columnIndex == myColIndex) {
                    return true;
                } else {
                    return inner.isCellEditable(rowIndex, columnIndex);
            public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
                if (columnIndex == myColIndex) {
                    deleteFlags.set(rowIndex, (Boolean) aValue);
                } else {
                    inner.setValueAt(aValue, rowIndex, columnIndex);
            public void addTableModelListener(TableModelListener l) {
                inner.addTableModelListener(l);
            public void removeTableModelListener(TableModelListener l) {
                inner.removeTableModelListener(l);
        }This would work some of the way but notably if the underlying model changes, this model needs to find out and change itself. That would take longer to write, this was just whipped up in a minute, heh.

  • Add Two Column in report ,Download and Delete

    Hi Friends,
    i have one item File Browser to use browse :P1_file_browser and i have create a Report
    My Table Is
    CREATE TABLE  "ARM_DOC_CER"
       (     "ID" NUMBER,
         "NAME" VARCHAR2(500),
         "MIME_TYPE" CLOB,
         "BLOB_CONTENT" BLOB,
         "SUBJECT" VARCHAR2(500)
    i jus want to add two column in my report
    1--Download
    2--Delete
    When i click on download then download file and when i click on delete then delete corresponding file.
    How can i do this.
    Thanks                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    Hi,
    You can use concat function or also '||' to combine two columns.
    1. with concat-
    concat("D4 Product"."P01 Product","D4 Product"."P02 Product Type")
    2. With '||' operator
    "D4 Product"."P01 Product" || '-'||"D4 Product"."P02 Product Type"
    (Remove '-' if not required)
    This should resolve. Hope this helps
    Regards
    MuRam

  • How to add a column in table control

    Hi ,
       Can any one tell me how to add a column in table control? My requirement is to add two columns ( custom fields ) into table control ( It is a standard program). I have added the column in the table and also in the table control. But when I am running the standard program, The newly added column is not there. But I have added in the perticular screen. Change is not reflected.
       Can anyone help me on this please.
    Thanks in advance.
    Regards,
    Lakshmi.

    Hi,
    Ensure the following :
    1. After adjusting the database, you`ll have to use the database utility and activate the table.
    2. If you have changed the standard screen, in tcode se80 -- right click on the program and click activate all. This activates all objects related to that program.
    Now execute the program.
    Reward if helpful.
    Regards

  • How to add a column that shows the difference of two metrics columns?

    I created a pivot table with two metrics columns. One metrics column has the aggregation rule of 'Min', the other has 'Max'. Now I want to add a column to show the difference of these two metrics for each row. Is this possible? How to do it? Thank you in advance.

    Use TimeStampdiff:
    TIMESTAMPDIFF(SQL_TSI_HOUR, MIN(xxxx), MAX(xxx))
    It's in the help file if you need more help.
    regards
    Alex

  • How can I add a column to show the website (web site) of an rss feed?

    I've got a lot of rss feeds coming into thunderbird. I organized some into folders, but also have a folder for several rss feeds as they adress the same topics and I prefer not to browse through 25 separate folders. However, the sender doesn't always make it clear which blog it's from, so I'd like to add a column which shows the website of the rss feed. (sender is often: [email protected], and there are different writers for a single blog who themselve have their own blog as well, so can't sort on sender name either).
    When opening an rss feed, it displays in the header: web site (with the space) and then the web adress. This is what I'd like to be able to see in my columns.
    I didn't see an option yet to customize columns, nor did I find an addon that does this.
    Does anyone know a solution?

    Thanks, that seems to work. I'm struggling to place the lightbox at the top of the page however - when I click the trigger I want the menu image to display anchored to the top of the page, but there's always a gap as it centers the image. Help is appreciated!

  • Add new column in PO Schedule line.

    -Currently Container# and Port is stored in table EKET
    -Add new columns in PO schedule line items and show the above two fields
    Please help me in this.
    How to add above two fields in standard transactions ME21n/Me22n/Me23n
    The answer is User Exit.
    The next question is how to find,write,configure an user exit.

    .

  • Add new column in RFUMSV00 program

    Hi,
    I am new in abap. I have requirment to add new column in VAT report. I have copy RFUMSV00 program to  'Z'  program and want to add new column in 'Z' program. The column is BSEG-ZNUOR(Assignment).How can i add a column in report and how to retrive data from BSEG table, If any one have code like this requirment , please give me some idea about this.
    Thanks in advance.
    Regards,
    Sourav

    you need to read program carefully first possible than do debug.than find the exact location where system ALV generates here you need to add your field.
    May be i it helps you.
    search with term in mention prg ASSIGN gt_alv TO <gt_alv>.    you will get idea where you need to add your own field
    Edited by: Amit Gujargoud on Aug 27, 2008 9:44 AM

  • How to add a column in report painter

    Hello
    i have a profit centre report where i have the profit centre group name in the header and i want to move it to column.
    could you please let me know how to do this?
    Thanks

    HI  Pradeep,
    Goto the transaction code (Change Report) GR32.
    Give you library name and report name
    And click on the column (application tool bar or F7) button then place the curser on the screen where you want column (please note you have to keep curser on the header section u2013Red column text) right click and insert element. Then you select formula as selection element  and enter. You will get the enter formula box. Then you can type your formula and continue. This will add new column to the report.
    How to enter formula: you can see the formula components in that id and description.
    Id is columns that are present and description indicates explanation of that column.
    Enter formula according your requirement.
    Examples:
    Enter formula screen:
    ID :    des
    X001  amount
    X002  pt000
    X003  test
    1. Enter formula as: ( X001 u2013 X002)
    The above formula is for fist column u2013 second column.
    2. ( ( X001 u2013 X002) / X003) * 100
    First column u2013 second column and devide by third column after that multiple with 100.
    Hope this will help you
    Regards
    Manohar

  • How to add new column in Report ME2L

    Dear Sir,
    We are using ME2L for various purposes . In the ME2L report we need to add 2 new columns i.e Item Delivery Date and WBS Element .
    Although in the standard ME2L report , after the basic list generation , there have been provided 2 icons for getting the report displayed  with either WBS Element or with Delivery Date .  It means we can not get both the column Delivery Date and WBS Element  available simultaneously in the standard ME2L report .
    We request you to kindly guide us as how can we add these column in the ME2L report pl .  We are on ECC-6.0 and not having enhancement package 4.0 .
    Kindly help us pl .
    Regards
    Sonia Agarwal

    HI  Pradeep,
    Goto the transaction code (Change Report) GR32.
    Give you library name and report name
    And click on the column (application tool bar or F7) button then place the curser on the screen where you want column (please note you have to keep curser on the header section u2013Red column text) right click and insert element. Then you select formula as selection element  and enter. You will get the enter formula box. Then you can type your formula and continue. This will add new column to the report.
    How to enter formula: you can see the formula components in that id and description.
    Id is columns that are present and description indicates explanation of that column.
    Enter formula according your requirement.
    Examples:
    Enter formula screen:
    ID :    des
    X001  amount
    X002  pt000
    X003  test
    1. Enter formula as: ( X001 u2013 X002)
    The above formula is for fist column u2013 second column.
    2. ( ( X001 u2013 X002) / X003) * 100
    First column u2013 second column and devide by third column after that multiple with 100.
    Hope this will help you
    Regards
    Manohar

  • Query to add a column in between existing cols of a table?

    HI All,
    I have two questions.
    1. Query to add a column in between existing cols of a table? (not at the end. This is view of an order of output fields in a report)
    2. How do I swap the contents of two columns in a table. Suppose in a table tab there are 2 cols , col1,col2 populated with some data.
    I need a query(probably) to swap the col1 and col2 values . NOT AS A RESULT SET, BUT IT NEEDS TO GET CHANGED IN THE TABLE.
    Please help !

    > 1. Query to add a column in between existing cols of
    a table? (not at the end. This is view of an order of
    output fields in a report)
    Not really sensible ito DBMS - it does not care how you want to view the data. The sequence and formats of columns are what you/the application need to specify in the SQL's projection clause.
    Also keep in mind to achieve this, the DBMS will need to rewrite the entire table to fit this new column in-between existing columns. This is not the best of ideas.
    The projection of rows is dealt with SQL statements - not with the physical storage implementation.
    > 2. How do I swap the contents of two columns in a
    table. Suppose in a table tab there are 2 cols ,
    col1,col2 populated with some data.
    I need a query(probably) to swap the col1 and col2
    values . NOT AS A RESULT SET, BUT IT NEEDS TO GET
    CHANGED IN THE TABLE.
    This seems to work:
    SQL> create table foo_tab( c1 varchar2(10), c2 varchar2(10) );
    Table created.
    SQL> insert into foo_tab select TO_CHAR(rownum), TO_CHAR(object_id) from user_objects where rownum < 11;
    10 rows created.
    SQL> commit;
    Commit complete.
    SQL> select * from foo_tab;
    C1 C2
    1 55816
    2 55817
    3 55818
    4 55721
    5 105357
    6 105358
    7 105359
    8 105360
    9 105361
    10 60222
    10 rows selected.
    SQL> update foo_tab set c1=c2, c2=c1;
    10 rows updated.
    SQL> select * from foo_tab;
    C1 C2
    55816 1
    55817 2
    55818 3
    55721 4
    105357 5
    105358 6
    105359 7
    105360 8
    105361 9
    60222 10
    10 rows selected.
    SQL>

Maybe you are looking for

  • I cannot get Item over 50MB  unlocked on my Ipad. It won't turn off to unfreeze it either.

    I have an icon that states, This item is Over 50MB in the middle of the screen. There is an OK button underneath. When I press OK nothing happens.  I cannot turn off the IPAD since the red slider will not work either.  The icon has remained on the sc

  • Attachments in Mails from iPad not conform to RFC2046

    Hello Community, Mails which were sent from iPad / iPhone and have attachments have the following technical structure: Headerfield Content-Type is multipart/alternative; --Apple-Mail-6--139698084 / Content-Type: text/plain;       <Text> --Apple-Mail-

  • Getting IP Profile Increased Quicker?

    I have read on various forums that resetting your router 10 times in an hour restarts the 10 day training period. Is this true? Also: apparently turning off all your equipment off for 20 minutes resets the IP profile. Is this true? And finally: I hav

  • Structure for OM

    Hi , I want to know that like there is a common structure for an Employees Personnel Administration infotypes 'PRELP' wherein I can check that for each employee which Infotypes exist and I can update that likewise I want to know that is there also a

  • Screen Saver on Stations' Logon Screen

    Hi, I am wondering if it is possible to deactivate the screen saver that comes up on the stations' logon screens when it is left idle for 30seconds? Thank you.