5 回答

TA貢獻1877條經驗 獲得超1個贊
for(MouseListener l : label.getMouseListener()){
if(...) label.removeMouseListener(l);
}

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);
}
}

TA貢獻1818條經驗 獲得超3個贊
1: JButton有setIcon(Icon icon)的方法可以設置圖片,
2: JLabel 也可以加入任意組件,add(Component c);這個方法
3:JLabel 默認布局是BorderLayout
4: 你的補充問題當然能實現,沒問題
添加回答
舉報