Save tree the lists of which is class' object

Hi, my question :
how can i save tree the lists of which is class' object?
i save tree with the help of ObjectOutputStream class, but when i read tree object from file i have leaf without name(clean leaf)
how read and save tree in file for normal with it?
Code of my function for save tree:
import javax.swing.JTree;
import java.io.*;
import java.util.*;
public class SaveTree {
    public SaveTree(){
    public void saveTree(JTree tree){
        try{
        ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream("tree.info"));
        out.writeObject(tree);
        out.close();
        catch(Exception e){
            e.printStackTrace();
    public JTree loadTree(){
        JTree tree = new JTree();
        try{
            ObjectInputStream in = new ObjectInputStream(new FileInputStream("tree.info"));
            tree = (JTree)in.readObject();
            in.close();
        catch(Exception e){
            e.printStackTrace();
        return tree;
}the code where i create new node as class' object
public void actionPerformed(ActionEvent e) {
        String command = e.getActionCommand();
        if (ADD_COMMAND.equals(command)) {
            //Add button clicked
            book = new DefaultMutableTreeNode(new BookInfo
            (name.getText(),
            "file:///"+ System.getProperty("user.dir") + "/" + ID.getText() + ".html", Integer.parseInt(ID.getText())));           
            treePanel.addObject(book);
            name.setText("");
            ID.setText("");
}my class BookInfo
public class BookInfo {
        public String bookName;
        public String bookURL;
        private int bookID;
        public BookInfo(String book, String filename, int ID) {
            bookID = ID;
            bookName = book;
            bookURL = filename;
            System.out.println(bookURL);
            if (bookURL == null) {
                System.err.println("Couldn't find file: "
                                   + filename);
        public String toString() {
            return bookName;
        public int getID(){
            return bookID;
        public void setID(int ID){
            bookID = ID;
    }thanks for attention ! :)

Jos, thanks for answer :)
Erm, get the TreeModel from the JTree, serialize it and later deserialize it and set it as the TreeModel for your JTree again?
kind regards,
JosHm, i save treeModel the same way, but when i (de)serialize treeModel from file i get clean tree
my function to save treeModel
class Save{
public Save(){}
public DefaultTreeModel loadModel(DefaultTreeModel model){
        try{
            ObjectInputStream in = new ObjectInputStream(new FileInputStream("tree.info"));
            model = (DefaultTreeModel)in.readObject();
            in.close();
        catch(Exception e){
            e.printStackTrace();
        return model;
        public DefaultTreeModel saveModel(DefaultTreeModel model){
        try{
            ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream("tree.info"));
            out.writeObject(model);
            out.close();
        catch(Exception e){
            e.printStackTrace();
        //return model;
}and here i init tree with treeModel
Save save = new Save();
DefaultMutableTreeNode root = new DefaultMutableTreeNode(myObject);
DefaultTreeModel model = new DefaultTreeModel(root);
JTree tree = new JTree(save.saveModel(model));
JPanel panel  = new JPanel();
panel.add(new JScrollPane(tree));
this.add(panel);Edited by: Tmrs on May 18, 2008 6:00 AM

Similar Messages

  • HT5361 how do I keep the classic look ? I go to mail preferences and click the button but when I launch mail again it is still in the list view which I hate. Anyone know ?

    how do I keep the classic look ? I go to mail preferences and click the button but when I launch mail again it is still in the list view which I hate. Anyone know ?

    The first thing to try if a setting does not "keep" is a PRAM reset.
    http://support.apple.com/kb/ht1379
    Change the setting to what you want, then PRAM reset on restart:
    Shut down your Mac.
    Locate the following keys on the keyboard: Command (⌘), Option, P, and R. You will need to hold these keys down simultaneously in step 4.
    Turn on the computer.
    Press and hold the Command-Option-P-R keys before the gray screen appears.
    Hold the keys down until the computer restarts and you hear the startup sound for the second time.
    Release the keys.

  • How to automate the creation of Function Module & Class Object (SE24)

    Experts,
    I have the requirement to automate the creation of any type of programs: ie function module (like how we normally create in SE37 together with the parameters), class object (like how we normally create in SE24 together with attribute & method), normal report (like how we did in SE38), module pool and so on.
    For example. I backuped my program into a flat file (the entire source code in txt formal or HTML) through a download program and I need to upload back this flat file into another installation of SAP.
    Does SAP provide any predefined FM to cater for the above cases or better still, does anyone know of any upload program which I can use for the above requirement.
    Thanks in advance.

    Hi Kris, I can't use the transport system as these are 2 separate SAP installation in a different place. The requirement came in the form of creation of program to be able to generate FM/Class/Report on the go.

  • While running my app I get the below error  - have different Class objects for the type javax/servlet/http/HttpServletRequest used in the signature

    I am running ATG[10.1.2] app on Jboss [EAP 5.1.0 GA] I am able to open dyn/admin however when I start my app I get the below error
    java.lang.LinkageError: loader constraint violation: when resolving method "atg.servlet.ServletUtil.setSessionConfNumCacheRequest(Ljavax/servlet/http/HttpServletRequest;)Ljavax/servlet/http/HttpServletRequest;" the class loader (instance of org/jboss/classloader/spi/base/BaseClassLoader) of the current class, atg/filter/dspjsp/PageFilter, and the class loader (instance of org/jboss/classloader/spi/base/BaseClassLoader) for resolved class, atg/servlet/ServletUtil, have different Class objects for the type javax/servlet/http/HttpServletRequest used in the signature
      at atg.filter.dspjsp.PageFilter.doFilter(PageFilter.java:215)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at atg.servlet.ForwardFilter.doFilter(ForwardFilter.java:263)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at atg.servlet.ErrorFilter.doFilter(ErrorFilter.java:279)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:638)
      at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:446)
      at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:382)
      at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:310)
      at org.apache.catalina.core.StandardHostValve.custom(StandardHostValve.java:416)
      at org.apache.catalina.core.StandardHostValve.status(StandardHostValve.java:342)
      at org.apache.catalina.core.StandardHostValve.throwable(StandardHostValve.java:286)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
      at java.lang.Thread.run(Thread.java:680)
    11:22:47,413 ERROR [[localhost]] Exception Processing ErrorPage[errorCode=500, location=/global/errorPage500.jsp]

    The supported JBoss version for 10.1.2 is JBoss EAP 5.1.2 but I don't think that your issue is caused because of this. Your issue is more of an environmental thing as you are probably getting two different versions getting loaded of class javax.servlet.http.HttpServletRequest and so correspondingly two different Class objects as the error shows. One reason for this could be if you include any server-specific libraries (in present case the Servlet API JAR which contains the class javax.servlet.http.HttpServletRequest) of a different version in the /WEB-INF/lib of your web application. Try removing it from there if so and see if that helps.

  • QTP11.0 does recording the list boxes twice (web portal object) that open through browser

    Hello There,
    I am recording an SAP portal application, whereby the list boxes are recorded twice.
    For example: see the code below where during the recording I selected the value from drop down once but this step recorded twice. Moreover, It happens only to the drop down objects only.
    Browser("Create Sample Request").SAPPortal("Create Sample Request").SAPFrame("Sales Sample Create -").SAPList("Sample Reason: *").Select "Quality Issue"
    Browser("Create Sample Request").SAPPortal("Create Sample Request").SAPFrame("Sales Sample Create -").SAPList("Sample Reason: *").Select "Quality Issue"
    Please advise.
    Regards
    Adil Syed

    Adil
    You may want to try reposting your question on the forums specifically for the QTP product. Here's the link.
    http://h30499.www3.hp.com/t5/Functional-Testing-QT​P/ct-p/sws-Fun_Test

  • No RFMs in the list when creating connector class

    When I attempt to create a proxy class (a new project of SAP Connector Class) I see no RFMs listed in the left hand list.  I type in qirf_* and click Search no RFMs appear.
    Connectivity tests work for the host, client, user, and pw settings I've entered (i.e. bad entries raise errors, good ones that work on SAP Gui or on my program with proxy class created in my dev environment allow me to get past the first screen and to the RFM selection screen by clicking next).
    Thanks for any suggestions you can provide.
    Using .net 2002 (1.0) against .net connector 1.0 SAP/QMIDI 640

    Amit,
    Thank you for your reply.  I am doing much better now
    Short version: it was a DLL mismatch!
    Long version: I was thoroughly and completely stumped until I just walked away for a bit and decided to go back and clean up some directories with various versions of my solution and builds.  I did a search on sap.connector.dll and that guided me to where my cleanups needed to be done...
    however, i noticed that there was a sap.connector.dll v1.2.0 file in all but 2 folders, where these 2 folders had 1.2.1 : one where I had it stored, the other one was
    c:\Program Files\Visual Studio .Net\Common7\IDE
    My solution however was referencing
    c:\Program Files\SAP\SAP .Net Connector\sap.connector.dll
    As soon as I saw that, I replaced the 1.2.1 with 1.2.0 and the proxy class wizard immediately showed the RFMs.
    I am happy once again.

  • Reading the Interfaces name which the class is implementing in a COM dll is implementing.

    Hi All,
    I'm using .NET Reflection to read a COM dll. I'm able to fetch the classes that are present in the dll. But I would like to know interface name which this class is implementing.
    For a .NET dll we can know the name of class's implementing interface name using the <classname>.BaseType.Name property.
    How can I know the interface name which this class is implementing (if any).
    Please let me know how to do this for a COM dll.
    Thanks in advance,Satish
    Thanks, Satish Bommideni "Success usually comes to those who are too busy to be looking for it."

    Hi,
    Thanks for the reply.
    I'm reading the COM assembly using the methods available in oleaut32.dll.
    Also I've imported the namespaces
    System.Runtime.InteropServices.ComTypes;
    System.Runtime.InteropServices;
    to use its respective methods and thus I'm able to read it's classes.But donot know what property to check for this class's interface.
    Kindly let me know if you need any further information.
    Thanks, Satish Bommideni "Success usually comes to those who are too busy to be looking for it."

  • Ribbon + s4-title s4-lp | Hides when clicked on the list item

    Hello,
    Using
    SPSecurityTrimmedControl, I hide the ribbon for a user having
    view only rights. Now when this user clicks on any list item (grid view), the div "s4-title" containing the logo, and title text hides too.
    Please help.

    Thanks for the reply Shakir.
    I tried to find the div with id ms-designer-ribbon to make the changes and add the JavaScript. I failed to do so. Please helpme with me with this.
    I'll try to explain a bit more:
    The View Only user shouldn't have the ribbon for any editing changes. To achieve this, I followed the steps given in the article (URL below).
    http://blogs.msdn.com/b/zwsong/archive/2010/04/29/how-to-hide-ribbon-from-users-without-edit-page-privilege.aspx
    Now when the user clicks anywhere on "Line Item", the div containing logo i.e.
    <div class="s4-title s4-lp">
    gets hide. There should be some click event on the list items which onclick opens the edit option.
    Any help is appreciated

  • Termstore changes are not getting reflected in the list items in SharePoint 2010 farm environment

    Hi,
    I had created managed metadata with termstores from central admin. Then I had created one list in which added a column of type managed metadata using the managed metadata which I had created. And also added few list items to this list.
    The problem is that after updating a termstore the changes are not reflecting in the list items which were added before the update.
    I have referred the following links:
    http://www.paulgrimley.com/2011/02/managed-metadata-changes-not-applied-to.html
    http://davidfrette.wordpress.com/2010/05/26/taxonomy-update-scheduler%C2%A0timer%C2%A0job/
    According to the links we need to run Taxonomy Update Scheduler on the server for updated termstore to get reflected. After running
    this scheduler on development environment changes are getting reflected but not working on the production environment.
    Kindly help!
    Regards, Shruti

    You should check the obvious.  You made the change in dev, but did you make the change in production too?  And, is the term you updated, actually the one that you are looking at in the list item?
    There is not much, if anything, that can go wrong with that timer job. so I'd guess that the term you are looking at is not the one you think you are updating.
    If you have double checked everything (the term is is in fact the same term id), then you may have something erroring in the update process.  In this case, you should check the ULS logs for any errors.
    Chris
    Chris Givens CEO, Architecting Connected Systems
    Blog Twitter

  • The CC control panel use to show my 4 applications CC, CS6, LR5 and Bridge, now LR5 is no longer showing up. I pay for the photographer bundle, which includes LR5 and CC, why has it been dropped off? Is there any way to bring it back in the panel, because

    The CC control panel use to show my 4 applications CC, CS6, LR5 and Bridge, now LR5 is no longer showing up. I pay for the photographer bundle, which includes LR5 and CC, why has it been dropped off? Is there any way to bring it back in the panel, because in the listed applications which can be added below it is not listed.  Thanks!

    If you're a paying Creative Cloud member, you may not see Lightroom in the Creative Cloud if your computer doesn't meet the minimum system requirements. Check to make sure that your system meets the minimum requirements for the latest release of Lightroom.
    If you're using a trial version of Creative Cloud, the Lightroom trial is not available through Creative Cloud. It is, however, available as a stand-alone trial. See Install Lightroom trial | Creative Cloud membership. 
    Please refer to : Lightroom and Creative Cloud FAQ
    Regards
    Rajshree

  • What is the exact mean of  classname.class.

    what is the exact mean of classname.class. what situations it will be use ful . how to use . give me one example .

    Each class, interface, or enum loaded into the JVM has an associated Class object. This contains a lot of information about the class in question, including lists of fields and methods. <classname>.class gives you a reference to the Class object of the class mentioned.
    See the java.lang.Class javadocs for all the things you can do with a Class object.
    For example:
    theImage = new ImageIcon(MainClass.class.getResource("item.png"));to retrieve an image file from the directory containing the MainClass class file.

  • Help with Xcode what is the difference between a Function, class and object

    Hi all,
    I'm new here and in programming in Xcode. My question is can somebody tell me what the difference is between functions classes and object. I will appreciate it if you can involve some articels or something else.
    Many thanks,
    RL6001

    Do a Google search for object-oriented programming. When I did, I found the following tutorial, which explains what objects and classes are:
    Object Oriented Programming Tutorial

  • Show the List attachment in a new window

     I have list item attachment names displayed along with the columns. I have used following styling to show the attachment names in the list
    <td id="ItemAttchment" class="ms-vb">
    <xsl:element name="SharePoint:AttachmentsField">
    <xsl:attribute name="runat">server</xsl:attribute>
    <xsl:attribute name="FieldName">Attachments</xsl:attribute>
    <xsl:attribute name="ControlMode">Display</xsl:attribute>
    <xsl:attribute name="Visible">true</xsl:attribute>
    <xsl:attribute name="ItemId">
    <xsl:value-of select="$thisNode/@ID">
    </xsl:value-of>
    </xsl:attribute>
    </xsl:element>
    </td>
    I have webviewer setup for the word documents to show in the browser.  The attached document for the list item shows fine in the browser.  Currently the attachment document shows in the same browser window
    When the user clicks on attachment name, I want to show it in a new window or new tab. How can I do that?
    Thanks
    Nate

    Thank you Bala for the quick reply.  I still cant get the attachment to open in new window
    I have used following code, Appreciate any help in resolving the issue
    Thanks
    Nate
    <td id="ItemAttchment{$ID}{generate-id()}" class="ms-vb"  onclick="window.open(this.href,'_blank','');">
              <xsl:element name="SharePoint:AttachmentsField">
                  <xsl:attribute name="runat">server</xsl:attribute>
                  <xsl:attribute name="FieldName">Attachments</xsl:attribute>
                  <xsl:attribute name="ControlMode">Display</xsl:attribute>
                  <xsl:attribute name="Visible">true</xsl:attribute>
                  <xsl:attribute name="ItemId" >
                             <xsl:value-of select="$thisNode/@ID">
                          </xsl:value-of>             
                    </xsl:attribute>
              </xsl:element>
        </td>
    <script language="javascript" type="text/javascript"> $( "#idAttachmentsTable tbody tr td span a").unbind( "click" ); </script>

  • To get Class object representing the primitive type by a String

    for classes,I can use
    classNameString = "java.lang.String"
    Class c=Class.forName(classNameString);
    to get Class object representing the classNameString.
    but to get Class object representing the primitive type ,I have to use something like :
    Class c=Integer.TYPE;
    is there any way to get Class object representing the primitive type by a String?

    not using Class.forName(). you'll just need to key off the String passed to see whether it names a primitive:class ClassUtilities {
       * Gives the <code>Class</code> corresponding to a named class or primitive.
       * @param  name  FQN of a class, or the name of a primitive type
       * @param  loader  a {@link java.lang.ClassLoader ClassLoader}
       * @return  the <code>Class</code> for the name given.  This method
       * converts primitive type names to their particular <code>Class</code>
       * object.  <code>null</code>, the empty string, <code>"null"</code>, and
       * <code>"void"</code> yield {@link java.lang.Void#TYPE Void.TYPE}.  If any
       * classes require loading because of this operation, the given
       * <code>ClassLoader</code> performs the loading.  Such classes are not
       * initialized, however.
       * @throws  ClassNotFoundException  if the name names an unknown class
       * or primitive
       * @see  java.lang.Class#getName
      static Class classForNameOrPrimitive( String name, ClassLoader loader )
        throws ClassNotFoundException {
        if ( name == null || name.equals( "" ) || name.equals( "null" ) || name.equals( "void" ) ) {
          return Void.TYPE;
        if ( name.equals( "boolean" ) )
          return Boolean.TYPE;
        if ( name.equals( "byte" ) )
          return Byte.TYPE;
        if ( name.equals( "char" ) )
          return Character.TYPE;
        if ( name.equals( "double" ) )
          return Double.TYPE;
        if ( name.equals( "float" ) )
          return Float.TYPE;
        if ( name.equals( "int" ) )
          return Integer.TYPE;
        if ( name.equals( "long" ) )
          return Long.TYPE;
        if ( name.equals( "short" ) )
          return Short.TYPE;
        return Class.forName( name, false, loader );
    }

  • Loading and viewing XML when a class object is created..Help Please

    Hello,
    I have writing a simple class which has a method that gets invoke when the object of the class is created. I am able to view the loaded XML content when I trace it with in my class method, but cannot assign the content to a instance variable using the mutator method. So the process goes like this:
    Class object is instantiated
    Class construtor then calls the loadXML method which laods the XML
    And then assigns the XML to a class instance variable.
    So now if I would like to access the loaded XML through class object, I should be able to see the loaded xml content which I am not able to see. I have spent over few hours and cannot get the class object to display the loaded XML content. I would highly appreciate it if someone can help in the right direction, please.
    [code]
    package com.as3.app
        import flash.display.*;
        import flash.events.*;
        import flash.text.*;
        import flash.net.*;
        public class Cars extends MovieClip {
               public var _CarList:Object;
               public function Quiz()
                  super();
                  loadCars();
    // ===========================================================
    //           CARS GETTER SETTER
    // ===========================================================
            public function set Cars(val:XML):void
                this._CarList = val;
            public function get Cars():XML
                return this._CarList;
    // ===========================================================
    //            LOAD QUESTIONS FROM XML
    // ===========================================================
            public function loadcars()
                var myXML:XML;
                var myLoader:URLLoader = new URLLoader();
                myLoader.load(new URLRequest("xml/cars.xml"));
                myLoader.addEventListener(Event.COMPLETE, processXML);
                function processXML(e:Event):void
                    myXML = new XML(e.target.data);  
                    Cars = myXML;                 // Assigning the loaded xml data via mutator method to the _CarList;
    //=============================================================  
                                  INSTANTIATING THE CLASS OBJECT
    //=============================================================
    package com.as3.app
        import flash.display.*;
        import flash.events.*;
        import flash.text.*;
        import flash.net.*;
        import com.as3.app.*;
        public class DocumentClass extends MovieClip {
            public var c:Car;
            public function DocumentClass()
                super();
                c = new Cars();  
                trace(c.Cars);
    [/code

    where you have:
                super();
                c = new Cars();  
                trace(c.Cars);
    c.Cars will not trace as the loaded xml, because it will not have loaded in time. After some time it should presumably have the correct value.
    loading operations in actionscript are asynchronous, so your nested function which is acting as the listener ( function processXML(e:Event):void) only ever executes when the raw xml data has loaded and that is (I believe, not 100% sure) always at least one frame subsequent to the current one.
    In general I would consider it bad practise to use nested functions like that, but I don't think its contributing to your issues here. I think its just a timing issue given how things work in flash....
    Additional observation:
    your Cars constructor calls loadCars() and your loadCars method is defined as:
    public function loadcars()
    I assume its just a typo in the forum that the uppercase is missing in the function name....

Maybe you are looking for

  • Posting period 002 2011 is not open (MRKO)

    Dear experts, I process Vendor consignment: 1. Goods receipt - 501K 2. Transfer posting - 411K 3. MRKO On MRKO, I choose Document date and Posting date is: 17.12.2010 Open period in MM: 01/2011 (12/2010) Now is 02/2011 but I want to post in 17.12.201

  • How much could I get for my MacBook Pro?

    I have a late 2007 MacBook Pro (November). 2.2GHz, 200GB HDD, 4GB RAM, and I was wondering if anyone knew how much I could get for it. The video card is slowly dying too and I wanted to trade this computer and spend some extra money to get an ipad 2

  • Weblogic 6.1sp3 Oracle 9i connectivity issue

    All, I need your help in overcoming a Connection Pool issue. Details are: -Configuration - Weblogic 6.1 sp2, Oracle 9i (on a P4 machine) -Connection pool entry (config.xml) <JDBCConnectionPool CapacityIncrement="1" DriverName="oracle.jdbc.driver.Orac

  • Sun java vs. microsoft java

    I need to know what the difference is between the two of these. And some good places to find info regarding this topic? I need to know differences, similarities, and what each is better suited for. I don't need this for a specific op sys but i need t

  • OpenOffice w/ KDE file picker dialogs

    I have OpenOffice 2.3 installed with KDE, and "export OOO_FORCE_DESKTOP=kde" (in /etc/profile), but I am still getting the yucky openoffice default dialogs for file save/open. The KDE file picker rocks - since you can access any konqueror bookmark, i