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

[img]http://dl.iteye.com/upload/attachment/196089/a7caec80-8966-3338-aaa1-a77144cfa854.jpg[/img]
当我在点击第一个“张三”按钮时弹出一个Jdialog后,让Jdialog下面的所有组件锁定,呈现出半透明状态,但是有一个问题是[b]点击的这个“张三”按钮呈现出发亮状态,没有被半透明层覆盖住[/b],其他的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覆盖住呢?
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值