我有一个JFrame, 在JFrame我创建的代码中,我JWindow在窗口上创建了一个JPanel. OnJPanel插入背景图像。
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);
我是新手JWindow,有以下问题:
- 如何在
JWindow(或JPanel在JWindow)上添加按钮和标签等元素? - 如何将 my 设置
JFrame为 this 的父级JWindow?我的意思是当JWindow它处于活动状态时,它JFrame不应该是可点击的。
所需最终效果的示例
