com.sun.jna.platform.WindowUtils Java Examples

The following examples show how to use com.sun.jna.platform.WindowUtils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DesktopWindowManagerImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
private static void setAlphaMode(Window window, float ratio) {
  try {
    if (SystemInfo.isMacOSLeopard) {
      if (window instanceof JWindow) {
        ((JWindow)window).getRootPane().putClientProperty("Window.alpha", 1.0f - ratio);
      }
      else if (window instanceof JDialog) {
        ((JDialog)window).getRootPane().putClientProperty("Window.alpha", 1.0f - ratio);
      }
      else if (window instanceof JFrame) {
        ((JFrame)window).getRootPane().putClientProperty("Window.alpha", 1.0f - ratio);
      }
    }
    else if (isTranslucencySupported()) {
      window.setOpacity(1.0f - ratio);
    }
    else {
      WindowUtils.setWindowAlpha(window, 1.0f - ratio);
    }
  }
  catch (Throwable e) {
    LOG.debug(e);
  }
}
 
Example #2
Source File: NativeWindowSystemImpl.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void setWindowMask(Window w, Icon mask) {
    try {
        WindowUtils.setWindowMask(w, mask);
    } catch( ThreadDeath td ) {
        throw td;
    } catch( Throwable e ) {
        LOG.log(Level.INFO, null, e);
    }
}
 
Example #3
Source File: AppMain.java    From MercuryTrade with MIT License 5 votes vote down vote up
private static String getGamePath() {
    return WindowUtils.getAllWindows(false).stream().filter(window -> {
        char[] className = new char[512];
        User32.INSTANCE.GetClassName(window.getHWND(), className, 512);
        return Native.toString(className).equals("POEWindowClass");
    }).map(it -> {
        String filePath = it.getFilePath();
        return StringUtils.substringBeforeLast(filePath, "\\");
    }).findAny().orElse(null);
}
 
Example #4
Source File: MercuryStoreCoreTest.java    From MercuryTrade with MIT License 5 votes vote down vote up
@Test
public void testSoundReducer() throws IOException {
    TestSubscriber<Map<String,String>> testSubscriber = new TestSubscriber<>();
    List<DesktopWindow> allWindows = WindowUtils.getAllWindows(false);
    allWindows.forEach(window -> {
        System.out.println(window.getFilePath());
    });
}
 
Example #5
Source File: UIServiceImpl.java    From jitsi with Apache License 2.0 5 votes vote down vote up
/**
 * Repaints and revalidates the whole UI Tree.
 *
 * Calls {@link SwingUtilities#updateComponentTreeUI(Component c)}
 * for every window owned by the application which cause UI skin and
 * layout repaint.
 */
public void repaintUI()
{
    if(!SwingUtilities.isEventDispatchThread())
    {
        SwingUtilities.invokeLater(new Runnable()
        {
            public void run()
            {
                repaintUI();
            }
        });
        return;
    }

    if (UIManager.getLookAndFeel() instanceof SIPCommLookAndFeel)
        ((SIPCommLookAndFeel) UIManager.getLookAndFeel()).loadSkin();

    Constants.reload();
    ImageLoader.clearCache();

    Window[] windows
        = net.java.sip.communicator.plugin.desktoputil.WindowUtils
            .getWindows();

    for(Window win : windows)
    {
        reloadComponents(win);
        ComponentUtils.updateComponentTreeUI(win);
    }
}
 
Example #6
Source File: DesktopWindowManagerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static boolean calcAlphaModelSupported() {
  GraphicsDevice device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
  if (device.isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency.TRANSLUCENT)) {
    return true;
  }
  try {
    return WindowUtils.isWindowAlphaSupported();
  }
  catch (Throwable e) {
    return false;
  }
}
 
Example #7
Source File: DesktopWindowManagerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void setWindowMask(final Window window, @Nullable final Shape mask) {
  try {
    if (isPerPixelTransparencySupported()) {
      window.setShape(mask);
    }
    else {
      WindowUtils.setWindowMask(window, mask);
    }
  }
  catch (Throwable e) {
    LOG.debug(e);
  }
}
 
