小菜樂園

          生活就是一杯茶

            BlogJava :: 首頁 :: 聯系 :: 聚合  :: 管理
            8 Posts :: 0 Stories :: 3 Comments :: 0 Trackbacks

           

          我照著《VRML與Java編程技術》,寫了這樣的一個程序,但是沒效果出來

          請高手們指教啊!!!

          vrml文件:

          #VRML V2.0 utf8

          Viewpoint
          {
           position 0 0 15
           orientation 0 0 1 0
           fieldOfView 0.8
          }

          Background
          {
           skyColor [ 0 0 0.2,
                 0.1 0.1 0.8,
                 0.7 0.8 0.9
                ]
           skyAngle [1 1.57]
           groundColor [ 0.0 0.0 0.0,
                  0.5 0.4 0.3,
                  0.3 0.3 0.3
                 ]
           groundAngle [1 1.57]
          }

          DEF ball1 Transform
          {
           translation -3 0 0
           children
           [
             DEF Touch1 TouchSensor{}
             Shape
             {
              appearance Appearance
              {
                material DEF SphereColor Material
                {
                 diffuseColor 1 0 0
                }
              }
               geometry Sphere{}
             }
           ]
          }

          DEF ball2 Transform
          {
           translation 3 0 0
           children
           [
             DEF Touch2 TouchSensor{}
             Shape
             {
              appearance Appearance
              {
                material DEF SphereColor2 Material
                {
                 diffuseColor 0 1 0
                }
              }
               geometry Sphere{}
             }
           ]
          }

          DEF openWnd Script
          {
           url"layOut.class"
           eventIn SFBool clicked
           eventIn SFBool clicked2
          }
          ROUTE Touch1.isActive TO openWnd.clicked
          ROUTE Touch2.isActive TO openWnd.clicked2

           

           

           

          Java窗體程序:

          import java.awt.*;
          import javax.swing.*;

          public class TheFirstWindow extends Frame{
           
           public static void main(String args[]){
            TheFirstWindow opp = new TheFirstWindow();
            opp.show();
            opp.resize(500,400);
            opp.setTitle("我的窗口");
           }
           
           public TheFirstWindow(){
            Label labely = new Label("歡迎進入我的第一個窗口",Label.LEFT);
            add(labely);
            Panel pp = new Panel();
            pp.add(new Button("打開"));
            pp.add(new Button("關閉"));
            pp.add(new Button("更多內容"));
            pp.setBackground(Color.red);
            add(pp);
            Panel p = new Panel();
            p.add(new TextArea("",6,25));
            p.add(new Button("保存"));
            p.add(new Button("我要留言"));
            p.add(new Button("全部刪除"));
            p.setBackground(Color.green);
            setLayout(new FlowLayout());
            add(p);
           }
           
           public boolean handleEvent(Event e){
            TextField t = new TextField();
            switch(e.id){
             case Event.WINDOW_DESTROY:
              dispose();
              System.exit(0);
              default:
               return super.handleEvent(e);
            }
           }

          }

           

           

           

          與vrml通信的程序:

          import vrml.*;
          import vrml.field.*;
          import vrml.node.*;


          public class layOut extends Script{
           
           TheFirstWindow myWindow;
           
           public void initialize()
           {
             myWindow = new TheFirstWindow();
           }
           
           public void processEvent(Event e)
           {
            ConstSFBool v = (ConstSFBool)e.getValue();
            if(v.getValue())
            {
             if(e.getName().equals("clicked") == true)
             {
              myWindow.show();
             }
             else
             {
              myWindow.hide();
             }
            }
           }
          }

          posted on 2007-08-15 11:39 小菜 閱讀(974) 評論(1)  編輯  收藏

          Feedback

          # re: java如何在vrml里彈出窗口 2007-08-16 10:59 小菜
          網上找到的,不知道有沒有
          -----------------------------------------------------------------
          如果用的是cortona,需要用jdk1.3或更低版本的jdk編譯。個人猜測是因為cortona使用的microsoft的jvm,微軟已經停止開發了,對java的一些新特性不支持。
          推薦使用OctagaPlayer。不管是使用web3d提供的vrml97.zip還是cortona里的classes.zip包編譯生成的class文件,它都能識別出來。不過對于System.out.println()不能輸出到控制臺。調試不方便。已經確認jdk1.3,1.5編譯的class文件可以識別。
          -----------------------------------------------------------------  回復  更多評論
            

          # re: java如何在vrml里彈出窗口 2007-08-28 12:08 姜利陽
          百度一下  回復  更多評論
            


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 高碑店市| 吴忠市| 和平县| 通许县| 军事| 普格县| 虹口区| 呼图壁县| 万山特区| 康平县| 阳春市| 岑溪市| 商洛市| 新平| 沁源县| 乌拉特中旗| 岚皋县| 祁连县| 伊宁县| 昭觉县| 宜春市| 锡林郭勒盟| 云和县| 汾阳市| 富蕴县| 平湖市| 山阴县| 通渭县| 永康市| 赫章县| 肥乡县| 江永县| 沿河| 德兴市| 武鸣县| 哈密市| 六安市| 新昌县| 黑山县| 黄梅县| 泸水县|