本文整理汇总了Python中javax.swing.JScrollPane.addMouseListener方法的典型用法代码示例。如果您正苦于以下问题:Python JScrollPane.addMouseListener方法的具体用法?Python JScrollPane.addMouseListener怎么用?Python JScrollPane.addMouseListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JScrollPane
的用法示例。
在下文中一共展示了JScrollPane.addMouseListener方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from javax.swing import JScrollPane [as 别名]
# 或者: from javax.swing.JScrollPane import addMouseListener [as 别名]
def __init__(self,view):
JPanel.__init__(self)
self.view=view
self.background=Color.white
self.layout=BorderLayout()
self.popup=JPopupMenu()
self.popup_items={}
self.add(self.make_controls(),BorderLayout.SOUTH)
data,title=self.extract_data()
self.table=JTable(DefaultTableModel(data,title))
scroll=JScrollPane(self.table)
self.add(scroll)
scroll.addMouseListener(self)
self.table.tableHeader.addMouseListener(self)
self.table.addMouseListener(self)
self.fileChooser=JFileChooser()
self.fileChooser.setFileFilter(CSVFilter())
self.fileChooser.setSelectedFile(File('%s.csv'%self.view.network.name))
示例2: SwingingMonkeyCommander
# 需要导入模块: from javax.swing import JScrollPane [as 别名]
# 或者: from javax.swing.JScrollPane import addMouseListener [as 别名]
class SwingingMonkeyCommander(JFrame):
'''
A Jython tool that uses the Android SDK's monkeyrunner to communicate with
the device. It fetches screenshots and draws them in the desktop window and
can accept mouse and key events.
Author: Fredrik Henricsson ([email protected])
'''
_preferredWidth = 480
_preferredHeight = 854
_widthScale = 1.0
_heightScale = 1.0
def __init__(self):
JFrame.__init__(self, "SwingingMonkeyCommander", \
layout=BorderLayout(), \
size=(505, 874), \
defaultCloseOperation=JFrame.EXIT_ON_CLOSE,) \
scriptDir = os.path.realpath(os.path.dirname(sys.argv[0]))
self.frameIcon = ImageIcon(scriptDir + '/smcs.png')
self.setIconImage(self.frameIcon.getImage())
self.image = ImageIcon()
self.label = JLabel(self.image)
self.scrollpane = JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED)
self.scrollpane.addMouseListener(ScreenMouseListener(self))
self.keyListener = ScreenKeyListener(self)
self.initAndroidKeyMap()
self.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, Collections.EMPTY_SET);
self.scrollpane.preferredSize = self._preferredWidth, self._preferredHeight
self.scrollpane.viewport.view = self.label
self.label.preferredSize = (self._preferredWidth, self._preferredHeight)
self.add(self.scrollpane, BorderLayout.PAGE_START)
self.show()
self.androidDevice = None
if self.waitForAndroidDeviceConnection() == False:
print "Could not establish connection with device."
return
self.screenPullTask = ScreenPullTask(self)
self.screenPullTask.execute()
self.dragStart = (0,0)
self.dragEnd = (0,0)
def waitForAndroidDeviceConnection(self):
maxAttempts = 5
secondsBetweenAttempts = 5
attempts = 0
while(self.androidDevice == None or attempts >= maxAttempts):
if attempts > 0:
print "Could not connect to Android device. Trying again in 5 seconds."
time.sleep(secondsBetweenAttempts)
self.androidDevice = MonkeyRunner.waitForConnection()
attempts += 1
if self.androidDevice != None:
return True
else:
return False
def initAndroidKeyMap(self):
# TODO: Can we use a tuple for the key and use keyCode as the first,
# and keyLocation as the second value?
# TODO: Need to check modifiers as well.
# TODO: Do we need to consider the locale or does Java abstract that away?
self.keyMap = { KeyEvent.VK_A : 'KEYCODE_A',
KeyEvent.VK_B : 'KEYCODE_B',
KeyEvent.VK_C : 'KEYCODE_C',
KeyEvent.VK_D : 'KEYCODE_D',
KeyEvent.VK_E : 'KEYCODE_E',
KeyEvent.VK_F : 'KEYCODE_F',
KeyEvent.VK_G : 'KEYCODE_G',
KeyEvent.VK_H : 'KEYCODE_H',
KeyEvent.VK_I : 'KEYCODE_I',
KeyEvent.VK_J : 'KEYCODE_J',
KeyEvent.VK_K : 'KEYCODE_K',
KeyEvent.VK_L : 'KEYCODE_L',
KeyEvent.VK_M : 'KEYCODE_M',
KeyEvent.VK_N : 'KEYCODE_N',
KeyEvent.VK_O : 'KEYCODE_O',
KeyEvent.VK_P : 'KEYCODE_P',
KeyEvent.VK_Q : 'KEYCODE_Q',
KeyEvent.VK_R : 'KEYCODE_R',
KeyEvent.VK_S : 'KEYCODE_S',
KeyEvent.VK_T : 'KEYCODE_T',
KeyEvent.VK_U : 'KEYCODE_U',
KeyEvent.VK_V : 'KEYCODE_V',
KeyEvent.VK_W : 'KEYCODE_W',
KeyEvent.VK_X : 'KEYCODE_X',
KeyEvent.VK_Y : 'KEYCODE_Y',
KeyEvent.VK_Z : 'KEYCODE_Z',
KeyEvent.VK_0 : 'KEYCODE_0',
KeyEvent.VK_1 : 'KEYCODE_1',
#.........这里部分代码省略.........