可以讲的再详细一点吗!
用鼠标响应 ImageIcon leftButtonIcon = new ImageIcon("images/right.gif");
        ImageIcon middleButtonIcon = new ImageIcon("images/middle.gif");
        ImageIcon rightButtonIcon = new ImageIcon("images/left.gif");        b1 = new JButton("Disable middle button", leftButtonIcon);
        b1.setVerticalTextPosition(AbstractButton.CENTER);/**设置垂直文本位置*/
        b1.setHorizontalTextPosition(AbstractButton.LEFT);/**设置水平文本位置*/
        b1.setMnemonic(KeyEvent.VK_D);/**加一个键盘上的快捷键*/
        b1.setActionCommand("disable");/**Sets the command name for the action event fired by this button. 
         By default this action command is set to match the label of the button*/        b2 = new JButton("Middle button", middleButtonIcon);
        b2.setVerticalTextPosition(AbstractButton.BOTTOM);
        b2.setHorizontalTextPosition(AbstractButton.CENTER);
        b2.setMnemonic(KeyEvent.VK_M);        b3 = new JButton("Enable middle button", rightButtonIcon);
        //Use the default text position of CENTER, RIGHT.
        b3.setMnemonic(KeyEvent.VK_E);
        b3.setActionCommand("enable");
        b3.setEnabled(false);/**Sets the enabled state of the object,
         if true, enables this object; otherwise, disables it*/        //Listen for actions on buttons 1 and 3.
        b1.addActionListener(this)

解决方案 »

  1.   

    可以讲的再详细一点吗!
    用鼠标响应吗??
     ImageIcon leftButtonIcon = new ImageIcon("images/right.gif");
            ImageIcon middleButtonIcon = new ImageIcon("images/middle.gif");
            ImageIcon rightButtonIcon = new ImageIcon("images/left.gif");        b1 = new JButton("Disable middle button", leftButtonIcon);
            b1.setVerticalTextPosition(AbstractButton.CENTER);/**设置垂直文本位置*/
            b1.setHorizontalTextPosition(AbstractButton.LEFT);/**设置水平文本位置*/
            b1.setMnemonic(KeyEvent.VK_D);/**加一个键盘上的快捷键*/
            b1.setActionCommand("disable");/**Sets the command name for the action event fired by this button. 
             By default this action command is set to match the label of the button*/        b2 = new JButton("Middle button", middleButtonIcon);
            b2.setVerticalTextPosition(AbstractButton.BOTTOM);
            b2.setHorizontalTextPosition(AbstractButton.CENTER);
            b2.setMnemonic(KeyEvent.VK_M);        b3 = new JButton("Enable middle button", rightButtonIcon);
            //Use the default text position of CENTER, RIGHT.
            b3.setMnemonic(KeyEvent.VK_E);
            b3.setActionCommand("enable");
            b3.setEnabled(false);/**Sets the enabled state of the object,
             if true, enables this object; otherwise, disables it*/        //Listen for actions on buttons 1 and 3.
            b1.addActionListener(this)
    未完!但就想问b1.addActionListener(this)是立即触发吗??
      

  2.   

    看看事件监听应该就会明白的想想你的button怎么通知,原因就在与此
      

  3.   

    奥,我明白你的意思了,在此并不立即触发,只有激发事件,才能触发,他的响应代码应该在actionPerforme(..)中