swing富客户端的专家们来看看Jbutton没有被盖住 这是咋回事?

swing富客户端的专家们来看看Jbutton没有被盖住 这是咋回事?
当我在点击第一个“张三”按钮时弹出一个Jdialog后,让Jdialog下面的所有组件锁定,呈现出半透明状态,但是有一个问题是 点击的这个“张三”按钮呈现出发亮状态,没有被半透明层覆盖住,其他的Jbutton覆盖住了。

我的Jbutton按钮都在Jpanel上面放着。
希望swing专家们给点意见。这种原因是怎么遭成的。


图片见附件! 提前谢谢同志们了。

“张三按钮”所在的Jpanel 代码如下:
public class PhoneTeamPanel extends javax.swing.JPanel {
    //背景图片

    public String img;
    //背景图片的x坐标
    int x;
    //背景图片的y坐标
    int y;
    AddressDialog dialog ;
    /** Creates new form PhoneTeamPanel */
    public PhoneTeamPanel(final JFrame frame,String img, int x, int y) {
        this.img = img;
        this.x = x;
        this.y = y;
        initComponents();
       
        
        //设置电话分组用户姓名
         setPhoneGroupPeopleName(peopleName,"张三");
        dialog = new AddressDialog(frame, true);
         
        peopleName.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            //frame set
            
             ((JPanel)frame.getContentPane()).setBackground(new Color(231, 231,231, 130));
             ((JPanel)frame.getContentPane()).setOpaque(true);
             ((JPanel)frame.getContentPane()).repaint();

             ((JPanel)dialog.getContentPane()).setOpaque(false);
            ImageIcon imgIc = new ImageIcon(ImagesPath.NUMBERFUCTION_BG);
            JLabel backLabel = new JLabel(imgIc);
            backLabel.setBounds(0,0, imgIc.getIconWidth(), imgIc.getIconHeight());
            dialog.setBounds(240, 230,imgIc.getIconWidth(), imgIc.getIconHeight());
            dialog.getLayeredPane().add(backLabel,new Integer(Integer.MIN_VALUE));
            dialog.setUndecorated(true);
            dialog.setVisible(true);
         }
       });
       
//       dialog.setDefaultLookAndFeelDecorated(true);
    }
    //JButton的标题
    JLabel buttonLabel;

        /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
    private void initComponents() {

        peopleName = new javax.swing.JButton();
               
        setBackground(new java.awt.Color(255, 255, 255));
        setOpaque(false);
        setPreferredSize(new java.awt.Dimension(600, 310));
        setRequestFocusEnabled(false);

              
        peopleName.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/phoneGroup_peopleNameB.png"))); // NOI18N
        peopleName.setBorderPainted(false);
        peopleName.setFocusPainted(false);
        peopleName.setPreferredSize(new java.awt.Dimension(85, 39));

       
       
    }// </editor-fold>                        

    // Variables declaration - do not modify                     

    private javax.swing.JButton peopleName;
          

    /*
     *绘制Panel背景
     */
    public void paintComponent(Graphics g) {
        ImageIcon imgbg = new ImageIcon(img);
        g.drawImage(imgbg.getImage(), x, y, null);
    }

}



Jframe 构造器中 PhoneTeamPanel 类的代码:
PhoneTeamPanel  ptp = new PhoneTeamPanel(this,ImagesPath.PHONEGROUP_BG, 3,13);
        ptp.setBounds(3, 15, frameWidth, frameHeight);
        this.getLayeredPane().add(ptp);


PhoneTeamPanel 类放到了Jframe的LayeredPane层上了。当点击PhoneTeamPanel上张三按钮后把
 ((JPanel)frame.getContentPane()).setBackground(new Color(231, 231,231, 130));

ContentPane层的背景设置为半透明为130的半透明效果。问题是为什么没有把张三这个Jbutton覆盖住呢?

你可能感兴趣的:(swing)