myjmenuitem.java

来自「GPRS数据通讯软件源码」· Java 代码 · 共 48 行

JAVA
48
字号
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package documenteditor;import java.awt.Color;import javax.swing.Icon;import javax.swing.JMenuItem;/** * * @author Administrator */public class MyJMenuItem extends JMenuItem{        private JMenuItem self = null;        private Color oldBack = null;        public MyJMenuItem(){                super(null,(Icon)null);        oldBack = this.getBackground();        self = this;        addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {            @Override            public void mouseMoved(java.awt.event.MouseEvent evt) {                self.setBackground(Color.BLUE);                self.setForeground(Color.WHITE);            }        });        addMouseListener(new java.awt.event.MouseAdapter() {            @Override            public void mouseExited(java.awt.event.MouseEvent evt) {                self.setBackground(oldBack);                self.setForeground(Color.BLACK);            }        });    }        public void Huanyuan(){        self.setBackground(oldBack);        self.setForeground(Color.BLACK);    }    }

⌨️ 快捷键说明

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