本文整理汇总了Python中javax.swing.JFrame.getBackground方法的典型用法代码示例。如果您正苦于以下问题:Python JFrame.getBackground方法的具体用法?Python JFrame.getBackground怎么用?Python JFrame.getBackground使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JFrame
的用法示例。
在下文中一共展示了JFrame.getBackground方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from javax.swing import JFrame [as 别名]
# 或者: from javax.swing.JFrame import getBackground [as 别名]
class ActionMenu:
def __init__(self):
self.titleBase = 'FF3 Monkey'
self.frame = JFrame(self.titleBase, defaultCloseOperation = JFrame.EXIT_ON_CLOSE, size=(400,400))
self.inputMap = self.frame.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
self.actionMap = self.frame.getRootPane().getActionMap()
self.actionLabels = {}
self.actionThread = None
self.defaultBackground = self.frame.getBackground()
self.frame.getContentPane().setLayout(BoxLayout(self.frame.getContentPane(), BoxLayout.Y_AXIS))
def quit():
from java.lang import System
print "Quitting..."
System.exit(0)
self.addAction("Q", "Quit", quit)
self.addAction("ESCAPE", "Abort current action", lambda: None)
def addAction(self, key, desc, cb):
if " " in key:
strokeString = key
else:
strokeString = "pressed "+key
stroke = KeyStroke.getKeyStroke(strokeString)
if stroke == None:
raise ValueError("Invalid key: "+str(key))
self.inputMap.put(stroke, key)
self.actionMap.put(key, MenuAction(cb, key, desc, self))
self.actionLabels[key] = JLabel(key+": "+desc)
self.actionLabels[key].setOpaque(True)
self.frame.getContentPane().add(self.actionLabels[key])
def run(self):
print "Starting menu"
self.frame.visible = True
while True:
sleep(300)