Where TableModel stores the columns ordering?

Hi,
In my JTable i allow columns reordering (setReorderingAllowed(true)).
I want to write to a file the new order of the columns and the next time i will run the program, i want to have the columns displayed just like in the file.
Any ideas?
Thanks,
TS

I serialized a trivial TableColumnModel - 8800 bytes! If this is a desktop app, this is the part package java.util.prefs was born to play! A quick example:
import java.awt.*;
import java.awt.event.*;
import java.util.prefs.*;
import javax.swing.*;
import javax.swing.table.*;
public class TablePrefs {
    private static TableModel model = new DefaultTableModel(
        new String[][] {{"a0", "b0", "c0", "d0"}, {"a1", "b1", "c1", "d1"}},
        new String[] {"COLUMN A", "COLUMN B", "COLUMN C", "COLUMN D"});
    public static void main(String[] args) {
        final JTable table = restoreSettings();
        JFrame f = new JFrame("TablePrefs");
        f.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent evt) {
                try {
                    saveSettings(table);
                } catch (BackingStoreException e) {
                    System.err.println(e.getMessage());
                }  finally {
                    System.exit(0);
        f.getContentPane().add(new JScrollPane(table));
        f.pack();
        f.show();
    public static void saveSettings(JTable table) throws BackingStoreException {
        TableColumnModel tcm = table.getColumnModel();
        Preferences node = Preferences.userNodeForPackage(TablePrefs.class);
        for(int i=0, count = tcm.getColumnCount(); i<count; ++i)
            node.putInt("modelIndex"+i, tcm.getColumn(i).getModelIndex());
        node.flush();
    public static JTable restoreSettings() {
         JTable table = new JTable(model);
         TableColumnModel oldtcm = table.getColumnModel();
         TableColumnModel newtcm = new DefaultTableColumnModel();
         int count = oldtcm.getColumnCount();
         Preferences node = Preferences.userNodeForPackage(TablePrefs.class);
         for(int i=0; i<count; ++i) {
            int index = node.getInt("modelIndex"+i, -1);
            if (index == -1)
                break;
            newtcm.addColumn(oldtcm.getColumn(index));
         if (newtcm.getColumnCount() == count)
             table.setColumnModel(newtcm);
         return table;
}Go ahead and run the code! The second execution should retrieve the column ordering from the backing store.

Similar Messages

  • Where u have to store the purchase order?

    suppose the customer creates purchase order directly, where u have to store the purchase order?

    Hi,
    Since End customer's Purchase order is external document for SAP system,there is no provision as such to store the purchase order directly into the system.
    But if the bussiness process requires this details then you can make use of sales document type for Inquiery (IN).In inquiery you can maintain the details received from the customers like customer code,Quantity,Material,Pricing etc.
    You can create the next cycle as sales order with reference to inquiery.
    Second advantage can be you can get in sales order document flow the reference of Customer's PO ( IN ) to keep track of the details for reporting purpose.
    Reward points if useful
    Regards,
    Amrish Purohit

  • How can i give a parameter to user to select the column order in runtime

    Select * from emp  ;
    in parameter form for i need to create a parameter so the user can select whatever the column order he required.
    where is should write the order by clause

    Hi,
    In Reports Use Lexical Parameter instead of Bind Parameter and write order by in After Param Form...
    Here you find more details...
    https://forums.oracle.com/thread/669325
    Hope this will solve your issue..
    Regards,
    Soofi

  • Where to store the attachments before sending a mail

    can any one help me
    when user clicks on attachfiles where to store the attachments before sending an email
    thanks in advance

    pengyou wrote:
    jschell wrote:
    pengyou wrote:
    However, if I just want store the html file in a file system for quich test purpose, how can I store the url and keep a link to the related file.Instead of storing the content in the database you instead store a file system location (either a path or a file url.)
    That file system location is where you store the content.Indeed, the file system location is where I store the content which I crawled from Internet. However, it is not the initial url from which I crawled this content. I would like to store the initial url of this content too. This is still a problem.No it isn't.
    You have two pieces of data: Url and content.
    If you want to store the content on the file system then your database table would have two columns: url and file_location.
    You then do the following
    1. Save the content to the file system. Derive a file path from that process.
    2. Write a record to the database consisting two data items : url and that file path.

  • Where to store the url of a webpage for indexing and searching?

    Dear Java gurus,
    We have a set of html files stroing in a file system. We can use Lucene to index those files with two fields "path" and "content ". Then using Lucene we can search and the result will be the relevant content and its path (path in the file system).
    As each of these html file is a real web page, we know its url in Internet too. However, I don’t know where to store this real url and let Lucene to index not only the path, content but also this url. If this is possible, then the search result will display the url also.
    Do you have any idea about this ?
    This is the last obstacle for us to develop a small Google like search engine. We have already a crawler that works well.
    Thanks for any suggestions.
    Pengyou

    pengyou wrote:
    jschell wrote:
    pengyou wrote:
    However, if I just want store the html file in a file system for quich test purpose, how can I store the url and keep a link to the related file.Instead of storing the content in the database you instead store a file system location (either a path or a file url.)
    That file system location is where you store the content.Indeed, the file system location is where I store the content which I crawled from Internet. However, it is not the initial url from which I crawled this content. I would like to store the initial url of this content too. This is still a problem.No it isn't.
    You have two pieces of data: Url and content.
    If you want to store the content on the file system then your database table would have two columns: url and file_location.
    You then do the following
    1. Save the content to the file system. Derive a file path from that process.
    2. Write a record to the database consisting two data items : url and that file path.

  • Set the column order in document library using power shell

    hi all,
     am looking for a power shell script which set the column order in the document  library, when i try to upload a  document.
     ie; i am  uploading a  doc to the doc lib. which has the below columns:
     columnA -   [choice field  - mandatory ]
     columnB -   [lookup field  - mandatory ]
     columnC -   [single line of text  - optional ]
     columnD -   [choice field  - optional ]
     columnE -   [choice field  - mandatory ]
    now when  the end user uploads a   document in my doc lib, i would like to see the mandatory columns takes up the top order and then optional fields.
     columnA
     columnB
     columnE
     columnC
     columnD
    so, is there any script, through which i can set the mandatory columns which will be coming in top and the optional fields as next order

    This is sample PowerShell code to reorder fields in a content type of a list.
    $web = Get-SPWeb http://aissp2013/sites/TestSite
    $list = $web.Lists["MyList"]
    $contentType = $list.ContentTypes | where {$_.Name –eq "MyTestCT"}
    $ctArray = "Title","ColumnA","ColumnB","ColumnD","ColumnC"
    $contentType.FieldLinks.Reorder($ctArray)
    $contentType.Update()
    Blog | SharePoint Learnings CodePlex Tools |
    Export Version History To Excel |
    Autocomplete Lookup Field

  • How to set the column order of a sealed column in a custom Content Type for the new item form NewDocSet.aspx?

    Dear SharePoint Developers,
    Please help.
    I need to know How to set the column order of a sealed column in a custom Content Type for the new item form NewDocSet.aspx?
    I think this is a "sealed column", whatever that is, which is  shown in SPD 2013 as a column of content type "document, folder, MyCustomContentType".
    I know when I set the column order in my custom Content Type settings page, it is correct.
    But, when I load the NewDocSet.aspx page, the column order that I set in the settings page is NOT used for this "sealed column" which is bad.
    Can you help?
    Please advise.
    Thanks.
    Mark Kamoski
    -- Mark Kamoski

    Hi,
    According to your post, my understanding is that you want to set the column order of a sealed column in a custom Content Type for the new item form NewDocSet.aspx.
    Per my knowledge, if you have Content Type management enabled for the list or library (if you see a list of content type with the option to add more), the display order of columns is set for each content type.
    Drill down into one of them and you'll see the option under the list of columns for that content type.
    To apply the column order in the NewDocSet.aspx page, you need to:
    Select Site Settings, under Site Collection Administration, click Content type publishing. In the Refresh All Published
    Content Types section, choose Refresh all published content types on next
    update.
    Run two timer jobs(Content Type Hub, Content Type Subscriber) in central admin(Central Administration--> Monitoring--> Review timer jobs).
    More information:
    http://sharepoint.stackexchange.com/questions/95028/content-types-not-refreshing-on-sp-online
    Best Regards,
    Linda Li
    Linda Li
    TechNet Community Support

  • How to change the column order in the DB?

    Hi all,
    For example,
         there is an employee database with the field names empno(1),empname(2), empphone(3), empaddress(4), empsal(5). the values in the brackets are the column order i.e., the order in which the column names are placed.
         I have the details of the employee records in a .txt file and i have to upload the file with the same column order with some delimiter. I done it but in future if any one have the details of the employee details with some other column order i.e., empaddress(1), empsal(5), empno(3), empname(4), empphone(5)
         how i can change the column order of the database ...
    Thanx in advance...
    Bye,

    how i can change the column order of the databaseYou don't. You specify the column order in you're insert.
    PreparedStatement pstmt = conn.prepareStatement ("insert into EMP (EMPNO, ENAME) values (?, ?)");
    pstmt.setInt (1, 1500);
    pstmt.setString (2, "A Name");
    pstmt.execute ();
    Steve.

  • How to get and set the column order in SharePoint list forms

    Hi,
    I want to read the column order of the SharePoint list forms in SharePoint 2003 sites using any of the available web services and need to set the same order
    in the newly created list in SharePoint 2010.
    I am able to read the fields from SharePoint 2003 and creating the list with same fields in SharePoint 2010, but the column order is not maintaining in
    list forms.
    Also, I need to created the views from 2003 site to 2010 site.
    Please help me...
    Thanks in advance...

    Hi,
    Please try to use the following code to programatically change the order.
    SPList list = web.Lists["Example List"];
    if (list.ContentTypes.Count > 0)
    SPContentType ct = list.ContentTypes[0];
    string[] names = {"Example_x0020_One", "Example_x0020_Two", "Example_x0020_Three"};
    ct.FieldLinks.Reorder(names);
    ct.Update();
    Here is a similar thread for your reference:
    https://social.technet.microsoft.com/Forums/en-US/ce66fd65-2882-4bda-8142-89e116d8b90f/how-to-set-the-order-of-the-fields-in-list-forms?forum=sharepointdevelopmentprevious
    Best Regards
    Dennis Guo
    TechNet Community Support

  • I have a formula where I want the columns to remain constant but I want the middle number to increase by 1.

    I have a formula,  where I want the columns to remain constant but I want the middle number to increase by 1. How do I do it? =SUMIF($F2:$F45,1,$H2:$H45)
    The first cell contains the correct formula with the columns highlighted. Autofill gives me a red triangle. The columns are no longer highlighted.
    I have done this in Excel. I will learn Numbers!
    Thank you.

    Hi,
    When posting formulas, as a courtesy, please select the formula in the entry bar, Copy, then Paste the formula into your message. This permits the reader to copy the formula directly from the page, paste it into the reply, and edit it there. When pasted as an image, that reader has to read the formula from the image and type it into the reply, increasing the probability of errors creeping in.
    =SUMIF(F2:F10,COLUMNA+1,H2:H10)
    The syntax error is in the part shown in bold. Here is the image of the similar formula from my reply above:
    With the syntax error corrected, your formula would read:
    =SUMIF(F2:F10,COLUMN()+1,H2:H10)
    Restated in English, the formula says:
    "calculate the SUM of all numbers in cells H2 to H10, where the value in the same row of column F is equal to the column number of this cell plus 3."
    In your image, this cell (the cell containing the formula) is C3. That's in column 3, so the value "COLUMN()+3" is 6. Considering the headers in your screen shot, that is probably not what you want to happen.
    NOTE: Your original formula (and mine, modeled on that original) used the $ operator to fix the Column values of the cell references, making them stay the same when the formula is filled right. Your description indicates you want to fill the formula down. Unless you attach the $ operator to the Row part of the cell references, the row value will change as the formula is filled down, producing an 'invalid reference' error when the referenced range extends beyond the bottom of the table.
    Change the range "$F2:$F45" in your original formula to read "F$2:F$45" (and make a similar change to the range in column H) to keep the range the same when the formula is filled down. You'll also need to use ROW()-n in place of COLUMN-n, as filled down. all copies of the formula will be in the same column.
    Regards,
    Barry

  • Where to store the servlet class files ?

    If, I store the class files for servlets under WEB-INF/classes folder,
              i get file not found exception while using WL 6.1 sp2. But, if i store
              the class file under DefaultWebApp folder, it works fine.
              Any help about where to store the class files for servlets would be
              great help.
              Thanks.
              hiren
              

    Copy Servlet in DefaultWebApp/Web-Inf/classes directory.
              Configure Servlet in web.xml deployment descriptor.
              <servlet>
              <servlet-name></servlet-name>
              <servlet-class></servlet-class>
              </servlet>
              <servlet>
              <servlet-name></servlet-name>
              <servlet-class></servlet-class>
              </servlet>
              <servlet-mapping>
              <servlet-name></servlet-name>
              <url-pattern></url-pattern>
              </servlet-mapping>
              hiren dossani wrote:
              > If, I store the class files for servlets under WEB-INF/classes folder,
              > i get file not found exception while using WL 6.1 sp2. But, if i store
              > the class file under DefaultWebApp folder, it works fine.
              > Any help about where to store the class files for servlets would be
              > great help.
              >
              > Thanks.
              >
              > --
              > hiren
              

  • Where to store the servlet classes

    can anyone tell me where to store the servlet classes(inside a package)in oracle9iAS used with oracle8i database ?
    Also how to deploy an ejb in oracle9iAS. should we have to use oracle8i deployment guide or any other procedure??
    thanks in advance

    Copy Servlet in DefaultWebApp/Web-Inf/classes directory.
              Configure Servlet in web.xml deployment descriptor.
              <servlet>
              <servlet-name></servlet-name>
              <servlet-class></servlet-class>
              </servlet>
              <servlet>
              <servlet-name></servlet-name>
              <servlet-class></servlet-class>
              </servlet>
              <servlet-mapping>
              <servlet-name></servlet-name>
              <url-pattern></url-pattern>
              </servlet-mapping>
              hiren dossani wrote:
              > If, I store the class files for servlets under WEB-INF/classes folder,
              > i get file not found exception while using WL 6.1 sp2. But, if i store
              > the class file under DefaultWebApp folder, it works fine.
              > Any help about where to store the class files for servlets would be
              > great help.
              >
              > Thanks.
              >
              > --
              > hiren
              

  • Where Firefox stores the FLV files in windows 7

    Where Firefox stores the FLV files in windows 7
    == This happened ==
    Not sure how often
    == Where Firefox stores the FLV files in windows 7

    FLV files played by the Flash plugin are usually streamed and not saved to the hard drive.
    They may be kept in the memory cache during the playing.
    Video DownloadHelper: https://addons.mozilla.org/firefox/addon/3006

  • How to restrict the columns order movement at runtime in 7.3

    Hi Experts
    We are using EP7.3 Portal.
    We have modified the  Cats table in a customized ESS Cats DC . We have added a another table
    say subTotals table (This table does not have header) to calculate the hours as per business requiremnt just below the cats table with proper allignment.
    Now at run time i.e when launched through Iview in the portal, the user can able to
    personalize the columns order of Cats Table (Moving columns from one place to other) by Right click on the
    table>User settings->other-->Re Arrange the columns
    We have 2 tables so moving the first table column order will effect the second table which displays the totals (This is readonly)
    Our requirement is we should not allow the user to change the column order at run time (At least we need to restrict 8 columns outof 13 to 14 columns)
    How can we restrict the columns order through code i.e by controlling the property if any
    Regards
    KALYAN

    nwa->configuration management->infrastructure  --->application modules
    filter the name column with "tcwddispwda"
    select the entry(should be only one after filter)
    select the "web dynpro properties" tab
    select the "default" in the table
    AllowUserPersonalization----->false

  • Where microsoft stores the information of each file? like .....

    I would like to know where microsoft stores the information about each file in my computer,
    because I want to search a specific folder in my computer that contains more than 400 files
    and stores the name of each file and its size and the modified date of it in an
    Excel sheet?
    Please, tell how to do it
    it's urgent

    Firstly the platform independance of Java is maintained (in part) by allowing the JVM to negotiate with the Operating System and the developer to command only the JVM.
    Secondly the Security Mangager of Java would not being functioning correctly if you were able to access arbitary memory in this way.
    Thirdly, do you have no compassion for Linux users?
    It is possible to conduct this search using the Java Core API
    Bamkin

Maybe you are looking for