I have a JFrame, inside the JFrame code I create a JWindow and on window I have created a JPanel. On JPanel is inserted a background image.
JButton btnImage= new JButton("My Button");
Image splashImg = Toolkit.getDefaultToolkit().getImage("images/image1.jpeg");
JPanel pnlSplashWindow= new JPanel(){
public void paint(Graphics g){
g.drawImage(splashImg,0,0,splashImg.getWidth(this),splashImg.getHeight(this),this);
}
};
pnlSplashWindow.setLayout(new BorderLayout());
pnlSplashWindow.add(BorderLayout.SOUTH,btnImage);
JWindo window= new JWindow(this); // this refers to my class which has extended JFrame
window.setContentPane(pnlSplashWindow);
window.setSize(688, 344);
btnImg.setVisible(true);
window.setLocationRelativeTo(this);
I am new to JWindow and have the following questions:
- How to add elements like buttons and labels on
JWindow(orJPanelwhich is on theJWindow)? - How to set my
JFrameas the parent of thisJWindow? I mean whileJWindowis active, theJFrameshould not be clickable.
An example of the desired end effect

To add components you should use:
instead. And if you don’t want your JFrame to be clickable, you should use a modal
JDialog, by extendingJDialoginstead ofJWindow.But if you want to create a Splash Screen, you should read How to create a Splash Screen.