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

📄 fuzzy_identity_frame.java~34~

📁 分别是模糊识别、模糊聚类、模糊控制的实例代码
💻 JAVA~34~
字号:
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;  private point p1,p2;  public void set_length(Vector v)  {    vp=v;  }  public void paint(Graphics g) {   g.setColor(Color.yellow);   g.fillRect(0,0,100,100);   g.setColor(Color.black);   for(int i=0;i<vp.size()-1;i++)   {      p1=(point)vp.elementAt(i);      p2=(point)vp.elementAt(i+1);      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()+image_jpanel.getLocation().x;    y=e.getY()+image_jpanel.getLocation().y;    p=new point(x,y);    v.addElement(p);    System.out.println(e.getX()+","+e.getY());    image_jpanel.set_length(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 + -