use of io.videofirst.capture.ui.constants.UiConstants.CAPTURE_ICON_16 in project vft-capture by videofirst.
the class VfCaptureFrame method setupSystemTray.
// Private methods
private void setupSystemTray() {
if (SystemTray.isSupported()) {
tray = SystemTray.getSystemTray();
Image image = Toolkit.getDefaultToolkit().getImage(CAPTURE_ICON_16);
ActionListener exitListener = e -> System.exit(0);
PopupMenu popup = new PopupMenu();
MenuItem defaultItem = new MenuItem("Exit");
defaultItem.addActionListener(exitListener);
popup.add(defaultItem);
defaultItem = new MenuItem("Open");
defaultItem.addActionListener(e -> {
showCaptureFrame();
});
popup.add(defaultItem);
trayIcon = new TrayIcon(image, "Video First Capture", popup);
trayIcon.setImageAutoSize(true);
trayIcon.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
if (SwingUtilities.isLeftMouseButton(e)) {
showCaptureFrame();
}
}
});
addWindowStateListener(e -> {
if (e.getNewState() == ICONIFIED || e.getNewState() == 7) {
trayHide(true);
}
if (e.getNewState() == MAXIMIZED_BOTH || e.getNewState() == NORMAL) {
trayHide(false);
}
});
} else {
System.out.println("system tray not supported");
}
}
Aggregations