原代码如下: import java.awt.*; import javax.swing.*;
public class MainFrame { public static void main(String[] args) { MFrame newFrame = new MFrame(); newFrame.setDefaultCloseOperation(newFrame.EXIT_ON_CLOSE); newFrame.show(); newFrame.setVisible(true); } }
class MFrame extends JFrame { private JPanel Content; public MFrame() { Content = (JPanel)getContentPane(); setTitle("财务之星"); setBounds(100,100,300,200); //setResizable(false); //add(new PicPanel()); Content.setOpaque(false); //设内容窗格为透明。。 Content.setLayout(new FlowLayout()); Content.add(new LoginPanel()); Content.add(new JButton("确认")); //Content.add(new PicPanel()); this.getLayeredPane().setLayout(null); this.getLayeredPane().add(new PicPanel(),new Integer(Integer.MIN_VALUE)); } }
class PicPanel extends JPanel { public PicPanel() { //把图片显示在标签里。。。 JLabel picLabel = new JLabel(); picLabel.setIcon(new ImageIcon("banner.gif")); picLabel.setBounds(0,0,300,200); setOpaque(false); add(picLabel); } }
class LoginPanel extends JPanel { public LoginPanel() { JLabel loginLabel = new JLabel(); loginLabel.setText("用户名:"); //loginLabel.setBounds(0,0,300,200); add(loginLabel); } }
----------------解决方案--------------------------------------------------------
我也不知道,我也正在搞这个问题,怎么没有会玩这个的回复下啊~~~
----------------解决方案--------------------------------------------------------