本文整理汇总了Python中javax.swing.JButton.addMouseListener方法的典型用法代码示例。如果您正苦于以下问题:Python JButton.addMouseListener方法的具体用法?Python JButton.addMouseListener怎么用?Python JButton.addMouseListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JButton
的用法示例。
在下文中一共展示了JButton.addMouseListener方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: init
# 需要导入模块: from javax.swing import JButton [as 别名]
# 或者: from javax.swing.JButton import addMouseListener [as 别名]
def init(self):
jbNew= JButton( LoadDefaultXmlThrottlesLayoutAction() )
jbNew.setIcon( NamedIcon("resources/Throttles.gif","resources/Throttles.gif") )
jbNew.addMouseListener(self.getMouseListeners()[0]) # In order to get the popupmenu on the button too
jbNew.setToolTipText( jbNew.getText() )
jbNew.setText( None )
self.add(jbNew)
示例2: DCCThrottle
# 需要导入模块: from javax.swing import JButton [as 别名]
# 或者: from javax.swing.JButton import addMouseListener [as 别名]
class DCCThrottle(Jynstrument, PropertyChangeListener, AddressListener, jmri.ThrottleListener):
#Jynstrument main and mandatory methods
def getExpectedContextClassName(self):
return "jmri.jmrit.throttle.ThrottleWindow"
def init(self):
self.getContext().addPropertyChangeListener(self) #ThrottleFrame change
self.addressPanel = self.getContext().getCurrentThrottleFrame().getAddressPanel()
self.addressPanel.addAddressListener(self) # change of throttle in Current frame
self.panelThrottle = self.getContext().getCurrentThrottleFrame().getAddressPanel().getThrottle() # the throttle
self.label = JButton(ImageIcon(self.getFolder() + "/DCCThrottle.png","DCCThrottle")) #label
self.label.addMouseListener(self.getMouseListeners()[0]) # In order to get the popupmenu on the button too
self.add(self.label)
# create a dcc throttle and request one from the ThrottleManager
self.masterThrottle = None
if ( jmri.InstanceManager.throttleManagerInstance().requestThrottle(listenToDCCThrottle, self) == False):
print "Couldn't request a throttle for "+locoAddress
# Advanced functions
self.advFunctions = AdvFunctions()
def quit(self):
if (self.masterThrottle != None):
self.masterThrottle.removePropertyChangeListener(self)
self.masterThrottle = None
self.panelThrottle = None
self.advFunctions = None
if (self.addressPanel != None):
self.addressPanel.removeAddressListener(self)
self.addressPanel = None
self.getContext().removePropertyChangeListener(self)
示例3: init
# 需要导入模块: from javax.swing import JButton [as 别名]
# 或者: from javax.swing.JButton import addMouseListener [as 别名]
def init(self):
jbNew = JButton( PaneOpsProgAction() )
jbNew.setIcon( NamedIcon("resources/decoderpro.gif","resources/decoderpro.gif") )
jbNew.addMouseListener(self.getMouseListeners()[0]) # In order to get the popupmenu on the button too
jbNew.setToolTipText( jbNew.getText() )
jbNew.setText( None )
self.add(jbNew)
示例4: getScreenPanel
# 需要导入模块: from javax.swing import JButton [as 别名]
# 或者: from javax.swing.JButton import addMouseListener [as 别名]
def getScreenPanel():
global mainScreen
global scrPanel
if not scrPanel:
mainScreen = JButton()
cursorImg = BufferedImage(16,16,BufferedImage.TYPE_INT_ARGB)
blankCursor = Toolkit.getDefaultToolkit().createCustomCursor(cursorImg, Point(0,0), "blank cursor")
mainScreen.setCursor(blankCursor)
mainScreen.setPreferredSize(
Dimension(700, 700))
image = BufferedImage(700, 700, BufferedImage.TYPE_INT_ARGB)
g = image.createGraphics()
g.setColor(Color.BLACK)
g.fillRect(0, 0, 700, 700)
g.setColor(Color.WHITE)
g.setFont(Font("Serif", Font.BOLD, 20))
g.drawString("Move your mouse here to controlfocused device.", 50, 30)
mainScreenImg = image
mainScreen.setIcon(swing.ImageIcon(image))
mouseListener = ScrMouseListener()
mainScreen.addMouseListener(mouseListener)
mainScreen.addMouseMotionListener(mouseListener)
mainScreen.addMouseWheelListener(mouseListener)
mainScreen.setFocusable(True)
keyListener = ScrKeyListener()
mainScreen.addKeyListener(keyListener)
scrPanel = JPanel()
scrPanel.setLayout(BoxLayout(scrPanel, BoxLayout.Y_AXIS))
scrPanel.add(mainScreen)
scrPanel.setFocusable(True)
return scrPanel
示例5: USBThrottle
# 需要导入模块: from javax.swing import JButton [as 别名]
# 或者: from javax.swing.JButton import addMouseListener [as 别名]
#.........这里部分代码省略.........
try:
if ((component == self.driver.componentF29) and (value == self.driver.valueF29)) :
self.throttle.setF29( not self.throttle.getF29() )
if ((self.roster != None) and (not self.roster.getFunctionLockable(29)) and (component == self.driver.componentF29) and (value == self.driver.valueF29Off)) :
self.throttle.setF29( not self.throttle.getF29() )
except AttributeError:
pass
# Nothing to customize bellow this point
if (event.propertyName == "ThrottleFrame") : # Current throttle frame changed
self.speedTimer.stop()
event.oldValue.getAddressPanel().removeAddressListener(self)
self.addressPanel = event.newValue.getAddressPanel()
self.throttle = self.addressPanel.getThrottle()
self.roster = self.addressPanel.getRosterEntry()
self.speedAction.setThrottle( self.throttle )
event.newValue.getAddressPanel().addAddressListener(self)
#Jynstrument main and mandatory methods
def getExpectedContextClassName(self):
return "jmri.jmrit.throttle.ThrottleWindow"
def init(self):
self.getContext().addPropertyChangeListener(self) #ThrottleFrame change
self.getContext().getCurrentThrottleFrame().getAddressPanel().addAddressListener(self) # change of throttle in Current frame
self.addressPanel = self.getContext().getCurrentThrottleFrame().getAddressPanel()
self.throttle = self.addressPanel.getThrottle() # the throttle
self.roster = self.addressPanel.getRosterEntry() # roster entry if any
self.speedAction = SpeedAction() #Speed increase thread
self.speedAction.setThrottle( self.throttle )
self.speedTimer = Timer(valueSpeedTimerRepeat, self.speedAction ) # Very important to use swing Timer object (see Swing and multithreading doc)
self.speedTimer.setRepeats(True)
self.label = JButton(ImageIcon(self.getFolder() + "/USBControl.png","USBThrottle")) #label
self.label.addMouseListener(self.getMouseListeners()[0]) # In order to get the popupmenu on the button too
self.add(self.label)
self.model = jmri.jmrix.jinput.TreeModel.instance() # USB
self.desiredController = None
self.ctrlMenuItem = []
self.USBDriver = None
self.driver = None
mi = JCheckBoxMenuItem ("None")
self.getPopUpMenu().add( mi )
mi.addItemListener( ControllerItemListener(None, self) )
self.ctrlMenuItem.append(mi)
for ctrl in self.model.controllers():
mi = JCheckBoxMenuItem (ctrl.getName())
self.getPopUpMenu().add( mi )
mi.addItemListener( ControllerItemListener(ctrl, self) )
self.ctrlMenuItem.append(mi)
if ( len(self.ctrlMenuItem) == 0 ):
print "No matching USB device found"
else:
self.ctrlMenuItem[0].setSelected(True) # by default connect to the first one
self.model.addPropertyChangeListener(self)
self.lastTimeStopButton = Calendar.getInstance().getTimeInMillis()
self.lastTimeCruiseButton = Calendar.getInstance().getTimeInMillis()
# On quit clean up resources
def quit(self):
self.speedTimer.stop()
for mi in self.ctrlMenuItem :
self.getPopUpMenu().remove( mi )
self.ctrlMenuItem = None
self.speedAction = None
self.speedTimer = None
self.throttle = None
示例6: WiimoteThrottle
# 需要导入模块: from javax.swing import JButton [as 别名]
# 或者: from javax.swing.JButton import addMouseListener [as 别名]
#.........这里部分代码省略.........
return
if ( evt.wasReleased( WRButtonEvent.ONE) ): # CRUISE SPEED = button1
self.throttle.setSpeedSetting( speedCruiseSpeed )
self.lastTimeButton1 = Calendar.getInstance().getTimeInMillis()
return
def disconnected(self):
self.wiiDevice = None
print("Lost wiimote")
def accelerationInputReceived(self, evt):
pass
def combinedInputReceived(self, evt):
pass
def extensionConnected(self, extension):
pass
def extensionDisconnected(self, extension):
pass
def extensionInputReceived(self, evt):
pass
def extensionPartiallyInserted(self):
pass
def extensionUnknown(self):
pass
def IRInputReceived(self, evt):
pass
def statusReported(self, evt):
print("Wiimote status reported: ", evt)
#Property listener part
def propertyChange(self, event):
self.speedTimer.stop()
if (event.propertyName == "ThrottleFrame") : # Current throttle frame changed
event.oldValue.getAddressPanel().removeAddressListener(self)
self.addressPanel = event.newValue.getAddressPanel()
self.throttle = self.addressPanel.getThrottle()
self.speedAction.setThrottle( self.throttle )
self.addressPanel.addAddressListener(self)
#Jynstrument main and mandatory methods
def getExpectedContextClassName(self):
return "jmri.jmrit.throttle.ThrottleWindow"
def init(self):
self.getContext().addPropertyChangeListener(self) #ThrottleFrame change
self.addressPanel=self.getContext().getCurrentThrottleFrame().getAddressPanel();
self.addressPanel.addAddressListener(self) # change of throttle in Current frame
self.throttle = self.getContext().getCurrentThrottleFrame().getAddressPanel().getThrottle() # the throttle
self.speedAction = SpeedAction() #Speed increase thread
self.speedAction.setThrottle( self.throttle )
self.speedTimer = Timer(valueSpeedTimerRepeat, self.speedAction ) # Very important to use swing Timer object (see Swing and multithreading doc)
self.speedTimer.setRepeats(True)
self.label = JButton(ImageIcon(self.getFolder() + "/WiimoteThrottle.png","WiiMote")) #label
self.label.addMouseListener(self.getMouseListeners()[0]) # In order to get the popupmenu on the button too
self.add(self.label)
self.lastTimeButton1 = Calendar.getInstance().getTimeInMillis()
self.lastTimeButton2 = Calendar.getInstance().getTimeInMillis()
self.lastTimeEStop = Calendar.getInstance().getTimeInMillis()
self.wiiDevice = None
self.sync = thread.allocate_lock() # A lock protecting bellow self.evt
self.evt = None
java.lang.System.setProperty("bluecove.jsr82.psm_minimum_off", "true"); # Required for Bluecove + WiiRemoteJ
WiiRemoteJ.findRemotes(self, 1) # Search for 1 Wiimote, and call back
def quit(self):
self.speedTimer.stop()
WiiRemoteJ.stopFind()
if ((self.wiiDevice != None) and (self.wiiDevice.isConnected())):
self.wiiDevice.removeWiiRemoteListener(self)
self.wiiDevice.disconnect()
self.wiiDevice = None
self.speedAction = None
self.speedTimer = None
self.throttle = None
self.getContext().removePropertyChangeListener(self)
self.addressPanel.removeAddressListener(self)
self.addressPanel = None
#AddressListener part: to listen for address changes in address panel (release, acquired)
def notifyAddressChosen(self, address):
pass
def notifyAddressThrottleFound(self, throttle):
self.speedTimer.stop()
self.throttle = throttle
self.speedAction.setThrottle( self.throttle )
def notifyAddressReleased(self, address):
self.speedTimer.stop()
self.throttle = None
self.speedAction.setThrottle( self.throttle )
def notifyConsistAddressChosen(self, address, isLong):
self.notifyAddressChosen(address)
def notifyConsistAddressThrottleFound(self, throttle):
self.notifyAddressThrottleFound(throttle)
def notifyConsistAddressReleased(self, address, isLong):
self.notifyAddressReleased(address)
示例7: DCCThrottle
# 需要导入模块: from javax.swing import JButton [as 别名]
# 或者: from javax.swing.JButton import addMouseListener [as 别名]
class DCCThrottle(Jynstrument, PropertyChangeListener, AddressListener, jmri.ThrottleListener):
#Jynstrument main and mandatory methods
def getExpectedContextClassName(self):
return "jmri.jmrit.throttle.ThrottleWindow"
def init(self):
self.getContext().addPropertyChangeListener(self) #ThrottleFrame change
self.addressPanel = self.getContext().getCurrentThrottleFrame().getAddressPanel()
self.addressPanel.addAddressListener(self) # change of throttle in Current frame
self.panelThrottle = self.getContext().getCurrentThrottleFrame().getAddressPanel().getThrottle() # the throttle
self.label = JButton(ImageIcon(self.getFolder() + "/DCCThrottle.png","DCCThrottle")) #label
self.label.addMouseListener(self.getMouseListeners()[0]) # In order to get the popupmenu on the button too
self.add(self.label)
# create a dcc throttle and request one from the ThrottleManager
self.masterThrottle = None
if ( jmri.InstanceManager.throttleManagerInstance().requestThrottle(listenToDCCThrottle, self) == False):
print "Couldn't request a throttle for "+locoAddress
# Advanced functions
self.advFunctions = AdvFunctions()
def quit(self):
if (self.masterThrottle != None):
self.masterThrottle.removePropertyChangeListener(self)
self.masterThrottle = None
self.panelThrottle = None
self.advFunctions = None
if (self.addressPanel != None):
self.addressPanel.removeAddressListener(self)
self.addressPanel = None
self.getContext().removePropertyChangeListener(self)
#Property listener part
def propertyChange(self, event):
if (event.propertyName == "ThrottleFrame") : # Current throttle frame changed
event.oldValue.getAddressPanel().removeAddressListener(self)
self.addressPanel = event.newValue.getAddressPanel()
self.panelThrottle = self.addressPanel.getThrottle()
self.addressPanel.addAddressListener(self)
return
if(self.panelThrottle == None):
return
if(event.propertyName == "IsForward"):
self.panelThrottle.setIsForward(event.newValue)
return
if(event.propertyName == "SpeedSetting"):
self.panelThrottle.setSpeedSetting(event.newValue)
return
if(event.propertyName == "F0"):
if (self.addressPanel.getRosterEntry() != None) and (self.advFunctions.call(self.addressPanel.getRosterEntry(), "0", event.newValue, self.panelThrottle) != None):
return
self.panelThrottle.setF0(event.newValue)
return
if(event.propertyName == "F1"):
if (self.addressPanel.getRosterEntry() != None) and (self.advFunctions.call(self.addressPanel.getRosterEntry(), "1", event.newValue, self.panelThrottle) != None):
return
self.panelThrottle.setF1(event.newValue)
return
if(event.propertyName == "F2"):
if (self.addressPanel.getRosterEntry() != None) and (self.advFunctions.call(self.addressPanel.getRosterEntry(), "2", event.newValue, self.panelThrottle) != None):
return
self.panelThrottle.setF2(event.newValue)
return
if(event.propertyName == "F3"):
if (self.addressPanel.getRosterEntry() != None) and (self.advFunctions.call(self.addressPanel.getRosterEntry(), "3", event.newValue, self.panelThrottle) != None):
return
self.panelThrottle.setF3(event.newValue)
return
if(event.propertyName == "F4"):
if (self.addressPanel.getRosterEntry() != None) and (self.advFunctions.call(self.addressPanel.getRosterEntry(), "4", event.newValue, self.panelThrottle) != None):
return
self.panelThrottle.setF4(event.newValue)
return
if(event.propertyName == "F5"):
if (self.addressPanel.getRosterEntry() != None) and (self.advFunctions.call(self.addressPanel.getRosterEntry(), "5", event.newValue, self.panelThrottle) != None):
return
self.panelThrottle.setF5(event.newValue)
return
if(event.propertyName == "F6"):
if (self.addressPanel.getRosterEntry() != None) and (self.advFunctions.call(self.addressPanel.getRosterEntry(), "6", event.newValue, self.panelThrottle) != None):
return
self.panelThrottle.setF6(event.newValue)
return
if(event.propertyName == "F7"):
if (self.addressPanel.getRosterEntry() != None) and (self.advFunctions.call(self.addressPanel.getRosterEntry(), "7", event.newValue, self.panelThrottle) != None):
return
self.panelThrottle.setF7(event.newValue)
return
if(event.propertyName == "F8"):
if (self.addressPanel.getRosterEntry() != None) and (self.advFunctions.call(self.addressPanel.getRosterEntry(), "8", event.newValue, self.panelThrottle) != None):
return
self.panelThrottle.setF8(event.newValue)
return
if(event.propertyName == "F9"):
if (self.addressPanel.getRosterEntry() != None) and (self.advFunctions.call(self.addressPanel.getRosterEntry(), "9", event.newValue, self.panelThrottle) != None):
return
self.panelThrottle.setF9(event.newValue)
return
#ThrottleListener part (real dccThrottle)
def notifyThrottleFound(self, dccThrottle):
#.........这里部分代码省略.........