本文整理汇总了Python中javax.swing.JButton.addKeyListener方法的典型用法代码示例。如果您正苦于以下问题:Python JButton.addKeyListener方法的具体用法?Python JButton.addKeyListener怎么用?Python JButton.addKeyListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JButton
的用法示例。
在下文中一共展示了JButton.addKeyListener方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getScreenPanel
# 需要导入模块: from javax.swing import JButton [as 别名]
# 或者: from javax.swing.JButton import addKeyListener [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