当前位置:首页
开发技术指南» 文章正文
    引言:

 ·加载资源dll的问题    »显示摘要«
    摘要: 我编了一个程序,程序中要使用一个资源dll,但是我这个程序既不使用mfc,也不使用atl,也就是说不能使用afxsetresourcehandle、setresourceinstance之类的函数,请问各位该如何将我程序使用的资源指向这个资源dll ......
    摘要: 本人初学,现在只会将文件读取出来,请问如果要实现上面的效果,应该怎么处理呢? 请最好给出示例代码 多谢!!!!!!!! ......


初学者一个简单程序的问题有分

左边是绘图面板,右边有一个滑杆用来控制角度!使一个点围绕另一个点画直线!怎么就有问题呢?!本人使初学者,这个问题可能比较弱,还望大家不要笑话:)  
  import   java.awt.*;  
  import   java.awt.event.*;  
  import   java.applet.*;  
  import   javax.swing.*;  
  import   javax.swing.event.*;  
   
  class   myPane  
          extends   JPanel   {  
      int   x1   =   300;  
      int   y1   =   300;  
      int   x2;  
      int   y2;  
      int   Angle;  
   
      public   myPane()   {  
          x2   =   (int)   (x1   +   200   *   Math.cos(this.getAngle()));  
          y2   =   (int)   (y1   +   200   *   Math.sin(this.getAngle()));  
      }  
   
      public   void   setAngle(int   a)   {  
          Angle   =   a;  
      }  
      public   int   getAngle()   {  
          return   Angle;  
      }  
   
      public   void   paintComponent(Graphics   g)   {  
          super.paintComponent(g);  
          g.drawLine(x1,   y1,   x2,   y2);  
      }  
   
  }  
   
  public   class   Applet1  
          extends   JApplet   {  
      private   boolean   isStandalone   =   false;  
      myPane   p   =   new   myPane();  
      JPanel   control   =   new   JPanel();  
      JSlider   slider   =   new   JSlider(0,   360,   30);  
      //Get   a   parameter   value  
      public   String   getParameter(String   key,   String   def)   {  
          return   isStandalone   ?   System.getProperty(key,   def)   :  
                  (getParameter(key)   !=   null   ?   getParameter(key)   :   def);  
      }  
   
      //Construct   the   applet  
      public   Applet1()   {  
      }  
   
      //Initialize   the   applet  
      public   void   init()   {  
          try   {  
              jbInit();  
          }  
          catch   (Exception   e)   {  
              e.printStackTrace();  
          }  
      }  
   
      //Component   initialization  
      private   void   jbInit()   throws   Exception   {  
          this.setSize(new   Dimension(800,   600));  
   
          Container   contentPane   =   getContentPane();  
          contentPane.setLayout(new   BorderLayout());  
          contentPane.add(p,   BorderLayout.CENTER);  
          contentPane.add(control,   BorderLayout.EAST);  
          control.add(slider);  
          slider.setMajorTickSpacing(90);  
          slider.setMinorTickSpacing(30);  
          slider.setPaintLabels(true);  
          slider.setPaintLabels(true);  
          slider.addChangeListener(new   ChangeListener()   {  
              public   void   stateChanged(ChangeEvent   e)   {  
                  p.setAngle(slider.getValue());  
                  p.repaint();  
              }  
          }  
          );  
      }  
   
      //Get   Applet   information  
      public   String   getAppletInfo()   {  
          return   "Applet   Information";  
      }  
   
      //Get   parameter   info  
      public   String[][]   getParameterInfo()   {  
          return   null;  
      }  
   
      //static   initializer   for   setting   look   &   feel  
      static   {  
          try   {  
              //UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());  
              //UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());  
          }  
          catch   (Exception   e)   {  
          }  
      }  
  }

NO.1   作者: aico

//修改后代码  
  import   java.awt.*;  
  import   java.awt.event.*;  
  import   java.applet.*;  
  import   javax.swing.*;  
  import   javax.swing.event.*;  
   
  class   myPane  
          extends   JPanel   {  
      int   x1   =   300;  
      int   y1   =   300;  
      int   x2;  
      int   y2;  
      int   Angle;  
   
      public   myPane()   {  
          setPreferredSize(new   Dimension(800,600));                                                             //此处设Size  
      }  
   
      public   void   setAngle(int   a)   {  
          Angle   =   a;  
      }  
      public   int   getAngle()   {  
          return   Angle;  
      }  
   
      public   void   paintComponent(Graphics   g)   {  
          super.paintComponent(g);  
          x2   =   (int)   (x1   +   200   *   Math.cos(this.getAngle()*Math.PI/180));                         //此处计算  
          y2   =   (int)   (y1   +   200   *   Math.sin(this.getAngle()*Math.PI/180));  
          g.drawLine(x1,   y1,   x2,   y2);  
      }  
   
  }  
   
  public   class   Applet1  
          extends   JApplet   {  
      private   boolean   isStandalone   =   false;  
      myPane   p   =   new   myPane();  
      JPanel   control   =   new   JPanel();  
      JSlider   slider   =   new   JSlider(0,   360,   30);  
      //Get   a   parameter   value  
      public   String   getParameter(String   key,   String   def)   {  
          return   isStandalone   ?   System.getProperty(key,   def)   :  
                  (getParameter(key)   !=   null   ?   getParameter(key)   :   def);  
      }  
   
      //Construct   the   applet  
      public   Applet1()   {  
      }  
   
      //Initialize   the   applet  
      public   void   init()   {  
          try   {  
              jbInit();  
          }  
          catch   (Exception   e)   {  
              e.printStackTrace();  
          }  
      }  
   
      //Component   initialization  
      private   void   jbInit()   throws   Exception   {  
          this.setSize(new   Dimension(800,   600));  
   
          Container   contentPane   =   getContentPane();  
          contentPane.setLayout(new   BorderLayout());  
          contentPane.add(p,   BorderLayout.CENTER);  
          contentPane.add(control,   BorderLayout.EAST);  
          control.add(slider);  
          slider.setMajorTickSpacing(90);  
          slider.setMinorTickSpacing(30);  
          slider.setPaintLabels(true);  
          slider.setPaintLabels(true);  
          slider.addChangeListener(new   ChangeListener()   {  
              public   void   stateChanged(ChangeEvent   e)   {  
                  p.setAngle(slider.getValue());  
                  p.repaint();  
                  System.out.println("changed");  
              }  
          }  
          );  
      }  
   
      //Get   Applet   information  
      public   String   getAppletInfo()   {  
          return   "Applet   Information";  
      }  
   
      //Get   parameter   info  
      public   String[][]   getParameterInfo()   {  
          return   null;  
      }  
   
      //static   initializer   for   setting   look   &   feel  
      static   {  
          try   {  
              //UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());  
              //UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());  
          }  
          catch   (Exception   e)   {  
          }  
      }  
  }  
 


    摘要: 上午成绩: 34 下午成绩: 50 论  文: 45 ( 合格 ) 是否通过: 否 ......
» 本期热门文章:

©2000-2007 All Rights Reserved. 最佳浏览:1024X768 MSIE