Save JTable and JCheckBox content

I've made a JTable(working with DefaultTableModel). One of the columns contains JCheckBoxes. I would like to save the data into a file, but i don't know how to manage this.
Is there somebody who knows a possible solution?!
Thx

I have code which can save the jtable, but i doesn't work with jcheckboxes in the jtable
CODE:
public void saveTable()
if (table.getRowCount() == 0)
System.out.println("Empty list");
return;
try
FileOutputStream fos = new FileOutputStream("data.dat");
Writer out = new OutputStreamWriter(fos,"UTF8");
for (int i = 0; i < table.getRowCount(); i++)
for(int j=0; j < table.getColumnCount(); j++)
String value = (String)table.getValueAt(i,j) + "|";
out.write(value);
out.close();
catch(IOException e)
System.out.println("Error IOException " + e.getMessage());
}

Similar Messages

  • JTable with JCheckbox problems

    Ok so I have a couple of questions. I have a JTable with a column represented as a checkbox.
    1. If I put the checkbox column as the first in the table, the rest of the cells are blank/null. Any idea what the reason is?
    2. What is the best workaround to having draggable columns, meaning icons/checkboxes don't render if you move the columns around?
    3. Does anyone have some links to good resources on JTables and things like custom components in them. I have googled but don't get many good links so would appreciate any help
    Code snippet as follows:
    public class ClobberTableCellRenderer implements TableCellRenderer
    private JPanel renderPanel = new JPanel(new BorderLayout());
    private JLabel renderLbl = new JLabel("");
    private JCheckBox checked = new JCheckBox();
    private Icon successIcon;
    private Icon errorIcon;
    public Component getTableCellRendererComponent(JTable table,
    Object value,
    boolean isSelected,
    boolean hasFocus,
    int row,
    int column)
    String columnName = table.getModel().getColumnName(column);
    if (value == null)
    return null;
    else if ("Status".equals(columnName) && "ok".equals(value))
    renderLbl.setIcon(successIcon);
    renderLbl.setText("");
    renderPanel.remove(checked);
    else if ("Status".equals(columnName) && "error".equals(value))
    renderLbl.setIcon(errorIcon);
    renderLbl.setText("");
    renderPanel.remove(checked);
    else if ("Active".equals(columnName))
    renderLbl.setText("");
    renderPanel.add(checked);
    renderPanel.setBackground(Color.white);
    else
    renderLbl.setHorizontalAlignment(value instanceof Date || value instanceof Number ? JLabel.RIGHT : JLabel.LEFT);
    renderLbl.setIcon(null);
    renderLbl.setText(value instanceof Date ? df.format((Date)value) : value.toString());
    renderLbl.setToolTipText(null);
    renderPanel.setToolTipText(null);
    renderPanel.remove(checked);
    if (isSelected)
    renderPanel.setBackground((Color)UIManager.getDefaults().get("Table.selectionBackground"));
    else
    renderPanel.setBackground((Color)UIManager.getDefaults().get("Table.background"));
    return renderPanel;
    }

    Hi :) I have also worked on JTables and JCheckBoxes before. This article
    helped me a lot: http://www-128.ibm.com/developerworks/java/library/j-jtable/

  • HT5527 I have had my storage reduced once already.  In the process they removed my "Save" mailbox and all its contents.  I do notcare about contents so much as starting a new Save box.  How?  (OS X 10.7.5)

    My iCloud storage is being reduced.  I have already had it reduced once.  In the process they removed my "Save" mailbox and all its contents.  (One would think that that would be the last thing they removed.  But they took that and the "Trash" mailbox, yet left several thousand old and read messages which were in my "Inbox".)  I do not expect to get the "Save" contents back, but I would like to restore the "Save" mailbox, so that I can start from scratch saving msgs in it again.  But I cannot figure out how to do that.  When I go to "Mailbox" on the top line (between View and Message) and select New Mailbox I get a dialog box in which I can name a new mailbox.  When I type Save, for the name of the new Mailbox I get a response; "The mailbox 'Save" already exists."  But I cannot find it.
    Thanks,  Bill Burner

    Option 1
    Back Up and try rebuild the library: hold down the command and option (or alt) keys while launching iPhoto. Use the resulting dialogue to rebuild. Choose to Repair Database. If that doesn't help, then try again, this time using Rebuild Database.
    If that fails:
    Option 2
    Download iPhoto Library Manager and use its rebuild function. (In Library Manager it's the FIle -> Rebuild command)
    This will create an entirely new library. It will then copy (or try to) your photos and all the associated metadata and versions to this new Library, and arrange it as close as it can to what you had in the damaged Library. It does this based on information it finds in the iPhoto sharing mechanism - but that means that things not shared won't be there, so no slideshows, books or calendars, for instance - but it should get all your events, albums and keywords, faces and places back.
    Because this process creates an entirely new library and leaves your old one untouched, it is non-destructive, and if you're not happy with the results you can simply return to your old one. 
    Regards
    TD 

  • My iPhone is FULL, no memory left for photos. If I move all my photos off my iPhone, will the 'ALBUMS' and their content (pics) be blown away ? Also, what is the BEST way to clear/save photos off my iPhone ? PC, ITunes, some other app ?

    My iPhone is FULL, no memory left for photos. If I move all my photos off my iPhone, will the 'ALBUMS' and their content (pics) be blown away ? Also, what is the BEST way to clear/save photos off my iPhone ? PC, ITunes, some other app ?

    I use an app called FileApp to transfer photos to my PC - I can then selectively delete photos from my iPhone and still have them on my PC - just download the app to your iPhone and follow the instructions for the accompanying program for your PC - then use your iPhone cable to connect - iTunes will also start up so just close it and you will see the iPhone storage as a drive - go the DCIM folder and open the device folder and you will see your photos.

  • I to use iphoto library manager to save corrupted iphoto and each time it saves some and the first time it brings up iphoto, iphone goes into "not responding" mode.  Using mac book pro, iphoto 9.5.1, and maverick 10.9.2.

    I've had issues with my iPhoto "not responding" and as a result I am attempting to save my photos to an external hard drive using iPhoto library Manager but each time I start the program it saves some, and then when it starts iPhoto, iPhoto then goes into not responding mode. Using mac book pro, iphoto 9.5.1, and maverick 10.9.2. I have completed all of the photo library first aid steps several times, but it makes no difference, iphoto eventually goes to "not responding."  Initial issues started with Time Machine back ups stopping because of iphoto. Thanks......

    Do you have a back up?
    If you're just trying to recover the photos you can do that much more simply:
    Go to your Pictures Folder and find the iPhoto Library there. Right (or Control-) Click on the icon and select 'Show Package Contents'. A finder window will open with the Library exposed.
    Look there for a Folder called 'Originals' or 'Masters'. (varies according to the version of iPhoto)
    Your photos are inside - these are the originals as imported from your camera.

  • Dreamweaver CS6 cloud - I can no longer use "Save As'  and the Application manager won't open.

    I always open an old page and use "save all"  to save it,  then "save as"  and change the name of the page to what I want the new page to be the rewrite the new content. It doesn't open a box for name change any longer. Also The application manager does not open at all.
    What to do to fix this?
    Roger

    Hi Roger,
    Can you close other applications open on your computer, and retry before the experts here suggest other solutions?
    Thanks,
    Preran

  • RH 8 crashes on Save All when copying content between two open projects

    [Win XP SP2] I've submitted a bug report for this issue. Note that RH does seem to save the content as it's dying (a very noble act, I must say), but the behavior is bothersome.
    ******BUG******
    With two instances of RH8 running (dual monitors), and copying content from one project to another, the instance receiving the added content crashes when you click Save All.
    Steps:
    1. Open RH 1
    2. Open RH 2
    3. Copy content in RH 2 and paste it into RH 1
    4. In RH 1, click Save All
    Results: RH 1 crashes (RH 2 does not)
    Expected Result: RH 1 does not crash

    I would try another one with each of these documents.
    Create a new document with 2 pages.
    Name the master pages so, that their names are not conflicting with neither of these 2 document’s masters.
    Delete every style in that empty document, also any swatch
    No drag the pages of the first document into such an empty document.
    Do the same step 1 to 4 with the second document in a NEW empty document.
    Now you have 2 new documents. Take care that no conflicting master names appear.
    In each of these documents create in each style panel a folder and drag all used styles in that folder.
    Save both documents
    Try again to insert the pages of both documents.
    Otherwise, it this does not work out, could you send me via private message the files or a link. I would check it with a Debugging Version of InDesign (InDesign DEV) I can use to find errors.

  • I have created a folder that I can now Save to and view in Photoshop (CS4) but cannot find in spotlight or any other way on my mac. PLEASE HELP!!

    I use Photoshop CS4, I do not think this problem is related to PS... I am not exactly sure what happened. I created a folder on desktop, think I changed name of it. Now it is not on desktop. I know the exact name of the folder and have tried doing a spotlight search and cannot locate it AS WELL as searching for a file by name EXACT as name is. However if I go into Photoshop I can open or "save as" and open the folder and save as a "recent location" and the folder and its contents are found no problem... however cannot see the pathway to know where the folder is located on my mac.. PLEASE HELP!!! Been using photoshop and my mac for MANY years and NEVER had a problem like this... I have a photo client awaiting their pictures to be burned on a cd and mailed to them!!
    THANK YOU!!
    Laurie

    Try this. Open one of your files. The window that contains your picture is named at the top. Command click on the name and you'll see the entire path starting with its name and then moving to the folder, the folder it is contained in, etc all the way to down to the hard drive volume name. This should tell you where to find the folder.

  • My contacts and calendar content have disappeared. How do I get them back?

    My contacts and calendar content has completely disappeared from my phone, but it is all still on my MacBook. Any ideas on how to get them back to my phone? I'm thinking something went wrong with my iCloud.

    It's hard to say what would cause that but I doubt you are doing anything wrong.  They only way you could intentionally make you contacts or calendars disappear is if you either turn off iCloud syinc for contacts and calendars in Settings>iCloud or signed out of your account.
    If it continues to happen, you might want to completely sign out of your account, then sign back in.  To do this, you would want to start by saving any photo stream photos that you want to keep to your camera roll (unless already there) by opening your my photo stream album, tapping Select, tapping the photos, tap the share icon (box with upward facing arrow), then tapping Save to Camera Roll.  Then go to Settings>iCloud, tap Delete Account, provide your password and choose Delete from My iPhone when prompted (your data will still be in iCloud), then sign back in.

  • 5 doc type and 2 content repository

    Hi
    I have 5 document type in DMS and 2 content repository.
    Doc type QWE, ASD, JKL - pdf files must be in content repository X
    Doc type ABC, BNM -  pdf files must be in content repository Y
    How should I proceed to do this?
    Regards

    Hi,
    if I understood your latest information correctly your request is that the files are stored automatically to storage category if you add a file to a document info record and save it. To achieve this behavior the first important setting here are the flags "Checkin" and "Checkin required" which are already set for the used
    document status.
    This first setting enables the automatic start of the checkin process. But to have a specific storage category choosen for an original workstation application, you have to do another setting and create a profile in your system in the customizing under
    - Cross Application Components
        - Document Management System
            - General Data
                - Define profile
    For this profile pleasee add your workstation applications under "Determine definitions for applications". Here you can maintain the default storage category for this application in field 'Storage cat.'. Since this profile is created assign it to all your users directly. Then if an user adds a new original file and chooses a workstation application the system should take the storage category automatically from the profile.
    Another proposal would be to use the BADI DOCUMENT_STORAGE01 which should offer also methods to control which storage category should be taken for which workstation application. I hope that this information could be useful for you. To set up this scenario in detail I would recommend you to contact your local consulting organization too which will help you in realizing a solution that meets all your requirements.
    Best regards,
    Christoph

  • Hi, I would like to know how can I recover a document from pages that I didn't save anytime and instead of clicking the button save I clicked the delete button at the end. Is there any way to recover it?

    Hi, I would like to know how can I recover a document from pages that I didn't save anytime and instead of saving the doc I clicked the delete button. Is there any way to recover it?

    Regardless of application, the first step that I take is to save and name the current document — even if it has no content yet. With Pages, this good habit enables autosave. As you add content, your document revision history is restorable via the File Revert To menu. The delete key has the same document foreboding as only teaching a pet raven to speak "Nevermore."

  • Is it possible to recover a deleted folder and its contents as opposed to an individual file?

    When I turned on my computer today, a folder located on my desktop is no longer there.  Astounded I could have accidentally deleted it, the folder having been trashed is the only illogical logical possibility I can think of - and is a first for me in my 30 years of Mac use.  My father is in the process of dying and the folder contains all the information coming to me on the subject.  The last backup of this folder is about a week old and much has been added since for which I've no record.
    Not having a master document or table of contents listing what was in the folder leaving me unable to search for and recover individual files/documents by name, my question is this:  Is it possible to recover a "FOLDER", and its contents after that folder has been moved from the desktop to the trash, the trash emptied, and the computer having been shut down?
    If anyone has any ideas of how to recover anything about what items that folder contained, I'd really appreciate whatever thoughts you might have.
    Thanks in advance -
    The computer this folder is missing from is a early 2008 MacPro, running 10.7.5.

    I'm not sure what you can do beyond trying to restrict the types of files you search for. These apps normally have ways to select the file types or to add example files. That allows them to carve out only those types, but you still may end up with GB's of data, especially if the types are somewhat generic. I don't know of any tools that can undo changes to the disk catalog over time.
    I guess you could also search for specific text if you know that these files contained something that is 'almost unique'. Spotlight can do that, or grep, egrep are command line tools that may help ask if you want to go that route, they may help you gather lists to move files around to whittle them down.
    Sorry I can't think of a way around this it's a difficult task at a difficult time. Good luck with it, ask if you think we could help.
    I do wonder if Apples 'Versions' could help?
    OS X Lion: About Auto Save and Versions - Apple Support
    @Tony T1, do you know how to restore files from that system? I think it is part of Time Machine, but the copies are saved locally.
    It is not entirely clear how it works (at least from my memory of Lion) with regards to how you could get files back in this situation. The database should be at the base of the disk in a hidden folder ".DocumentRevisions-V100", but I don't think you can just pull files out of there. Personally I'd consider making a full disk backup before you attempt to restore files. Then you could try the 'Enter Time Machine' UI to see if it can browse back to the older Desktop.

  • FMX2 - earmarked funds  and SAP Content server

    Hello all,
    Need a help to find solution for the following issue.
    Customer would like to have earmarked funds   attachments  save on SAP Content server u201Eout of databaseu201C.
    So in detail, customer run FMX2 change document and from menu choose Environment > Object list > create attachments
    Attachment is save on DB, so question is how to change this to save attachments on SAP Content server. And what is need to set up at transaction OAC3 to which Object type and document type is for attachment at FMX2.
    SAP Content server is up and running also we have repositories u2013 this is not issue. Issue is only to fill in data at OAC3 with correct object type and doc. Type.
    Thanks for any help
    Peter

    Hi, it's better to ask from basis team. In table maintained link between Document type and 'place' where you want to save your documents, it's not FM customizing

  • When I change the row heights in a spreadsheet, then save, close, and open it, the row heights are back to default. How can I prevent this?

    One of our reports has lots of text in some rows. I import the data, adjust the row width and ask the text to wrap, which automatically sets the row height appropriately. When I save, close, and open that spreadsheet, the width is still the same and Wrap is still selected, but the rows are only one line high, which means that the report is unreadable and a serious pain to make readable.
    I can save it as a PDF, but I'd rather be able to use the Numbers format or Excel and be confident that my recipients can read it.

    Hi k,
    I'm unable to reproduce the described behaviour.
    The document containing the table below has a combination of row heights set manually using teh stepper in the Table Inspector (both 0.76" labeled rows), set manually by dragging the row boundary between row reference tabs (labeled 1/13"), and set automatically by Numbers to fit the content of the remaining cells.
    Content in the rows with names beginning E, F, G or H wraps automatically to form two rows in the cell. The rest are forced into two lines using a carriage return character.
    All maiintained their row heights through two Saves and reopenings.
    Regards,
    Barry

  • Save jtable in xml

    hi,
    i have an application that create multiple jtable, and i want when the user click to save, the jtable will be save in a xml file.
    i know that's possible but i dont know how to do that.
    someone have an example or a good tutorial to teach how to do that????
    i will be very gratefull to any kind of help.

    Have u tried something like:
    For row major xml document:
    String xml = "";
    for(int i = 0; i < jt.getRowCount(); i++)
             xml+= "<row number = '" + i + "'>\n";
             for(int j = 0; j < jt.getColCount(); j++)
                      xml+= "       <col number = '" + j + "'>" + jt.getValueAt(i,j) + "</col>";
              xml += "</row>
    //Then save xml to file.For column major XML document just swap the two loops round.
    Hope this helps

Maybe you are looking for