java show window JFrame JDialog always on top

We have to use this feature of java.awt.Window : Window.alwaysOnTop(boolean); Example code :

import javax.swing.JFrame;
import javax.swing.JLabel;

public class Always_on_Top_JFrame_JAVA{
    public static void main(String[] args) {
        JFrame frame = new JFrame("Title - always on top :D ");
        // Set's the window to be "always on top"
        frame.setAlwaysOnTop( true );

        frame.setLocationByPlatform( true );
        frame.add( new JLabel(" Always on TOP ") );
        frame.pack();
        frame.setVisible( true );
    }
}

No comments :

Post a Comment

Your Comment and Question will help to make this blog better...