Inserting a column into JTable

I can insert a column at the end, and then move it to the position i want it. When i have done this and print out the headers from the columns in the column model, then from index 0 up to (say) 6 are as i want them, with the new column at index 4.
However, when i add a new column again, then the previously added column has an index of 6 and so isn't displayed in the position i want it.
I'm using the moveColumn method as I have found people saying to use, it's just it doesn't seem to stick!
Any ideas?

Adding a new column to a DefaultTableModel fires a special TableModelEvent. Because of that the JTable reinitializes its TableColumnModel and any column movements are undone.
You can call "setAutoCreateColumnsFromModel(false)" on the table but then you must update the TableColumnModel manually. The best solution is to build a table model with all necessary columns and to remove all TableColumn-Objekts from the TableColumnModel which should not be visible at first; adding TableColumn objects later wont alter the positions of the other columns.

Similar Messages

  • How to insert rows & columns into a jTable???

    helloo there...
    How to insert rows & columns into a jtable???
    your reply is greatly appreciated....
    -=samer=-

    Yes!thanks...
    But what i want is how to set the number of rows and the number of columns...and i don't know how to setColumns and rows....any idea?
    the user will input number of rows and columns in a jtextfield....
    Please rply...

  • Problem while inserting new Column in JTable

    Hi,
    I am facing Problem while inserting new Column in JTable.
    I have a JTable with one inherited ColumnModel class.
    When I am adding the column and moving towards the corresponding location, it moves successfully.
    but if I am adding another column or making any changes to table column structure the table retains the defualtcolumn structure.
    please help me to solve this..
    Regards
    Ranjith.........

    Maybe this example will help:
    http://forum.java.sun.com/thread.jspa?forumID=57&threadID=579527

  • Inserting multiple columns into database using dbtool set

    I have  a labVIEW program that is currenly simulating voltage and a current signal using the DAQ Assistant. I'm using the database connectivity toolset. I am currently able to insert one signal into the database converted to a float(I can insert both into the same column as bianary but it needs to be stored as a usable format and in seperate columns.)
    The problem I am having is at the DB Tools Insert Data block. I have the connection, dbTable, error code, and create table boolean being passed into it. Where I am a little lost is how to set the columns I want to store the multiple signals into.
    If someone could break that part down for me that would be great. In short, I want to store voltage(channel0) and current(channel1) from the DAQ Assistant into their own respective columns in the db.
    Message Edited by DonPoulson on 07-10-2007 11:04 AM

    Don,
    This particular forum is specific to TestStand, not LabVIEW or Multifunction DAQ. You may have a better chance at responses by posting to either of those forums rather than here.
    Brandon Vasquez | Software Engineer | Integration Services | National Instruments

  • Insert single column into oracle table

    i have a table t1 in whcih only one column is there
    Create table t1
    a number);now i need to load this column from a excel sheet.
    it have many rows and many column but need only corresponding column.
    please suggeest any way apart from external table and sql laoder.
    thanks

    No problem if you have thousands of rows.
    Say the value you want to insert is in column A of your excel file.
    In column B use the following formula:
    =CONCATENATE("insert into t1 values (";A1;");")And copy this formula to all other rows.
    Then select all the B column, copy it and paste it in a notepad file.
    Call the file as you want, for example c:\ins.sql
    open sqlplus and run
    SQL> @c:\ins.sqlAt the end don't forget to commit...
    Max
    [My Italian Oracle blog|http://oracleitalia.wordpress.com/2010/01/10/crittografia-in-plsql-utilizzando-dbms_crypto/]

  • Insert 3 columns into winSQL

    I have an excel spreadsheet that has 3 columns and I need
    those three
    columns inserted into a Win SQL table that has more than 3
    columns.
    I know how to export the Excel file to get a comma delimited
    or other
    compatible formats, I just don't know what the insert
    statement would
    look like in order to get it into the SQL database using
    query analyzer.
    I've done something similar to this but I lost the notes I
    had for doing
    this.
    Also, I need one of the fields to be added into another
    table. It would
    be cool to be able to do both at the same time but doing one
    table at a
    time is no problem either.
    Thanks for the help...

    What server language are you using?
    Paul Whitham
    Certified Dreamweaver MX2004 Professional
    Adobe Community Expert - Dreamweaver
    Valleybiz Internet Design
    www.valleybiz.net
    "Lee" <[email protected]> wrote in message
    news:emeq37$rj0$[email protected]..
    >I have an excel spreadsheet that has 3 columns and I need
    those three
    >columns inserted into a Win SQL table that has more than
    3 columns.
    >
    > I know how to export the Excel file to get a comma
    delimited or other
    > compatible formats, I just don't know what the insert
    statement would look
    > like in order to get it into the SQL database using
    query analyzer.
    >
    > I've done something similar to this but I lost the notes
    I had for doing
    > this.
    >
    > Also, I need one of the fields to be added into another
    table. It would be
    > cool to be able to do both at the same time but doing
    one table at a time
    > is no problem either.
    >
    > Thanks for the help...

  • Inserting a column into the title of a graph

    Hi,
    I have a pie chart with a title. I also have a drop down column in the graph prompt area showing the months.
    I need the month value to show within the title, and for it to change when the user chooses another month
    from the drop down list.
    Any help would be really appreciated.
    Thanks,
    - Jenny

    Let's see if I can figure this out and type it up before the real GREP masters show up...
    \d{9} will find groups of nine digits, but what you actually need to do is find groups of five digits followed by groups of four digits.
    \d{5}\d{4}
    And you need to separate them into groups:
    (\d{5})(\d{4})
    so that in the Change field you can use "first found group" and "second found group":
    $1-$2

  • Insert column into shopping cart status screen

    Hi,
    I need to insert a column into the shopping cart status screen table control( search results).(BBPSC04).
    Can u pls let me know whether i can achieve this by adding an append structure or standard screen modification?
    Cheers
    Rajeev

    Hi,
       Instead of modifying the std structure,try modifying the corresponding template of the service.
    BR,
    Disha.
    Pls reward points for useful answers.

  • How can I copy and then insert a column in Numbers 09

    I have a column in a Table that I would like to copy and then insert this column into another existing table on the same sheet. I don't want to copy and paste this, but rather insert it between existing columns.
    Thanks
    Eric

    Thanks SG,
    I have reverted back to 09' because of the nonexistant functionality of 3.0. I tried the option method you mentioned and it doesn't seem to work in 09'. Have you tried it in this version.
    Eric
    PS 3.0 has beautiful interface, perhaps they will add some functionality someday.

  • Scroll Fix Column in JTable

    I have see a lots of examples of whow to create fix column into JTable.
    But all the examples have the same problems.
    When I wont to scroll over the fix column the vertical scroll bar of the no fix column dont move, so the no fix column dose not move and the fix columns and no fix columns aren?t alined.
    If sameone have same example, send it please !!!!
    Thanks !!!
    Pablo

    In a recent project I've had the same problem.
    After a long research at the Swing forum at java.sun.org and google I found out that
    1. Currently there is no proper Open Source solution
    2. All the postings at sun are good concepts, but far away from solutions
    3. The only (for me )acceptable commercial solution is the JCTable from Quest (formerly KGroup)
    Since I want to have full control over the source code of the table, I decided to collect all the tips from this forums and write my own table.
    Here is a first try:
    http://jroller.com/resources/kriede/CoolTable.java
    The main idea is to have two tables, one for the locked columns (= fixed columns = frozen columns) and one for the scrollable columns. With all the tips from this forum it was more or less a puzzle to make it work pretty.

  • Inserting a Column on a report

    How do I insert a column with fixed contents into a report? I currently have two columns on the report and I'm doing a Union so I need to insert a 3rd column with a fixed text based on the criteria. For example, the inserted column for the first section would say "AAAAAAA", the inserted column for the 2nd section would say "BBBBBBB", etc... How can this be done?

    Insert any column into your report and position it where you want your static text column to appear. Click the fx button to edit the column's formula and replace the entire column formula with your desired text enclosed in single quotes.
    'AAAAAAA'
    Mike L

  • Need to use vector to insert data into JTable?

    hi
    i'm trying to insert data from mssql 2000 into JTable. The number of columns are fixed, but the number of rows are not, since it will depend on how many data retrieved from the database.
    The documentation says that vector class implements a growable array of objects, and I've seen some examples using vector such as from http://forum.java.sun.com/thread.jspa?forumID=57&threadID=238597 .
    I would like to know, in my case, do i need to set my column and row to use vector? or should i only set rows to use vector ? (since the row size will vary, while the column size will stick to 6).

    Because your JTable operation will be done on a table model, the selection of the initial data
    structure for the model is almost non-issue. In other words, whatever will do.
    See the javadoc for the DefaultTableModel class, which you will eventually use, especially the
    construcotr part.

  • URGENT--inserting into JTable

    Hi
    i'm trying to insert data retrieved from the database into JTable
    i have seen some code examples on TableModel on this site but
    getting confused.Can anybody give me a full code example.
    Ashish

    you can take a look at the following link:
    http://forum.java.sun.com/thread.jsp?forum=57&thread=357504
    I published my code for a dynamic table that supports adding/removing columns.

  • Error inserting a row into a table with identity column using cfgrid on change

    I got an error on trying to insert a row into a table with identity column using cfgrid on change see below
    also i would like to use cfstoreproc instead of cfquery but which argument i need to pass and how to use it usually i use stored procedure
    update table (xxx,xxx,xxx)
    values (uu,uuu,uu)
         My component
    <!--- Edit a Media Type  --->
        <cffunction name="cfn_MediaType_Update" access="remote">
            <cfargument name="gridaction" type="string" required="yes">
            <cfargument name="gridrow" type="struct" required="yes">
            <cfargument name="gridchanged" type="struct" required="yes">
            <!--- Local variables --->
            <cfset var colname="">
            <cfset var value="">
            <!--- Process gridaction --->
            <cfswitch expression="#ARGUMENTS.gridaction#">
                <!--- Process updates --->
                <cfcase value="U">
                    <!--- Get column name and value --->
                    <cfset colname=StructKeyList(ARGUMENTS.gridchanged)>
                    <cfset value=ARGUMENTS.gridchanged[colname]>
                    <!--- Perform actual update --->
                    <cfquery datasource="#application.dsn#">
                    UPDATE SP.MediaType
                    SET #colname# = '#value#'
                    WHERE MediaTypeID = #ARGUMENTS.gridrow.MediaTypeID#
                    </cfquery>
                </cfcase>
                <!--- Process deletes --->
                <cfcase value="D">
                    <!--- Perform actual delete --->
                    <cfquery datasource="#application.dsn#">
                    update SP.MediaType
                    set Deleted=1
                    WHERE MediaTypeID = #ARGUMENTS.gridrow.MediaTypeID#
                    </cfquery>
                </cfcase>
                <cfcase value="I">
                    <!--- Get column name and value --->
                    <cfset colname=StructKeyList(ARGUMENTS.gridchanged)>
                    <cfset value=ARGUMENTS.gridchanged[colname]>
                    <!--- Perform actual update --->
                   <cfquery datasource="#application.dsn#">
                    insert into  SP.MediaType (#colname#)
                    Values ('#value#')              
                    </cfquery>
                </cfcase>
            </cfswitch>
        </cffunction>
    my table
    mediatype:
    mediatypeid primary key,identity
    mediatypename
    my code is
    <cfform method="post" name="GridExampleForm">
            <cfgrid format="html" name="grid_Tables2" pagesize="3"  selectmode="edit" width="800px" 
            delete="yes"
            insert="yes"
                  bind="cfc:sp3.testing.MediaType.cfn_MediaType_All
                                                                ({cfgridpage},{cfgridpagesize},{cfgridsortcolumn},{cfgridsortdirection})"
                  onchange="cfc:sp3.testing.MediaType.cfn_MediaType_Update({cfgridaction},
                                                {cfgridrow},
                                                {cfgridchanged})">
                <cfgridcolumn name="MediaTypeID" header="ID"  display="no"/>
                <cfgridcolumn name="MediaTypeName" header="Media Type" />
            </cfgrid>
    </cfform>
    on insert I get the following error message ajax logging error message
    http: Error invoking xxxxxxx/MediaType.cfc : Element '' is undefined in a CFML structure referenced as part of an expression.
    {"gridaction":"I","gridrow":{"MEDIATYPEID":"","MEDIATYPENAME":"uuuuuu","CFGRIDROWINDEX":4} ,"gridchanged":{}}
    Thanks

    Is this with the Travel database or another database?
    If it's another database then make sure your columns
    allow nulls. To check this in the Server Navigator, expand
    your DataSource down to the column.
    Select the column and view the Is Nullable property
    in the Property Sheet
    If still no luck, check out a tutorial, like Performing Inserts, ...
    http://developers.sun.com/prodtech/javatools/jscreator/learning/tutorials/index.jsp
    John

  • How can I insert a image into a BLOB column in a table?

    I am using forms6i against a 10gR2 database and I have one table with a BLOB column and I try to insert a image into this column. I get ORA-01461 error.
    The curious case is that in another table with a BLOB column it works very fine.
    What happens with the first table? How can I avoid the error?
    Thanks in advance.

    Hi hyue,
    Thanks for visiting Apple Support Communities.
    If you would like to add an image to a project in iMovie for iOS, see this article for helpful steps:
    iMovie for iOS (iPad): Add photos to a project
    http://support.apple.com/kb/PH3171
    All the best,
    Jeremy

Maybe you are looking for

  • How do I add a log file to posts? (NT)

    How do I add a log file to posts? Thanks,

  • Unknown error when merging files

    I have encountered an unknown error when trying to combine files into a single pdf.  It specifically states: "No PDF file was created because Acrobat encountered an unknown error."  This is unusual as just yesterday I was able to perform this task wi

  • What is causing FF6.02 to have VERY slow and incomplete page loads

    Every since I've upgraded to FF 5 [now running 6.02] on Win7, the browser loads extremely slowly on ALL pages and often [most of the time] just hangs and doesn't display all images. I can start Chrome, copy and paste the URL and have the full page co

  • N8 - Picture Browser Issue After Firmware Update

    Since I´ve updated to PR1.1 I have a lot of tearing and blurriness when I see my pics at max zoom in the phone´s own pic browser. Pics viewed in my PC are just fine. I´ve tried to reinstall the FW 2 times already, but the problem remains. Details fro

  • System recovery fails with C++ runtime error

    My Compaq CQ610-410US running Windows 7  is unusable. When using system recovery, either from CD's or Recovery drive, it fails with C++ runtime library program not found Contact HP Support. EIther way, Windows is loaded and system recovery screens ap