我希望菜单栏上的菜单可以在鼠标上更改其背景颜色..就像在大多数应用程序中一样.
我想要这个效果 - > 示例图片
到目前为止我尝试过的...
public class Menu extends JMenuBar implements ActionListener {
private JMenuItem fileItem_close;
private final MouseListener mouseAction = new MouseAdapter() { //i use this to apply the mouse event
@Override
public void mouseEntered(MouseEvent e) {
JMenu item = (JMenu)e.getSource(); //is this implementation correct ?
item.setOpaque(true);
};
@Override
public void mouseExited(MouseEvent e) {
JMenu item = (JMenu)e.getSource();
item.setOpaque(false);
};
};
public Menu() {
initFileMenu();
}
private void initFileMenu() {
JMenu fileMenu = new JMenu("File");
fileMenu.setMnemonic('F');
fileMenu.setRolloverEnabled(true);
fileItem_close …Run Code Online (Sandbox Code Playgroud) 嗨,我试图通过谷歌SMTP发送一封电子邮件,
我认为代码是正确的,但我得到以下异常..
"G:\Installed Applications\Python\Python35-32\python.exe" "C:/Users/brand/Desktop/Test Projects/Python Projects/SMTP.py"
Traceback (most recent call last):
File "C:/Users/brand/Desktop/Test Projects/Python Projects/SMTP.py", line 22, in <module>
server.login(sender, password)
File "G:\Installed Applications\Python\Python35-32\lib\smtplib.py", line 730, in login
raise last_exception
File "G:\Installed Applications\Python\Python35-32\lib\smtplib.py", line 721, in login
initial_response_ok=initial_response_ok)
File "G:\Installed Applications\Python\Python35-32\lib\smtplib.py", line 627, in auth
initial_response = (authobject() if initial_response_ok else None)
File "G:\Installed Applications\Python\Python35-32\lib\smtplib.py", line 664, in auth_login
raise SMTPAuthenticationError(code, resp)
smtplib.SMTPAuthenticationError: (502, b'5.5.1 Unrecognized command. m16sm36193099wmb.13 - gsmtp')
Process finished with exit code 1
Run Code Online (Sandbox Code Playgroud)
我的代码显示在这里:
import smtplib …Run Code Online (Sandbox Code Playgroud)