contactButton=newJButton("修改信息");confirm=newJButton("确认修改");cancel=newJButton("取消修改");contactButton.setBounds(newRectangle(330,190,95,30));confirm.setBounds(n...
contactButton = new JButton("修改信息");
confirm = new JButton("确认修改");
cancel = new JButton("取消修改");
contactButton.setBounds(new Rectangle(330,190,95,30));
confirm.setBounds(new Rectangle(130,220,95,30));
cancel.setBounds(new Rectangle(230,220,95,30));
String url0=System.getProperty("user.dir")+"/src/images/hbtn_highlight.png";
String url1=System.getProperty("user.dir")+"/src/images/hbtn_focus.png";
String url2=System.getProperty("user.dir")+"/src/images/hbtn_down.png";
contactButton.setIcon(new ImageIcon(url0));
confirm.setIcon(new ImageIcon(url0));
cancel.setIcon(new ImageIcon(url0));
contactButton.setRolloverIcon(new ImageIcon(url1));
confirm.setRolloverIcon(new ImageIcon(url1));
cancel.setRolloverIcon(new ImageIcon(url1));
contactButton.setPressedIcon(new ImageIcon(url2));
confirm.setPressedIcon(new ImageIcon(url2));
cancel.setPressedIcon(new ImageIcon(url2));
contactButton.setBorder(null);
confirm.setBorder(null);
cancel.setBorder(null);
contactButton.setOpaque(false);
confirm.setOpaque(false);
cancel.setOpaque(false);
contactButton.setVerticalTextPosition(JButton.CENTER);
confirm.setVerticalTextPosition(JButton.CENTER);
contactButton.setHorizontalTextPosition(JButton.CENTER);
confirm.setHorizontalTextPosition(JButton.CENTER);
cancel.setVerticalTextPosition(JButton.CENTER);
cancel.setHorizontalTextPosition(JButton.CENTER);
confirm.setVisible(false);
cancel.setVisible(false);
contactButton.addActionListener(new ActionAdapter()
{
public void actionPerformed(ActionEvent e)
{
confirm.setVisible(true);
cancel.setVisible(true);
contactButton.setVisible(false);
}
});
confirm.addActionListener(new ActionAdapter()
{
public void actionPerformed(ActionEvent e)
{
confirm.setVisible(false);
cancel.setVisible(false);
contactButton.setVisible(true);
}
});
cancel.addActionListener(new ActionAdapter()
{
public void actionPerformed(ActionEvent e)
{
confirm.setVisible(false);
cancel.setVisible(false);
contactButton.setVisible(true);
}
});
这是其中一部分代码,我的目的是,刚开始时隐藏confirm和cancel这两个按钮,点击contactButton按钮时,之前两个按钮就显示出来。但是现在点击contactButton按钮时,并没有反应,那个按钮没有显示出来。
但是如果将那些图片设置的代码全部去掉后,就能够实现我想要的功能
能否有个高手来帮一下我啊!!!!
展开
最后
以上就是生动花生最近收集整理的关于java 隐藏按钮_关于java隐藏按钮的问题的全部内容,更多相关java内容请搜索靠谱客的其他文章。
发表评论 取消回复