Example #8
Source File: UIServiceImpl.java    From jitsi with Apache License 2.0 4 votes vote down vote up
/**
 * Initializes all frames and panels and shows the GUI.
 */
void loadApplicationGui()
{
    this.setDefaultThemePack();

    // Initialize the single window container if we're in this case. This
    // should be done before initializing the main window, because he'll
    // search for it.
    if (ConfigurationUtils.isSingleWindowInterfaceEnabled())
        singleWindowContainer = new SingleWindowContainer();

    // Initialize the main window.
    this.mainFrame = new MainFrame();

    if (UIManager.getLookAndFeel() instanceof SIPCommLookAndFeel)
        initCustomFonts();

    /*
     * The mainFrame isn't fully ready without the MetaContactListService so
     * make sure it's set before allowing anything, such as LoginManager, to
     * use the mainFrame. Otherwise, LoginManager, for example, will call
     * back from its event listener(s) into the mainFrame and cause a
     * NullPointerException.
     */
    mainFrame.setContactList(GuiActivator.getContactListService());

    // Initialize main window bounds.
    this.mainFrame.initBounds();

    // Register the main window as an exported window, so that other bundles
    // could access it through the UIService.
    GuiActivator.getUIService().registerExportedWindow(mainFrame);

    // Initialize the login manager.
    this.loginManager = new LoginManager(new LoginRendererSwingImpl());

    this.popupDialog = new PopupDialogImpl();

    this.wizardContainer = new AccountRegWizardContainerImpl(mainFrame);

    if (ConfigurationUtils.isTransparentWindowEnabled())
    {
        try
        {
            WindowUtils.setWindowTransparent(mainFrame, true);
        }
        catch (UnsupportedOperationException ex)
        {
            logger.error(ex.getMessage(), ex);
            ConfigurationUtils.setTransparentWindowEnabled(false);
        }
    }

    if(ConfigurationUtils.isApplicationVisible()
        || Boolean.getBoolean("disable-tray")
        || ConfigurationUtils.isMinimizeInsteadOfHide())
    {
        mainFrame.setFrameVisible(true);
    }

    SwingUtilities.invokeLater(new RunLoginGui());

    this.initExportedWindows();

    KeyboardFocusManager focusManager
        = KeyboardFocusManager.getCurrentKeyboardFocusManager();
    focusManager.addKeyEventDispatcher(
            new KeyBindingsDispatching(focusManager));

    maybeShowMasterPasswordMissingWarningDialog();
}
 
Example #9
Source File: UIServiceImpl.java    From jitsi with Apache License 2.0 4 votes vote down vote up
/**
 * Indicates that a <tt>PropertyChangeEvent</tt> has occurred.
 *
 * @param evt the <tt>PropertyChangeEvent</tt> that notified us
 */
public void propertyChange(PropertyChangeEvent evt)
{
    String propertyName = evt.getPropertyName();

    if (propertyName.equals(
        "impl.gui.IS_TRANSPARENT_WINDOW_ENABLED"))
    {
        String isTransparentString = (String) evt.getNewValue();

        boolean isTransparentWindowEnabled
            = Boolean.parseBoolean(isTransparentString);

        try
        {
            WindowUtils.setWindowTransparent(   mainFrame,
                isTransparentWindowEnabled);
        }
        catch (UnsupportedOperationException ex)
        {
            logger.error(ex.getMessage(), ex);

            if (isTransparentWindowEnabled)
            {
                ResourceManagementService resources
                    = GuiActivator.getResources();

                new ErrorDialog(
                        mainFrame,
                        resources.getI18NString("service.gui.ERROR"),
                        resources.getI18NString(
                                "service.gui.TRANSPARENCY_NOT_ENABLED"))
                    .showDialog();
            }

            ConfigurationUtils.setTransparentWindowEnabled(false);
        }
    }
    else if (propertyName.equals(
        "impl.gui.WINDOW_TRANSPARENCY"))
    {
        mainFrame.repaint();
    }
}