Is it possible, in Java, to make a JPanel
skip drawing its background thus being transparent except for the components on it?
This article seems to have some handy info on how to create shaped and transparent windows in Java:
https://docs.oracle.com/javase/tutorial/uiswing/misc/trans_shaped_windows.html
class TransparentJPanel extends JPanel
{
TransparentJPanel()
{
super() ;
this.setOpaque( false ) ; // this will make the JPanel transparent
// but not its components (JLabel, TextField etc.)
this.setLayout( null ) ;
}
}
Technically a JPanel may start off non-opague. This was true for the Gtk look & feel in 1.5 (or 1.4?), but no other PL&Fs as far as I am aware.
If you are using NetBeans, Then Do these steps:-
JPanel
.JPanel
background will be removed and what will appear in
JPanel
Background is your Background of JFrame
.setOpaque(false)
It'll pass off painting the background to its parent, which may draw its own background.
You can do a screen capture and then use that to paint the background of the panel.