亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

java中可不可以移除添加在JLabel上的事件?

java中可不可以移除添加在JLabel上的事件?

叮當貓咪 2019-04-03 11:07:05
java中可不可以移除添加在JLabel上的事件
查看完整描述

5 回答

?
冉冉說

TA貢獻1877條經驗 獲得超1個贊

for(MouseListener l : label.getMouseListener()){
if(...) label.removeMouseListener(l);

}

查看完整回答
反對 回復 2019-04-06
?
慕尼黑8549860

TA貢獻1818條經驗 獲得超11個贊

可以..把在JLabel中加入圖片.然后當成JApplet的背景..JButton放在JApplet上就行

//###################################

import java.awt.FlowLayout;

import javax.swing.*;

public class Test extends JApplet{
public Test()
{
JPanel jp=(JPanel)this.getContentPane(); //從JFrame 里面創建一個JPanel
jp.setOpaque(false); //JPanel 透明模式
ImageIcon img = new ImageIcon("c://Sunset.jpg"); //創建一個圖片路徑
JLabel background = new JLabel(img); //創建個帶背景圖片的JLabel
this.getLayeredPane().add(background,new Integer(Integer.MIN_VALUE));
background.setBounds(0, 0, img.getIconWidth(), img.getIconHeight());
jp.setLayout(new FlowLayout());
JButton jb=new JButton("我是按鈕");
jp.add(jb);
}
}



查看完整回答
反對 回復 2019-04-06
?
泛舟湖上清波郎朗

TA貢獻1818條經驗 獲得超3個贊

1: JButton有setIcon(Icon icon)的方法可以設置圖片,
2: JLabel 也可以加入任意組件,add(Component c);這個方法
3:JLabel 默認布局是BorderLayout
4: 你的補充問題當然能實現,沒問題

查看完整回答
反對 回復 2019-04-06
  • 5 回答
  • 0 關注
  • 1770 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號