Search in sources :

Example 1 with CAPTURE_ICON_16

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");
    }
}
Also used : ActionListener(java.awt.event.ActionListener) Image(java.awt.Image) GraphicsDevice(java.awt.GraphicsDevice) Window(java.awt.Window) Point(java.awt.Point) CAPTURE_ICON_16(io.videofirst.capture.ui.constants.UiConstants.CAPTURE_ICON_16) GraphicsEnvironment(java.awt.GraphicsEnvironment) MouseEvent(java.awt.event.MouseEvent) PopupMenu(java.awt.PopupMenu) RecordPanel(io.videofirst.capture.ui.panels.RecordPanel) Dimension(java.awt.Dimension) SwingUtilities(javax.swing.SwingUtilities) MenuItem(java.awt.MenuItem) TrayIcon(java.awt.TrayIcon) AWTException(java.awt.AWTException) DisplayMode(java.awt.DisplayMode) MouseAdapter(java.awt.event.MouseAdapter) CaptureService(io.videofirst.capture.service.CaptureService) BorderLayout(java.awt.BorderLayout) SystemTray(java.awt.SystemTray) JFrame(javax.swing.JFrame) Toolkit(java.awt.Toolkit) MouseEvent(java.awt.event.MouseEvent) ActionListener(java.awt.event.ActionListener) TrayIcon(java.awt.TrayIcon) MouseAdapter(java.awt.event.MouseAdapter) MenuItem(java.awt.MenuItem) Image(java.awt.Image) PopupMenu(java.awt.PopupMenu)

Aggregations

CaptureService (io.videofirst.capture.service.CaptureService)1 CAPTURE_ICON_16 (io.videofirst.capture.ui.constants.UiConstants.CAPTURE_ICON_16)1 RecordPanel (io.videofirst.capture.ui.panels.RecordPanel)1 AWTException (java.awt.AWTException)1 BorderLayout (java.awt.BorderLayout)1 Dimension (java.awt.Dimension)1 DisplayMode (java.awt.DisplayMode)1 GraphicsDevice (java.awt.GraphicsDevice)1 GraphicsEnvironment (java.awt.GraphicsEnvironment)1 Image (java.awt.Image)1 MenuItem (java.awt.MenuItem)1 Point (java.awt.Point)1 PopupMenu (java.awt.PopupMenu)1 SystemTray (java.awt.SystemTray)1 Toolkit (java.awt.Toolkit)1 TrayIcon (java.awt.TrayIcon)1 Window (java.awt.Window)1 ActionListener (java.awt.event.ActionListener)1 MouseAdapter (java.awt.event.MouseAdapter)1 MouseEvent (java.awt.event.MouseEvent)1