fuzzy_identity_frame.java~1~
来自「分别是模糊识别、模糊聚类、模糊控制的实例代码」· JAVA~1~ 代码 · 共 70 行
JAVA~1~
70 行
package fuzzy_identity;import java.awt.*;import java.awt.event.*;import javax.swing.*;import com.borland.jbcl.layout.*;class Image_jpanel extends JPanel{ public void paint(Graphics g) { g.setColor(Color.yellow); g.fillRect(0,0,100,100); g.setColor(Color.black); g.drawLine(0,0,100,100); }}public class Fuzzy_Identity_Frame extends JFrame { JPanel contentPane; Image_jpanel image_jpanel; XYLayout xYLayout1 = new XYLayout(); //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 { 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) { image_jpanel.repaint(); System.out.println(e.getX()); }}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 + =
减小字号Ctrl + -
显示快捷键?