-1

I have the following swing code :

import java.awt.Dimension;
import java.awt.GraphicsEnvironment;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.SwingUtilities;

public class JFrameDemo {

    private JFrame jframe = new JFrame();

    public JFrameDemo() {
        jframe.setSize(new Dimension(800, 20));
        jframe.setUndecorated(true);
        jframe.getContentPane().add(new JLabel("xxxxxxxxxxx"));
        jframe.setVisible(true);
        jframe.setAlwaysOnTop(true);
        jframe.setLocation(0, 0);

        GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
        jframe.setMaximizedBounds(env.getMaximumWindowBounds());
        jframe.toFront();
        jframe.repaint();
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                new JFrameDemo();
            }
        });
    }
}

My jframe window is always on top and also in the top of the screen but when other window from os ,like a browser window, is maximized my jframe overlaps that window . When any os windows are maximized to be maximized below my jframe window. you can see:

WRONG Behavior


current_wrong_behavior.png

GOOD Behavior


wanted_good_behavior.png

Since I understood java has no support for that feature so I am asking now if exists any native library which should I load using the jni.

aurelianr
  • 538
  • 2
  • 12
  • 35

1 Answers1

0

So the behavior that I am looking for can be made using the jna lib: Docking a java application jna on windows

Community
  • 1
  • 1
aurelianr
  • 538
  • 2
  • 12
  • 35