Simple question concerning "persisting JTable data?"

Hi fellow bloggers,
I couldn't find this info in the Sun JTable tutorial. The tutorial explains how to update a cell in a JTable, but it doesn't suggest a method for persisting the "row" once it has been modified. Furthermore, the JTable tutorial states the following in the leading summary:
"JTable does not contain or cache data; it is simply a view of your data."
Does this mean that the data structure which is used to populate the JTable must be updated on a row by row basis, as well as updating the JTable itself? Isn't there some way to select a row on the JTable, update the row of data, and then port the data in a row of cells to a completely separate data structure?
Thanks.

If you want your data cached or persistent, you do that in the TableModel. DefaultTableModel will already be persistent. What they mean in that quote is that whenever the JTable needs a value for cell it queries the TableModel for the value.
I'm not sure why you want/need/care to port the data in a completely separate data structure, but sure... you can do that. Create a class and feed the data into it however you please, that'll be that.

Similar Messages

  • Simple question - How to find date

    Hi Experts,
    I have a simple question on date. Suppose today is Jan 4, 2010. I have to find out Jan 1, 2007 using Java code.
    I have used following code. This code will work for 2010 and 2011 properly. However it won't work properly after Feb 28, 2012. Please see "dayInMillis*1096 " portion of code. Here 365365366 = 1096.
    How I can avoid this hard coding. Do we have any simple way to get Jan 1, 2007 even without using following code.
         Calendar calendar = Calendar.getInstance();
         int lastDate = calendar.getActualMaximum(Calendar.DATE);
         int firstDate = calendar.getActualMinimum(Calendar.DATE);
         int todayDate = calendar.get(Calendar.DATE);
         int dayofyear = calendar.get(Calendar.DAY_OF_YEAR);
         java.sql.Date currentdate = new java.sql.Date(System.currentTimeMillis());
         long dayInMillis = 1000 * 60 * 60 *24; //1 day
         wdContext.currentContextElement().setFromDate(new Date(System.currentTimeMillis() - dayInMillis*1096 - ((dayofyear-1)*dayInMillis)));
    Please help.
    Regards,
    Gary

    Hi Gary,
    I am not pretty much clear with your question, whatever i have understood, i have found a way to get the previous date given the current date.
    Below is the code for the same.
                           Calendar now = Calendar.getInstance();//Jan 4, 2010
           String nowDateStr = DateFormat.getDateInstance().format(now.getTime());
           System.out.println("date now : " +nowDateStr);
           now.add(Calendar.YEAR, -3);//2007
           now.add(Calendar.DATE, -3);//1st
           now.add(Calendar.MONTH, 0);//No change in month, Jan.
           String changedDateStr = DateFormat.getDateInstance().format(now.getTime());
           System.out.println("date changed : " +changedDateStr);

  • Simple question concerning internal harddisk replacement

    Hello out there,
    I'd like to replace my internal MacBook Pro 100 GByte SATA Harddisk with a 300 GByte SATA harddisk. The new harddisk is a FUJITSU Mobile MHX2300BT, specified with
    capacity: 300 GByte
    form factor: 2.5" internal
    interface: SATA-150
    rotating speed: 4200 rpm
    buffer: 8 MByte
    height: 12.5 mm
    My question is: can I use this harddisk in my MacBook Pro (especially concerning its height!)
    Regards from Germany
    Ansgar
    MacBook Pro 17", 2.16 GHz Core Duo   Mac OS X (10.4.9)   100 GByte SATA HD, 1 GByte RAM, 256 MByte VRAM

    Hi rvdparis,
    there is no more warranty on my MacBook Pro because I replaced the internal DVD DL-burner (MATSHITA UJ-846) with an older one which can read AND write DVD-RAMs.
    And I don't want to transport additional devices if I can have them in my MacBook Pro. So I just want to know if there is enough space inside the MacBook Pro to build in a 12.5 mm high 2.5" harddisk.
    Regards
    Ansgar
    MacBook Pro 17", 2.16 GHz Core Duo   Mac OS X (10.4.9)   100 GByte SATA HD, 1 GByte RAM, 256 MByte VRAM

  • Simple question concerning scrolling

    I am looking for information on how to create an image which lags somewhat behind the scroll on a webpage, very simliar to the candle at the bottom of this page: http://www.blizzard.com/diablo3/faq/
    If I only knew the name of this effect, I could search out a tutorial for it myself. However, of course, any more detailed advice or instruction would be appreciated.
    Thanks!

    I could be misunderstanding something here but it just looks to me that the candle is in a DIV with a higher z-index and the css that is positioning it has a little play(extra space). The little play is causing the bouncing effect when you scroll but as for the actual candle fickering that looks like a simple flash movie.

  • Questions concerning ST Simple Transformations

    I got some questions concerning Simple Transformations:
    1.) When editing a simple transformation, how to insert comments? In pure ABAP, a comment line must have as asterisk in the first column...
    2.) I use <tt:loop>...</tt:loop> and want to use the index of the currently processed entry, like SY-TABIX when implementing a "LOOP AT itab" in ABAP. Is there a way?
    Thanks for your answer, points will be rewared...
    -MIKE

    Hi Jack, please find some sample coding below that will solve your issue:
    <tt:cond check="not-initial(ref('E1EDL20.INCO1'))">
      <INCO1 tt:value-ref="E1EDL20.INCO1"/>
    </tt:cond>
    With the simple transformation tt cond statment you can make an XML tag optional. In below example during deserialisation xml tag <INCO1> will be skipped when not availabke in the xml and SAP data E1EDL20.INCO1 will not be filled by the transformation.
    Regards. Please give points when usefull !

  • Simple Question: How to search for a date value in SELECT

    Probabily a simple question, but in a SELECT statement, how do you do a search for a date value in the WHERE clause?
    example:
    Select * From Example
    Where date = 01/01/2001
    I know its not as simple as that, but what change has to occur to make it do what that example implies?
    Thanks In Advance.

    If you want to avoid the conversion part(to_date) you will need to specify the date in the format as ur nls date format.so the same query might not work if you change ur nls date format.
    so it is advisable to give it in general format.
    ie where date_col=to_date(01-01-2000,'dd-mm-yyyy')

  • Simple Question - Data Import

    Hi,
    i have a simple question. Is it wise to change our actual import scenarios for input data from systems out of sap to XI?
    Today we have the scenario that data from outer systems will send per ftp to a special directory. After that a report will transform the data into a batchinput. The btci will send per rfbibl into the system. Now we have a huge number of such reports. Will it now be better to change to XI, which we use perhaps for MDM?
    Xi could take the file from ftp-srever maps the fields an will send per bapi to sap.
    Is it a quite simple scenario or is batchinput still the better way.

    Hi,
    If you have a scenario where you have different file formats , which needs to be converted and then send to different systems based on some conditions , then suggested is XI usage.
    However, also if you already have XI installed and running for the MDM system , then you can think of routing all messages through XI.  It may make sense to use one system for all routing and data conversion puposes.
    Hope this view helps.
    Cheerio,
    Disha

  • Help with simple question.......

    This is a simple question but i can't seem to figure it out.
    For example i am using this code...
    feel free to run this code...
    When you run this you see the scrollbars with the Swing look (Bars look so nice)...
    I am using this same type of code in my other project with JBuilder 7 and I am getting the plain look of the scrollbars.
    Any suggestions will be greatly appreciated..
    =======================================================
    import javax.swing.JTable;
    import javax.swing.JScrollPane;
    import javax.swing.JPanel;
    import javax.swing.JFrame;
    import java.awt.*;
    import java.awt.event.*;
    public class SimpleTableDemo extends JFrame {
    private boolean DEBUG = true;
    public SimpleTableDemo() {
    super("SimpleTableDemo");
    Object[][] data = {
    {"Mary", "Campione",
    "Snowboarding", new Integer(5), new Boolean(false)},
    {"Alison", "Huml",
    "Rowing", new Integer(3), new Boolean(true)},
    {"Kathy", "Walrath",
    "Chasing toddlers", new Integer(2), new Boolean(false)},
    {"Mark", "Andrews",
    "Speed reading", new Integer(20), new Boolean(true)},
    {"Angela", "Lih",
    "Teaching high school", new Integer(4), new Boolean(false)}
    String[] columnNames = {"First Name",
    "Last Name",
    "Sport",
    "# of Years",
    "Vegetarian"};
    final JTable table = new JTable(data, columnNames);
    table.setPreferredScrollableViewportSize(new Dimension(500, 70));
    if (DEBUG) {
    table.addMouseListener(new MouseAdapter() {
    public void mouseClicked(MouseEvent e) {
    printDebugData(table);
    //Create the scroll pane and add the table to it.
    JScrollPane scrollPane = new JScrollPane(table);
    //Add the scroll pane to this window.
    getContentPane().add(scrollPane, BorderLayout.CENTER);
    addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
    System.exit(0);
    private void printDebugData(JTable table) {
    int numRows = table.getRowCount();
    int numCols = table.getColumnCount();
    javax.swing.table.TableModel model = table.getModel();
    System.out.println("Value of data: ");
    for (int i=0; i < numRows; i++) {
    System.out.print(" row " + i + ":");
    for (int j=0; j < numCols; j++) {
    System.out.print(" " + model.getValueAt(i, j));
    System.out.println();
    System.out.println("--------------------------");
    public static void main(String[] args) {
    SimpleTableDemo frame = new SimpleTableDemo();
    frame.pack();
    frame.setVisible(true);

    any help will get DUKE $$$$$$$$$$$$$$$$

  • A simple Question about % in CR Chart!

    Hi, I have another simple question.
    When i use SQL to storage data and wanna Crystal Report to display the data in chart using %
    which data type should i use?
    float or string?
    and I found when i use 0.12 as 12% in database , It could not display in Crystal Report line chart normally.
    What should I do??
    Please Help!!!
    Thank you VERY MUCH!!!

    If you have the datatype as string from your database then try adding the string field as a summary field in chart and select maximum instead of count and if you have them in number format then you can directly select the percentage in chart.
    Regards,
    Raghavendra

  • Two questions: Event on a Date Picker and Read Only on a full page?

    Hello,
    I make use of this very informative board to develop an application but i have been unable to find info on these two topics. Sorry if it has been already discussed extensively.
    Using HTMLDB 2.2 for now.
    =>First question:
    I have a date picker item with an event
    onChange="resaStatusChange();"
    in the HTML Form Element Attribute field.
    The event is triggerring if i put a new data in the field but does not trigger if i use the picker.
    Is it a standart behaviour? Is there a way to trigger the event when new data is provided through the date picker?
    => Second question:
    One page in my application has to be used either to only display information or as a mixed displaying/entering data sheet.
    When the context is appropriate to use the page as a simple display (testing both global authorization and data to be displayed), is there a way to put a read only attribute on the full page instead of putting the read only conditions through each and every item of the page?
    Sorry if the questions are not clear and apologize for what should be newbie questions.
    Any link or info will be appreciated.
    Regards,
    Daniel Gureghian

    Hi Daniel,
    I'm not sure about your first question, but I can hopefully give you a helpfull answer for your second one.
    I'm handling it this way:
    var elInput = document.getElementsByTagName('input');
    var elTextArea = document.getElementsByTagName('textarea');
    var elSelect = document.getElementsByTagName('select');
    for (i = 0; i < elInput.length; i++)
      setReadOnly(elInput, true);
    for (i = 0; i < elTextArea.length; i++)
    setReadOnly(elTextArea[i], true);
    for (i = 0; i < elSelect.length; i++)
    setReadOnly(elSelect[i], true);
    function setReadOnly(pThis, pRead)
         if (pThis && pRead)
              pThis.disabled = pRead;
              pThis.style.emptyCells = "show";
              pThis.style.color = "black";
              pThis.style.backgroundColor = "#DDDDDD";
         else if (pThis && !pRead)
              pThis.disabled = pRead;
              pThis.style.emptyCells = "show";
              pThis.style.color = "black";
              pThis.style.backgroundColor = "#FFFFFF";
    I never used it on a whole page, only for regions. So maybe you have to make some changes.
    chrissy

  • Is there a simple way to retrieve the data from a resultset using JavaBean?

    I have a result set from a select * from users where userid = xxx statement. However, at the moment I have had to hard code the remainder of the code to get the data from each column as I need the column name as well as its data.
    I had read somewhere using java beans and reflection it is easier. But i do not know know how.
    Is there a simple way to retrieve the data from a result set ?
    thanks in advance-
    kg

    Well, it is not really simple. But there are Open Source components to simplify it for you. See e.g http://www.must.de/Jacompe.htm - de.must.dataobj.DataObject and its subclasses. Feel free to contact me if you have any questions: [email protected]

  • JTable data back-up (re-visited)

    Hi!
    I need to persist the data in my jTable rows and columns. Right now I get and set them with java preferences with two x and y loops ... this works fine.
    but ..... is there a way to save to a file the jTable row and column data without first extracting the row and column data cell for cell?
    ie; to serialize only the cell data?

    Thanks!
    Is there an example code for me to look at? (didnt see much on Google so far)

  • A few simple questions from a new Iphone user

    Hi a few simple questions, just got an iphone 2g - 2nd hand so not really sure what to expect. Anyway I guess my first question is about mine sometimes being a little slow - when I look at contacts and sometimes when sending a txt it slows down/freezes a little - normal?
    Secondly Edge - I havent used it much but when I have its been painfully slow, is this normal - is it always really slow - cause I had read despite not being 3g Edge was actually pretty fast - what exactly is data roaming by the way? I mean I have been switched off as basically I dont wanna use the internet till next month when they change my contract to one I get unlimited access on - is that right?
    Im having a problems syncing videos to it - it just wont sync some but will others and Im not sure why - theyre same file type and they used to sync to my ipod touch but now they wont for some reason
    Cheers

    I have the origina iPhone.
    Downloaded 2.0, synced phone with everything UNchecked. Installed 2.0. Synced with all the options checked to reload my data. The iPhone has been great. Noticed a little lag when I opened contacts. Installed the new upgrade, and everything is back, no lag.
    Edge is Edge and nothing more. It is slow compared to a strong 3g signal. But is liveable most of the time. Heavy traffic can slow it down to barely usable.
    My four wheel drive club has a web site with a large photo section. I was standing out in the middle of parking lot in San Jose, Ca and showing a friend some photos. It opens up a page of small picts to choose from. Select a print and it enlarges, He was amazed at how fast they appeard. Especially given the quantity of photos.

  • A very very very simple question

    Hi guys,
    I have a very simple question and standard but I cant find anywhere...
    I have two dateTime variables, i need to calculate difference between this dates in days, thats it.
    I tried all functions and tried without success a Java Embed task but I couldnt retrieve this objects as java.util.Date so I couldnt calculate exactly the difference in days like this pure java code:
    (dataVencimento.getTime() - dataReferencia.getTime()) / 86400000L)
    can you help me this?

    Hi Jose
    Just see if these alternate approaches works. I know there may be lot like this and you may be lucky to find out simple out of box solution itself. If you want to solve this issue and move ahead, gives these approaches a shot.
    1. Create a very simple standalone WebService that takes 2 input date elements (can be of Date type or String type. If string type, convert to date in your java code). Create a simple operation like getDaysBetween(firstDate, secondDate). In the generated webservice impl class, use the java code apis (refer earlier link for usage), and get the difference. Return this value. NOW, invoke this WebService in your BPEL Process, and pass your 2 inputs (if the bpel payload elemetns are date object or string objects of date), and get output, and then use this output in your continuing bpel process.
    2. This approach, I did a long back. When we insert any expression using XPath, in that editor window on bottom right side, we see many categories and for each category we see list of functions we can use, like for String, we can use concat etc. I vaguely remember reading somewhere, that we can add our own custom functions also in this section. So explore this direction and see if you can add your own function and then use that fucntion with your 2 input dates.
    I have not given solution to your problem, but may be these directions can help you move ahead. Or something along these lines.
    Thanks
    Ravi Jegga

  • Tomcat 5.0.25 persisting session data by default ?!?

    This is, I imagine, a dumb question, but I can't quite figure out what is happening by looking at past postings.
    When I start Tomcat I get an error : "IOException while loading persisted sessions" because some classes we use are not serializable. That makes sense - we didn't design them to be serialized.
    I understand that Tomcat CAN try to persist session data across restarts. However, I do not want it to do this. I thought this was something we had to configure, but it looks like it happens by default (?)
    Anyway ... any advice about how to prevent this behavior, at least for our app, would be appreciated ... really puzzled ... !
    Thanks in advance for any help you can give !!
    ethan

    Well, thanks ... I have been there actually, but it only tells me how to set up the 'Experimental" Persistent Manager and not how to turn this off. Here is an interesting blurb from that site :
    <<<<<
    Whenver Catalina is shut down normally and restarted, or when an application reload is triggered, the standard Manager implementation will attempt to serialize all currently active sessions to a disk file located via the pathname attribute. All such saved sessions will then be deserialized and activated (assuming they have not expired in the mean time) when the application reload is completed.
    In order to successfully restore the state of session attributes, all such attributes MUST implement the java.io.Serializable interface. You MAY cause the Manager to enforce this restriction by including the <distributable> element in your web application deployment descriptor (/WEB-INF/web.xml).
    >>>>>>>
    I THINK this means that persitence is on by default. I'm not certain because - if that is true - then what is the Persisistent Manager for ? I have found thi ssnippet of config in conf/server.xml :
    <<<<<<
    <Context path="/myApp" reloadable="true" docBase="myApp" workDir="C:\myApp\\work\org\apache\jsp" >
    <Manager className="org.apache.catalina.session.PersistentManager" saveOnRestart="false"/>
    </Context>
    >>>>>>
    which tells Tomcat to use the Persistent Manager for my app and then ... tells it not to store session data. And this seems to work ... at least the error messages go away. Now, though, I get a new and different error message :
    <<<<<<
    SEVERE: no store configured, persistence disabled
    >>>>>>
    So I am still doing something wrong ... I think ... and still looking for help ... B-)
    Thanks again, black_lotus ... maybe we'll learn about this together ;-)

Maybe you are looking for

  • DVD from IMac  or MacBook to ATV2

    Is it possible to play a DVD movie inserted into an IMac or MacBook on a HDTV through an ATV2?

  • MacBook Air will not connect to a specific network

    Hi, I recently moved into a new place and the landlord has a wireless connection in place. My Macbook Pro , iPad and iPhone 5s all connect to the network without a problem (it requires a password and we were able to connect just fine). However, my mo

  • What is the Role of SAP PI in SAP SRM?

    Hello Gurus I'm from SAP-XI background. In my project I need to create a scenario from SRM ---> PI/XI ---> MDM. I'm having the below queries regarding this scenario. 1) Do I need to download the "XI CONTENT for SRM SERVER and import it into PI server

  • Log in error using Discover 3i

    I have a singe machine installation of Discover 3i with the following components installed. - Win NT4 (service pack 4) - MS IIS as the web server - Discover locator, server, preference components installed. All the components registered successfully.

  • Color Selection stuck on Crayons (or Color Wheel or Slider) - Lion alternative to "little oval button."

    I just spent a while figuring this out so I'm posting the solution.  I'm running OS X Lion and it seems that Apple has done away with the little oval button in the upper right hand of windows that allows you to hide/unhide toolbars.  You can usually