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

 

 ·jsp中能调用pl/sql存储过程吗    »显示摘要«
    摘要: 如题。 请高手指教!最好给个例子。 ......
 ·用sql语名实现模糊查找.    »显示摘要«
    摘要: 比如说表名叫table,要找的名叫cctv,在名为productname的字段里,现在我只记的ct, 用sql实现模糊查找.thank you. ......


你有没有好的想法

我要做一个画图程序,要求是画一条物体在空中的运动轨迹曲线,当鼠标移到曲线上时,可以显示当前点的各种信息,我的方案是定义一个类Position继承Point类,将速度和坐标等信息封装在内,然后让Position类实现MouseListener接口,在里面定义鼠标进入的事件。不知这样可不可以,在画图是会不会有问题。  
  那位有好的想法,还忘赐教。  
  谢谢!

NO.1   作者: littlecpu

你这样太复杂了,  
   
  简单点,  
  你写你的曲线,它不会响应mouse   event  
   
  在这个曲线的母板上(frame等),监视mouse   move事件,算算mouse   poiner和你的曲线是否近到某一阀点,如是,显示

NO.2   作者: helpall

给你一个雏形.   画两三条直线后,把鼠标移到线上就有显示了.  
  写得比较乱,将就着看吧.  
   
  import   java.awt.*;  
  import   java.awt.event.*;  
  import   java.util.*;  
   
  import   javax.swing.*;  
   
  public   class   DrawLine   extends   JFrame   {  
      private   Draw   dr;  
      public   DrawLine()  
      {  
          dr   =   new   Draw();  
          dr.setBackground(Color.white);  
          Container   c   =   getContentPane();  
          c.setLayout(new   FlowLayout());  
          c.add(dr);  
          setSize(300,300);  
          show();  
      }  
   
      public   static   void   main(String   args[])  
      {  
          DrawLine   dl   =   new   DrawLine();  
          dl.addWindowListener(   new   WindowAdapter(){  
                  public   void   windowClosing(WindowEvent   e){  
                        System.exit(0);  
                  }  
                });  
      }  
  }  
   
  class   Line   {  
        public   int   x0,y0,x1,y1;  
  }  
   
  class   Draw   extends   JPanel{  
        Vector   lines   =   new   Vector();  
        Line   cur;  
   
        public   Draw()  
        {  
              setPreferredSize(new   Dimension(150,100));  
              addMouseListener(   new   MouseAdapter()   {  
                    public   void   mousePressed(MouseEvent   e)   {  
                          if(cur   ==   null)  
                                cur   =   new   Line();  
                          cur.x0   =   e.getX();  
                          cur.y0   =   e.getY();  
                    }  
                    public   void   mouseReleased(MouseEvent   e)   {  
                          cur.x1   =   e.getX();  
                          cur.y1   =   e.getY();  
                          lines.add(cur);  
                          cur   =   null;  
                    }  
              });  
   
              addMouseMotionListener(   new   MouseMotionAdapter(){  
                    public   void   mouseDragged(MouseEvent   e){  
                          cur.x1   =   e.getX();  
                          cur.y1   =   e.getY();  
                          repaint();  
                      }  
                      public   void   mouseMoved(MouseEvent   e)   {  
                            if(!isShowInfo)  
                                  return;  
                            x   =   e.getX();y=e.getY();  
                            info   =   getInfo(x,y);  
                            System.out.println("info="+info);  
                            repaint();  
                      }  
              });  
      }  
      String   info   =""   ;  
      int   x,y;  
      private   String   getInfo(int   x,   int   y)   {  
            for(int   i   =   0;   i   <   lines.size();i++)   {  
                  Line   tmp   =   (Line)lines.elementAt(i);  
                  if(Math.abs(Point.distance(tmp.x0,tmp.y0,tmp.x1,tmp.y1)   -  
                        Point.distance(tmp.x0,tmp.y0,x,y)-Point.distance(tmp.x1,tmp.y1,x,y))   <   5   )  
                        return   "("+x+","+y+")";  
            }  
            return   "";  
      }  
      boolean   isShowInfo   =   false;  
   
      public   void   paint(Graphics   g)   {  
            super.paint(g);  
            isShowInfo   =   lines.size()   >   1;  
            Color   c   =   g.getColor();  
            g.setColor(Color.red);  
            g.drawString(info,x,y);  
            g.setColor(c);  
   
            for(int   i   =   0;i<lines.size();i++){  
                  Line   tmp   =   (Line)lines.elementAt(i);  
                  g.drawLine(tmp.x0,   tmp.y0,   tmp.x1,   tmp.y1);  
            }  
            if(cur   !=   null   )  
                  g.drawLine(cur.x0,cur.y0,cur.x1,cur.y1);  
      }  
   
  }  
 


    摘要: query 有错误 连接占线导致另一个 hstmt 是怎么回事?? 急急急 在线等待 100 分 ......
» 本期热门文章:

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