⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fuzzy_identity_frame.java~43~

📁 分别是模糊识别、模糊聚类、模糊控制的实例代码
💻 JAVA~43~
字号:
package fuzzy_identity;import java.awt.*;import java.awt.event.*;import javax.swing.*;import com.borland.jbcl.layout.*;import java.util.*;class point{  int x,y;  point(int a,int b)  {x=a;y=b;}}class Image_jpanel extends JPanel{  private Vector vp=null;  private point p1,p2;  private int count;  public void vec(Vector v)  {    vp=v;  }  public void paint(Graphics g) {   g.setColor(Color.yellow);   g.fillRect(0,0,100,100);   g.setColor(Color.black);   if(vp==null)     count=0;   else     count=vp.size();   for(int i=0;i<count-1;i++)   {      p1=(point)vp.elementAt(i);      p2=(point)vp.elementAt(i+1);      System.out.println(p1.x);      g.drawLine(p1.x,p1.y,p2.x,p2.y);   } }}public class Fuzzy_Identity_Frame extends JFrame {  JPanel contentPane;  Image_jpanel image_jpanel;  XYLayout xYLayout1 = new XYLayout();  point p;  int x,y;  Vector v=new Vector();  //Construct the frame  public Fuzzy_Identity_Frame() {    enableEvents(AWTEvent.WINDOW_EVENT_MASK);    try {      jbInit();    }    catch(Exception e) {      e.printStackTrace();    }  }  //Component initialization  private void jbInit() throws Exception  {    x=y=0;    contentPane = (JPanel) this.getContentPane();    contentPane.setLayout(xYLayout1);    this.setResizable(false);    this.setSize(new Dimension(300, 200));    this.setTitle("模糊识别");    image_jpanel=new Image_jpanel();    image_jpanel.addMouseMotionListener(new Fuzzy_Identity_Frame_image_jpanel_mouseMotionAdapter(this));    contentPane.add(image_jpanel,new XYConstraints(100, 20, 100, 100));  }  //Overridden so we can exit when window is closed  protected void processWindowEvent(WindowEvent e) {    super.processWindowEvent(e);    if (e.getID() == WindowEvent.WINDOW_CLOSING) {      System.exit(0);    }  }  void image_jpanel_mouseDragged(MouseEvent e) {    x=e.getX();    y=e.getY();    p=new point(x,y);    v.addElement(p);    image_jpanel.vec(v);    image_jpanel.repaint();  }}class Fuzzy_Identity_Frame_image_jpanel_mouseMotionAdapter extends java.awt.event.MouseMotionAdapter {  Fuzzy_Identity_Frame adaptee;  Fuzzy_Identity_Frame_image_jpanel_mouseMotionAdapter(Fuzzy_Identity_Frame adaptee) {    this.adaptee = adaptee;  }  public void mouseDragged(MouseEvent e) {    adaptee.image_jpanel_mouseDragged(e);  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -