当前位置: 首页>>代码示例>>Python>>正文


Python JButton.setContentAreaFilled方法代码示例

本文整理汇总了Python中javax.swing.JButton.setContentAreaFilled方法的典型用法代码示例。如果您正苦于以下问题:Python JButton.setContentAreaFilled方法的具体用法?Python JButton.setContentAreaFilled怎么用?Python JButton.setContentAreaFilled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JButton的用法示例。


在下文中一共展示了JButton.setContentAreaFilled方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: ButtonPanel

# 需要导入模块: from javax.swing import JButton [as 别名]
# 或者: from javax.swing.JButton import setContentAreaFilled [as 别名]
class ButtonPanel(Panel):
	
	playButton = None
	helpButton = None
	resetButton = None
	exitButton = None

	def __init__(self, inconsolePanel,dialogPanel):
		self.consolePanel = inconsolePanel
		self.dialogPanel = dialogPanel
		Panel.__init__(self, "gap 1px 1px, insets 0 0 0 0, flowy")

	def initUI(self):

		self.setBackground(Color(0, 50, 0))

		self.playButtonS = ImageIcon('bin/gui/media/' + "playButton.png")
		self.helpButtonS = ImageIcon('bin/gui/media/' + "helpButton.png")
		self.resetButtonS = ImageIcon('bin/gui/media/' + "resetButton.png")
		self.exitButtonS = ImageIcon('bin/gui/media/' + "exitButton.png")
		self.playButtonU = ImageIcon('bin/gui/media/' + "playButton_unselected.png")
		self.helpButtonU = ImageIcon('bin/gui/media/' + "helpButton_unselected.png")
		self.resetButtonU = ImageIcon('bin/gui/media/' + "resetButton_unselected.png")
		self.exitButtonU = ImageIcon('bin/gui/media/' + "exitButton_unselected.png")

		class MouseHoverAdap(MouseAdapter):
			def __init__(self, butt, entImage, leaImage):
				self.entImage = entImage
				self.leaImage = leaImage
				self.butt = butt
				self.butt.setIcon(self.leaImage)
			def mouseEntered(self, m):
				self.butt.setIcon(self.entImage)
				#self.butt.repaint()
			def mouseExited(self, m):
				self.butt.setIcon(self.leaImage)
				#self.butt.repaint()


		self.playButton = JButton(self.playButtonS)
		self.playButton.setForeground(Color(0, 245, 0))
		#self.playButton.setPreferredSize(Dimension(playButton.getIconWidth(), playButton.getIconHeight()))
		#self.playButton.setBackground(Color(125, 125, 25))
		self.playButton.setMaximumSize(Dimension(self.playButtonS.getIconWidth(), self.playButtonS.getIconHeight()))
		self.playButton.setContentAreaFilled(False)

		self.helpButton = JButton(self.helpButtonS)
		self.helpButton.setForeground(Color(0, 235, 0))
		self.helpButton.setMaximumSize(Dimension(self.helpButtonS.getIconWidth(), self.helpButtonS.getIconHeight()))
		self.helpButton.setContentAreaFilled(False)

		self.resetButton = JButton(self.resetButtonS)
		self.resetButton.setForeground(Color(0, 225, 0))
		self.resetButton.setMaximumSize(Dimension(self.resetButtonS.getIconWidth(), self.resetButtonS.getIconHeight()))
		self.resetButton.setContentAreaFilled(False)

		self.exitButton = JButton(self.exitButtonS)
		self.exitButton.setForeground(Color(0, 215, 0))
		self.exitButton.setContentAreaFilled(False)
		self.exitButton.setMaximumSize(Dimension(self.exitButtonS.getIconWidth(), self.exitButtonS.getIconHeight()))
		
		# self.playButton.addMouseListener(MouseHoverAdap(self.playButton, self.playButtonS, self.playButtonU))
		# self.helpButton.addMouseListener(MouseHoverAdap(self.helpButton, self.helpButtonS, self.helpButtonU))
		# self.resetButton.addMouseListener(MouseHoverAdap(self.resetButton, self.resetButtonS, self.resetButtonU))
		# self.exitButton.addMouseListener(MouseHoverAdap(self.exitButton, self.exitButtonS, self.exitButtonU))


		class PlayButtonActionListener(ActionListener):
			def actionPerformed(button, e):
				self.dialogPanel.speak(self.consolePanel.console.do_play(''))
		self.playButton.addActionListener(PlayButtonActionListener())

		class HelpBUttonActionListener(ActionListener):
			def actionPerformed(button, e):
				self.dialogPanel.speak(self.consolePanel.console.do_hint(''))
		self.helpButton.addActionListener(HelpBUttonActionListener())

		class ResetButtonActionListener(ActionListener):
			def actionPerformed(button, e):
				self.dialogPanel.speak(self.consolePanel.console.do_reset(''))
		self.resetButton.addActionListener(ResetButtonActionListener())

		class ExitButtonActionListener(ActionListener):
			def actionPerformed(button, e):
				System.exit(0)
		self.exitButton.addActionListener(ExitButtonActionListener())





	def addUI(self):
		self.add(self.playButton, "push, grow")
		self.add(self.helpButton, "push, grow")
		self.add(self.resetButton, "push, grow")
		self.add(self.exitButton, "push, grow")
开发者ID:doctorOb,项目名称:bashED,代码行数:98,代码来源:buttonPanel.py


注:本文中的javax.swing.JButton.setContentAreaFilled方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。