Menu

Try this class

Help
seeker1006
2007-10-21
2013-04-26
  • seeker1006

    seeker1006 - 2007-10-21

    import java.util.Iterator;
    import gui.HyperFrame;
    import javax.swing.JFrame;
    import javax.swing.JMenuBar;
    import javax.swing.JPanel;
    import data.FileHandler;
    import data.Node;
    import data.NodeTree;

    public class testclass extends JFrame {

        /**
         * @param args
         */
        public static NodeTree nodeTree;
       
        public static void main(String[] args) {
            // TODO 自动生成方法存根
           
            nodeTree = new NodeTree();
            Node n = new Node("New File");
            nodeTree.getRootNode().addChild(n);
            FileHandler.loadedFileName = null;
            HyperFrame hf = HyperFrame.getActiveFrame();
            if(hf == null)
                hf = new HyperFrame();
            hf.setNode(n);
            hf.setVisible(true);

            JFrame jframe = new JFrame();
            JMenuBar menuBar =jframe.getJMenuBar();
            menuBar=hf.updateMenuBar();
            jframe.setJMenuBar(menuBar);
            JPanel ContentPane = (JPanel)hf.getContentPane();
            jframe.setContentPane(ContentPane);
            jframe.setSize(400,400);
            jframe.setTitle("TestDemo");
            jframe.setVisible(true);

        }

    }

    It hasn't the listener event .why?

     
    • Jere Darais

      Jere Darais - 2007-10-22

      This class doesn't run with my current version of the source code, but as far as I can tell, it looks like you're just going for a way to pull the components out of the JFrame to use in some other window or frame.  If you're trying to make a customized frame, you're probably better off extending the HyperFrame class.  If extending the HyperFrame class doesn't work for what you want to do, let me know what you are going for, and I will see if I can accommodate your needs.

      Cheers,
      Jere

       
    • seeker1006

      seeker1006 - 2007-10-22

         I have a purpose to exploit two java application programmes. The first one will be the Hypernotes which should be consummated . The other one will be an java application programme which already has it's user interface and some other functions.I want to embed the Hypernotes sourcecode to the java application programme ,so the java application programme can interpret the files which the Hypernotes saved.

         So I want to embed our Hypernotes into another java application programme. So the problem comes. The java application programme already has a "JFrame" as the user interface. So I have to change the HyperFrame of the Hypernotes frome a JFrame to a JPanel. After delete and change some sourcecodes,for example:I delete the menubar ; I add a "Open2" item to the popmenu which has had the itum "Create New", "Delete", "Rename" ,I want to open a saved file through this "Open2" item. 

      And then the main function likes following:

      public class MainTest {
      public static void main(String[] args){

      JFrame jframe = new JFrame();
      jframe.setTitle("Test");
      JPanel contentpane = (JPanel)jframe.getContentPane();
      HyperFrame hf = HyperFrame.getActiveFrame();
      if(hf == null)
      hf = new HyperFrame();
      hf.setNode(n);
      contentpane.add(hf);
      jframe.setSize(200,200);
      jframe.setVisible(true);
      }
      }

      But the result is:The Hypernotes'interface can be seen in the UI,but when I try to use the "Open2" to open a saved file, it catches the following information:

      "Couldn't load from the file"

      How can I to do ? 

      My purpose  is above. May be the above source codes have some unknown problems.But how to

      achieve my purpose  ?

      Realy appreciated for your help!

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.