Skip to content

Instantly share code, notes, and snippets.

@Bios-Marcel
Created July 30, 2018 07:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Bios-Marcel/3f00ba61543d867dec21541d549d697c to your computer and use it in GitHub Desktop.
Save Bios-Marcel/3f00ba61543d867dec21541d549d697c to your computer and use it in GitHub Desktop.
Creating a Frame that stays in the background (Swing only)
import java.awt.Color;
import java.awt.Dimension;
import javax.swing.JPanel;
import javax.swing.JWindow;
public class SturdyWindow
{
public static void main( final String[] args )
{
final JWindow demoWindow = new JWindow();
final JPanel bigRedPanel = new JPanel();
final Dimension size = new Dimension( 800, 600 );
bigRedPanel.setMinimumSize( size );
bigRedPanel.setPreferredSize( size );
bigRedPanel.setBackground( Color.RED );
demoWindow.add( bigRedPanel );
demoWindow.pack();
demoWindow.setVisible( true );
demoWindow.toBack();
}
}
@Bios-Marcel
Copy link
Author

Bios-Marcel commented Jul 30, 2018

TODO:

  • Make moveable and resizable
  • Try the same with JavaFX

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment