我目前不是java的新手,但我第一次收到此错误是我的代码示例!解释为什么即使我实现了mouseListener方法,我也似乎无法使我的代码能够与IntelliJ一起工作
package com.company;
import org.w3c.dom.events.MouseEvent;
import javax.swing.*;
import java.awt.event.MouseListener;
public class AppMenu extends JMenuBar implements MouseListener {
// Constants
private static String menufile = "File";
private static String editmenu = "Edit";
private static String aboutmenu = "About";
// Constructor
public AppMenu() {
super();
this.add(newMenu(menufile));
this.add(newMenu(editmenu));
this.add(newMenu(aboutmenu));
}
// This function create new menu for the App Menu
private JMenu newMenu(String _name){
JMenu newMenu = new JMenu(_name);
//newMenu.addMouseListener(this);
return newMenu;
}
public void mouseExited(MouseEvent e) {}
public void mousePressed(MouseEvent e) {}
public void mouseReleased(MouseEvent e) {}
public void mouseEntered(MouseEvent e) {}
public void mouseClicked(MouseEvent e) {}
}
答案 0 :(得分:1)
var query = function(sql) {
return new Promise(function(resolve, reject) {
var returnValue = "";
db.query(sql, function(error, rows) {
if (error) {
returnValue = "";
} else {
returnValue = rows[0]['url'];
console.log("in function result: " + returnValue);
}
resolve(returnValue)
});
});
};
var getSlaveURL = async function() {
var sqlQuery = "SELECT url FROM `slave` WHERE `id`='2' LIMIT 1";
let result = await query(sqlQuery)
console.log("out function result: " + result);
};
getSlaveURL();
是错误的导入,你想要
import org.w3c.dom.events.MouseEvent;
快速查看How to Write a Mouse Listener和JavaDocs for MouseListener
上的示例会突出显示特定问题