Object Serilization

Hi,
I'm new to Java and was wondering if you could help me with a problem.
I am writing code for a simple text editor.
I have been able to write and read files using Object Serilization. However when I read the file to the textarea display I can no longer edit the textarea. It's not editable.
Can you please have a look at the code and tell what i am doing wrong.
Thank you for all your help.
//creates a FileInputStream object bound to the disk file named jtextarea
FileInputStream fileIn = new FileInputStream("Wordss");
//creates an ObjectInputStream bound to the FileInputStream
ObjectInputStream objectIn = new ObjectInputStream(fileIn);
//read the object ans store it in an Object varialbel called c
Object c = objectIn.readObject();
// String an = (String)objectIn.readObject();
//close the inputstream
objectIn.close();
//now, check that the object is a type of component before adding it to the panel
if(c instanceof Component) {
// cast the Object as a Component before adding, you can cast as a JTextArea too.
writeArea.add((Component)c, null);
writeArea.repaint();
System.out.println("Your JTextArea has been retrived and shown");
The 'writeArea' is the JTextArea object that is used to display the words.
Thank you for all your help.

I've have tried doing that but I get the following compile error....'cannot resolve symbol' for the setEnable(true).
I have added the textarea to a scrollpane using..... "          bar= new JScrollPane(writeArea);" where bar is a scrollpane.
I have used setEditable(true) but get the same results when I read from the file. The textarea is still not editable.
What i have discovered is that when the textarea is not editable, if i write something (which is not being displayed because the textarea is not editable), save it abd then open it the text that i just wrote is displayed. It is like I am writing on another textarea which is beneath the textarea displaying the read file.
Thank you for all your help.

Similar Messages

  • About serilize/deserilize complex objects

    Dear friends,
    I have a question about transfering complex objects between client and server. if I just transfer primitive data type, any language of client side can consume this web service. but how about if I transfer complex object?
    for example, in the server side, I use java to make a bean--bean1, in this bean, there is a variable bean2, it's also a java bean with primitive variables. though WSDL file, I know the complex data type is mapped to primitive data type at last. but I don't know if the client side can consume this web service if it's made by c language or perl language. also, supposing such kind of client side can consume this web service, can the client side transfer back this bean object to server and server can recognize it?
    I really confused about this, from theory, web service is platform indepedent, does it mean language indepedent? or conditionally? does there any samples or articles about it?
    any hint will be greatly appreciated!
    Sammy

    It depends on the product and version of CORBA spec you are working with, but you can always pass a reference to the interface of the object in the parameter list, then the code can do whatever it needs to by manipulating the interface.
    Jeff <[email protected]>
    Technical Lead
    eBay.com
    eBay.com is recruiting for multiple open Java engineering positions.
    Email me your resume to be put in contact with a hiring manager.
    Principles only.

  • HOW TO PASS NON REMOTE OBJECT PARAMETER

    good day,
    hi im new to java and rmi, and i need help pls, my question is how can i pass a non-remote object/local object as a parameter to a remote method. can u pls give a code for the:
    1. client that will invoke the remote method and pass the object in remote objects method.
    2. object that will be passed to the server/remote object( a serilizable object of course).
    3. the remote object and the method that will receive the object parameter.
    thank you very much for your kindness,
    p.s.
    you can email me to [email protected]
    batusai,

    When you create the object locally, and pass it to the server, at that point it exists on both systems/in both jvms.
    Why don't you write your own example, and try it. If you get in trouble, post the code, and we will help you.

  • Serializable Objects - Clustering

              Hi,
              I want to know:
              For a Bean to support Fail Over(to be able to replicate on secondary server) in a
              cluster does it need to be Serilizable.
              If the bean is not serializable and is part of a cluster with the 'InMemory' replication
              type defined in weblogic-ejb-jar.xml if a fail over situation occurs what will happen.
              Your attention is sincerely appreciated.
              Thanks,
              Kiran
              

              Yes. That answers my question.
              Thanks,
              Kiran
              "Sudhir" <[email protected]> wrote:
              >
              >
              >Yes ,
              >it requires the bean or object Seriliazable interface.
              >Replication takes place by value not by ref.
              >Also wnen ever u change the object the value
              >use the SET attribute this is very imp in order to
              >get replicated.
              >
              >Hope this helps
              >Sudhir
              >
              >
              >
              >
              >
              >"Kiran" <[email protected]> wrote:
              >>
              >>Hi,
              >>
              >>I want to know:
              >>
              >>For a Bean to support Fail Over(to be able to replicate on secondary server)
              >>in a
              >>cluster does it need to be Serilizable.
              >>
              >>If the bean is not serializable and is part of a cluster with the 'InMemory'
              >>replication
              >>type defined in weblogic-ejb-jar.xml if a fail over situation occurs what
              >>will happen.
              >>
              >>Your attention is sincerely appreciated.
              >>
              >>Thanks,
              >>Kiran
              >>
              >>
              >>
              >
              

  • Objects serialization

    Suppose I am serializing a custome object of class
    class Employee implements java.io.Serializable{
    long id;
    String name;
    String department;
    //setter and getter methods for each attribute
    if i am serializing the object of Employee
    Employee key = new Employee();
    key.setId(1000);
    key.setName("xyz");
    key.setDepartment("aaa");
    //using serial binding for key, instead of tuple binding - application requirement
    SerialBinding binding = new SerialBinding(new StoredClassCatalog(db),Employee.class);
    DatabaseEntry keyEntry = new DatabaseEntry();
    binding.objectToEntry(key, keyEntry);
    - what is order of serilization, represented by byte array, of each attribute of object?
    - is the byte array contains first, bytes of id then name and so on?
    - If this object key is used to find the record, will it use entire byte array representation of serialized object to compare or it will first, use byte array representation of 'id' then 'name' and so on... to compare

    I don't want to use custom tuple binding for custom
    objects as any arbitrary objects can be stored in
    database. In this case which binding I should use. It
    seems that TupleBinding supports only java primitive
    objects.I don't understand why you're using arbitrary objects for keys. If you do that, I don't know of any way to get a meaningful sort order. So you might as well use SerialBinding.
    If you can think of a way to use arbitrary objects for keys and implement a binding that provides a meaningful sort order, for your application at least, please do so. You are free to implement the EntryBinding and EntityBinding interfaces in any way you choose. It is up to you.
    Any clue for my query? It is unreasonable for you to expect answers so quickly. I suggest that you read the source code in the com.sleepycat.bind package and try to get answers on your own.
    --mark                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Loosing of object state when it is called from server to client side

    Hi,
    Iam loosing an object values when that object is returning from server side to client side.
    Even my server class implements serilizable interface, the object is not retaing its values..
    can any one suggest regarding this Issue..
    Regards,
    Dev

    got the solution

  • I want to Know about Vo and Serilization

    Hi Friends
    I am having one doubt
    When we carete a Value objet then we provide a deafault constructor.
    Also we use to serilize it.
    What is the use of deafult construtor even if we are not intilizing any parameters..

    Maybe we should agree on what we mean by "Value
    Object" first.
    I like Eric Evans' definition: A value object isan
    object whose identity doesn't matter, and itsstate
    is immutable.
    If I write a Person object, and that Person is
    persisted in a relational database with a primary
    key, that Person object is likely to have aprimary
    key as an attribute. That's an identity that my
    application needs to track as that object is used.
    If I write a Money class, it can be a Value Object
    because any instance that represents $10 USD canbe
    used by any other object that needs it. The Java
    wrapper classes are VOs.
    %Thanks for Ur valubable Input.
    Is String Class provide any type of design
    Pattern?
    In an iNterview the interviewr had asked me that u can not initilize a Valueobject.But I know that it is simple java Class with getter and setter method serilaizable Interface Imlepmented.
    He said that What is the Point of Initilization when It is Serilized.

  • Are there any problems to expect when srializing java.lang.Object?

    When having code like this:
    public class SomeClass implements Serializable{
    private final String NULL_CONSTANT="dmmystring";
    private Object result=new String(NULL_CONSTANT);
    ...whatever
    Class java.lang.Object is not implementing the Serializable Interface. In practise, this works fine however, I would like to understand this question. Will serialization work in every case as long as result is set to a serializable type?

    hi,
    If the object does not implement the Serilizable marker interface, then when you try to serialize the object, you will get a NotSerializableException. Also when you try to serialize a object, java will check to see if any variables contained in the object are also serializable and if so it serializes the same so in effect all attributes of the object must be either serializable or marked transient. When you mark a variable as transient, for eg
    transient Vector v;
    this object will not be serialized.
    you might want to check out the article at
    http://java.sun.com/docs/books/performance/1st_edition/html/JPIOPerformance.fm.html#11352
    It contains ways to improve serialization, but it will also be useful in understanding the Serialization concepts as such...
    hope this helpzz
    cheerz
    ynkrish

  • Serilization delay over network.

    Hello!
    As mentioned in a previous thread, with a 1.4-class JVM i have a serilization-delay (the time it takes to send the server a serilized Object and receive another serialized object from the server).
    For the server I always use 1.4.2 but the client I've tested the client with several different JVMs.
    The funny(sad) thing is, that with 1.1-class JVM the delay is less than 1ms but with 1.4.2 it takes 40ms(!!) for the same data. The delay is always about 40ms. The objekts I (de)serilizise is just a simlple class with one int and some short strings, no complex references. My profilier says most time is used in read() from the InputStream, it doesnt matter if I use a BufferedInutStream or not, the delay is always the same.
    However Throughput of network should be no problem over unix-domain-sockets and localhost.
    I also dont have any delays when I communicate byte-based with the stream directly.
    The comunication looks like this:
    clint -> server -> (Problem) -> client
    As you can see Problem is the deserilisation of the object sent by the server. It doesnt matter if I use Buffered Streams or not. Also, the CPU-utilisation is only about 6%, my profilier says most time is spend in read() od the stream.
    Any ideas, I tries nearly everything, maybe this is a bug in the current JRE??
    lg Clemens

    Its not a general behaviour that bothers me like low performance or such stuff, it seems to be a bug which I don't know to resolv.
    I benchmarked serilisation-performance and 1.4.2 is A LOT faster than 1.1, but in my application the objectinputstream has a delay (not working, just doing nothing, my CPU utilisation doent reach 10%) and I'm quite sure its a bug. It looks a little bit overoptimized.
    I serached the forums and I found somebody who had the same problem with 1.2.2 but he resolved it. The sad thing is that he didnt tell us how he did.
    Has anyone had also these problems and how yould you resolv those?
    Thanks a lot, lg Clemens

  • ObjectOutputstream not sending all of the object?

    Hello, I have a server/client application that is sort of like a chatroom, except you type in a box and other people have frames that see you as you type.
    So im sending the updated string and the ID of the clinet in an object using serilization, etc. So i send it like this (c is a serializable object):
    oos.writeObject(c);
    oos.flush();and the serverside code
    Object o = ois.readObject();
    Client c = (Client)o; //never gets hereBut when i debug, the ois never finishes reading the object - it just stays on that line and never goes to the next line. help?

    ok that narrows it down a bit i guess... and brings up an intersting thing.
    I implemented the writeObject/readObject methods. So it seems like the reading(serverside) side is doing good. But the writing side(client) isnt.
    ive put System.out.printlns above and below the writeObject call
    //write side
    System.out.print("before w");
    oos.writeObject(c);
    System.out.println("after w");
    ///read side
    System.out.println("before r");
    c = (Client)ois.readObject();
    System.out.println("after r");Then, the writeObject meothod is like this:
        private void writeObject(ObjectOutputStream out) throws IOException
            //dont really need to call this becuz i made all the fields transient so whats the point ;)
            out.defaultWriteObject();
            System.out.println("Starting the wite");
            out.writeInt(ID);
            System.out.println("WRote the ID");
            out.writeObject(s);
            System.out.println("WRote the String");
        }the readObject method is the same except its in.readObject and stuff.
    So what is happening:
    I write out the object the first time. Everything works well, all the println statements print: the write side activates, printing out
    before w
    Starting the wite
    WRote the ID
    WRote the String
    after w
    the read side preforms the exact same too.
    I do it a second time. The write side prints out before and after:
    before w
    after w
    It does not seem like the object actually got serilaized! ???
    the read side hangs at "before r", meaing its hung up on the ois.readObkect. CPU is at 0.
    Sooo... very weird indeed.

  • Error while activating a routine  "no object list"

    hi
    I am getting a error while activating a routine Rv50c601
    "There is no object list for INCLUDEs"  Please suggest on the error and resoulution
    regards
    Nishant

    Try running program RV80HGEN.
    Regards,
    Naiimesh Patel

  • Error in VBA reference for Adobe Photoshop CS4 Object Library

    Hello,
    I'm using Windows 7 Pro, MS Office 2010 Pro and Creative Suite CS4 (with all updates).
    I will automate Photoshop via Visual Basic for Applications in MS Access.
    Befor using there the Adobe Photoshop CS4 Object Library I must reference it in VBA.
    But when I will du this, I get the message "Error loading DLL".
    When I will manually reference to the WIASupport.8LI File, I get the error: "Cannot reference this file"
    Can you give a tip, how I can solve this problem?
    Regards

    I have the same problem!  I have photoshop cc2014 (which we own) and the object library shows, but not for cs 5.1 (30 day trial).
    Does registering unlock something?
    Help please!!

  • Logical Database in Abap Objects

    Hi to All
    I want do it a program report using a Logical Database.
    Is this possible ??? But when I make a GET <node>, occurs the following error:
             "" Statement "ENDMETHOD" missing.  ""
    I'm doing the following:
    CLASS MONFIN IMPLEMENTATION.
           METHOD TRAER_DATOS.
                   GET VBRK.
           ENDMETHOD.
    ENDCLASS.
    Please, somebody tell me how I use the logical database in Abap Objects.
    Thank you very much
    Regards
    Dario R.

    Hi there
    Logical databases whilst of "some use" are not really part of OO.
    If you want to use a logical database in an abap OO program I would create a special class which just does the get data from your DB and pass this either at record or table level.
    Techniques such as GET XXXX LATE aren't really part of any OO type of application since at Object Instantiation time you should be able to access ALL the attributes of that object.
    As far as OO is concerned Logical databases are a throwback to "Dinosaur Technology".
    Since however modules such as SD and FI are still heavily reliant on relational structures (i.e linked tables etc)  then there is still some limited life in this stuff but for OO try and solve it by another method.
    If you really must use this stuff in OO then do it via a FMOD call and save the data in a table which your method will pass back to your application program.
    You can't issue a GET command directly in a method.
    Cheers
    Jimbo

  • Null and empty string not being the same in object?

    Hello,
    I know that null and empty string are interpreted the same in oracle.
    However I discovered the strange behaviour concerning user defined objects:
    create or replace
    TYPE object AS OBJECT (
    value VARCHAR2(2000)
    declare
    xml xmltype;
    obj object;
    begin
    obj := object('abcd');
    xml := xmltype(obj);
    dbms_output.put_line(xml.getStringVal());
    obj.value := '';
    xml := xmltype(obj);
    dbms_output.put_line(xml.getStringVal());
    obj.value := null;
    xml := xmltype(obj);
    dbms_output.put_line(xml.getStringVal());
    end;
    When creating xml from object, all not-null fields are transformed into xml tag.
    I supposed that obj.value being either '' or null will lead to the same result.
    However this is output from Oracle 9i:
    <OBJECT_ID><VALUE>abcd</VALUE></OBJECT_ID>
    <OBJECT_ID><VALUE></VALUE></OBJECT_ID>
    <OBJECT_ID/>
    Oracle 10g behaves as expected:
    <OBJECT><VALUE>abcd</VALUE></OBJECT>
    <OBJECT/>
    <OBJECT/>
    However Oracle 9i behaviour leads me to the conclusion that oracle
    must somehow distinguish between empty string and null in user defined objects...
    Can someone clarify this behaviour?
    Thus is it possible to test if object's field is empty or null?

    However Oracle 9i behaviour leads me to the conclusion that oracle
    must somehow distinguish between empty string and null in user defined objects...
    Can someone clarify this behaviour?
    Thus is it possible to test if object's field is empty or null?A lot of "fixes" were done, relating to XML in 10g and the XML functionality of 9i was known to be buggy.
    I think you can safely assume that null and empty strings are treated the same by Oracle regardless. If you're using anything less than 10g, it's not supported any more anyway, so upgrade. Don't rely on any assumptions that may appear due to bugs.

  • "cacheHostInfo is null" and Add-SPDistributedCacheServiceInstance : Object reference not set to an instance of an object.

    I am working on a standalone install Sharepoint 2013 (no Active Directory). I found newsfeed feature is not available and checked Distributed Cache service is stopped. When start it “cacheHostInfo is null” is returned.
    I checked the Windows service “AppFabric caching service” is stopped because the default identity “Network Service” not work. Then I change the AppFabric service identity to use “.\administrator” (which is also the sp farm administrator) and the service can
    be started.
    However the “cacheHostInfo is null” when try to start Distributed Cache service in central admin.
    I searched on web and found this blog: http://rakatechblog.wordpress.com/2013/02/04/sharepoint-2013-spdistributedcacheserviceinstance-cachehostinfo-is-null/
    I tried to run the script but it return error:
    Add-SPDistributedCacheServiceInstance : Object reference not set to an
    instance of an object.
    At C:\root\ps\test.ps1:8 char:13
    + $whatever = Add-SPDistributedCacheServiceInstance
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidData: (Microsoft.Share…ServiceInstance:
    SPCmdletAddDist…ServiceInstance) [Add-SPDistributedCacheServiceInstance]
    , NullReferenceException
    + FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletAddDistr
    ibutedCacheServiceInstance
    I am not sure what went wrong. Please give me some idea? Thank you for any comment!

    Can you deploy Active Directory as installing without is not a supported installation scenario - http://support.microsoft.com/kb/2764086.
    Trevor Seward
    Follow or contact me at...
    &nbsp&nbsp
    This post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs.

Maybe you are looking for

  • How to Process an Empty File and deliver to the receiver channel

    Hello Gurus, We had a requirements to process an empty file and send it to the receiver channel .  We had successfully configured and polling an empty file, but the message output of the empty file was never sent to the receiver channel.  Is there an

  • Nokia Lumia Icon denim update

    I updated my phone as I was supposed to, and some features work. However I'm not able to open any apps, including Verizon which enables me to call. My photos don't open, in fact the only apps I can open are internet explorer, settings, and messages.

  • Working with an original DVD

    I'm working with a DVD in order to familiarize myself with FCE because I don't have any raw fotage or even a digital camcorder. Just an old Hi8. So, I'm working with a manufactured DVD to practice using fce. and in the end y end result onto a burned

  • Gaps between purchased iTUNES tracks

    I have seen some discussion on making a CD one track to eliminate the gaps between tracks in the iPOD. However, I have purchased several classical music pieces-such as the Rachmaninov Variations on Pagannini--well each variation is a track-which is n

  • Unable to repair disk permissions : no valid package

    i can't repair disk permissions on my PB G4 OS 10.4.7! i did a disk repair, had minor problems which were repaired. i took the iTunes iPod stuff from the library/receipts folder. the error message is : no valid package. i tryed to reset permissions w