SystemTray.getSystemTray() 错误,找不到 class
SystemTray.getSystemTray() error, can't Find a class
我的代码有问题。我的 IDE (NetBeans) 显示不存在像“.getSystemTray()”这样的 class。我到处都在寻找,但找不到答案。你知道为什么会这样吗?
这一行 -
final SystemTray tray = new SystemTray.getSystemTray();
不起作用。
在此先感谢您的帮助
此致
有一个密码:
import java.awt.*;
import java.net.URL;
import javax.swing.*;
public class DisplayTrayIcon {
static TrayIcon TRAY_ICON;
public DisplayTrayIcon(){
SHOW_TRAY_ICON();
}
public static void SHOW_TRAY_ICON(){
if(!SystemTray.isSupported()){
System.err.println("Error, TrayIcon not supported!");
System.exit(0);
}
TRAY_ICON = new TrayIcon(CREATE_ICON("LogoOnTime.png","Tray Icon"));
final SystemTray tray = new **SystemTray.getSystemTray()**;
}
protected static Image CREATE_ICON(String path, String desc){
URL ImageURL = DisplayTrayIcon.class.getResource(path);
return (new ImageIcon(ImageURL, desc)).getImage();
}
}
嗯,我不知道 SystemTray
class。
您需要删除 new
关键字并如下所示:
final SystemTray tray = SystemTray.getSystemTray();
我的代码有问题。我的 IDE (NetBeans) 显示不存在像“.getSystemTray()”这样的 class。我到处都在寻找,但找不到答案。你知道为什么会这样吗?
这一行 -
final SystemTray tray = new SystemTray.getSystemTray();
不起作用。
在此先感谢您的帮助
此致
有一个密码:
import java.awt.*;
import java.net.URL;
import javax.swing.*;
public class DisplayTrayIcon {
static TrayIcon TRAY_ICON;
public DisplayTrayIcon(){
SHOW_TRAY_ICON();
}
public static void SHOW_TRAY_ICON(){
if(!SystemTray.isSupported()){
System.err.println("Error, TrayIcon not supported!");
System.exit(0);
}
TRAY_ICON = new TrayIcon(CREATE_ICON("LogoOnTime.png","Tray Icon"));
final SystemTray tray = new **SystemTray.getSystemTray()**;
}
protected static Image CREATE_ICON(String path, String desc){
URL ImageURL = DisplayTrayIcon.class.getResource(path);
return (new ImageIcon(ImageURL, desc)).getImage();
}
}
嗯,我不知道 SystemTray
class。
您需要删除 new
关键字并如下所示:
final SystemTray tray = SystemTray.getSystemTray();