我有一个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
不应该是可点击的。