zoukankan      html  css  js  c++  java
  • Creating A New Mode In Your Application

    http://blogs.oracle.com/roller-ui/bsc/spider.jsp?entry=c885fd8d0e44862b010e5a6a299d2525

    尚未正式发布的Netbeans v7.1已经提供了向导用来创建mode

    ——————————————————————————————————————————————————————————————————————————————————

    Creating A New Mode In Your Application

    This is a detailed approach to creating a new mode (i.e., a position for a custom window component) in your Swing application. I encountered two problems with it, as explained in the instructions below, but at the end of it, you should have worked your way to a new position for a banner, for example, as shown in the day before yesterday's blog entry.

    1. Close down the application (e.g., the IDE). Go to your user directory. (If you don't know where that is, start the application again and go to Help > About. In the Detail tab, look at the User Dir property.)
    2. In the user directory, go to the config folder. In the config folder, delete the Windows2Local folder. This will reset the position for all of the application's windows to their default positions.
    3. Start the application. (If things look weird at this stage, you might need to delete the whole user directory.) Now everything should look as it did when you first started the application, before moving windows around. Now close the application again.
    4. Back in the user directory, go to Windows2Local/Modes. You should see the following:

      All this was generated when you closed the application. The files that end with wsmode each define a mode, which is a position in the IDE. In each of the folders, with names matching the modes, you find a file for the window/s that is/are found in the mode. For example, open the navigator folder and notice that there are two files in there—ComponentInspector.wstcref and navigatorTC.wstcref. If you open these files, you will notice the state-opened element. This determines whether the window is open (true) or closed (false) when the application starts up.

    5. Now we will create a new window. We will move it to a new position (one that is currently not defined in the application). We will then close the application and return to the Windows2Local/Modes folder. There we will see a new mode (called "anonymousMode_1.wsmode"). The information in that file we will register in the window's XML layer. So, start the IDE and take the following steps:
      1. Create a new module project. Project name: "MyBannerMode". Code name base: "org.netbeans.modules.mybannermode". Click Finish.
      2. Add this section to the XML layer:
        <folder name="Windows2">      <folder name="Modes">          <file name="banner.wsmode" url="modes/banner.wsmode"/>      </folder> </folder>
      3. Right-click the package, choose New > File/Folder. In the Other category, choose Empty File. Click Next. Name the file "banner.wsmode". Append "\\modes" to the Folder field, so that the whole field now reads "src\\org\\netbeans\\modules\\mybannermode\\modes". Click Finish.
      4. Copy the content of navigator.wsmode (from the Windows2Local/Modes folder) into your empty file, but change name unique="navigator" to name unique="banner".
      5. Check that the Projects window now looks as follows:

      6. Right-click the module and choose "Install/Reload in Development IDE".
      7. You now have a new mode, but it has the navigator mode's values. Let's change that. Create a new module, call it anything you like. Use the New Window Component wizard to create a new TopComponent, with any name you prefer. Once you've completed the wizard, open the XML layer. Change one value (the one in bold below):
        <folder name="Modes">     <folder name="banner">
      8. Install this second module. In the Window menu, use the new menu item to open your new window. Now you can move the window to the upper part of the application, spanning its length, as shown here:

        Drop it there. Close the application. Back in Windows2Local/Modes, you should see this:

      9. Notice that we have a folder called "anonymousMode_1" and a file called "anonymousMode_1.wsmode". Because the IDE doesn't recognize the position to which you moved your window, it generated that folder and file for you, assigning it this anonymous name. But that anonymousMode_1.wsmode contains the values we need! Those are the values for our new "banner" mode. So open that file, copy the content, start the application again, and paste the content into your banner.wsmode file. Then change the name "anonymousMode_1" to "banner". Install the MyBannerMode module again. Then close the application.
      10. Delete the Windows2Local folder again in the user directory. Restart the application. Create a new module with a new window component. In the first panel, you should be able to choose "banner", but I think there's a bug somewhere, because that doesn't happen for me. No "banner" appears. Bummer. Never mind, the mode will work anyway. Finish the wizard. In the XML layer, just change the mode value to "banner" (as done previously in step 7).

      When you install the module and open the window, it may not appear in the "banner" mode right away. You might need to "help" it. After moving it to the correct position the first time, it will stay there. So, there's one or two weird things in this procedure, but basically, at the end of it all, you should at least be able to fiddle your way to getting a new mode for your application. When things aren't working for you, check that Windows2Local/modes/banner contains a wstcref file for each of the new windows that you assigned to "banner" mode. If the wstcref file ends up in the correct folder, the window will be displayed in the correct mode.

    Geertjan's Blog

    Random NetBeans Stuff -- Geertjan

  • 相关阅读:
    2015-04-10一些知识点
    2015-04-07一些知识点
    斐波那契数列算法
    进制转换算法
    Java中transient有何作用?
    RandomAccessFile的使用
    Java各种类型占用的字节数
    LineNumberReader类的使用
    PreparedStatement和Statement的区别
    ResultSet几种类型的区别
  • 原文地址:https://www.cnblogs.com/cuizhf/p/2222005.html
Copyright © 2011-2022 走看看