Exemplo n.º 1
0
    def test_java_bean_properties(self):

        b1 = swing.JButton()
        b1.label = 'foo'
        b2 = swing.JButton(label='foo')
        self.assertEquals(b1.label, b2.label)
        self.assertEquals(b1.label, 'foo')

        # Test bean event properties - single and multiple
        def testAction(event):
            JythonBasicTests.flag += 1

        doit = ActionEvent(b1, ActionEvent.ACTION_PERFORMED, "")

        b1.actionPerformed = testAction
        JythonBasicTests.flag = 0
        b1.doClick()
        self.assertEquals(
            JythonBasicTests.flag, 1,
            'expected one action per event but got %s' % JythonBasicTests.flag)

        b1.actionPerformed.append(testAction)
        JythonBasicTests.flag = 0
        b1.doClick()
        self.assertEquals(JythonBasicTests.flag, 2, 'two actions per event')

        b1.actionPerformed = testAction
        JythonBasicTests.flag = 0
        b1.doClick()
        self.assertEquals(JythonBasicTests.flag, 1,
                          'one actions per event - again')
Exemplo n.º 2
0
	def actionPerformed(self, e):
		manager = KeyboardFocusManager.getCurrentKeyboardFocusManager()
		focusOwner = manager.getPermanentFocusOwner()
		if focusOwner is not None:
			action = e.getActionCommand()
			a = focusOwner.getActionMap().get( action )
			if a is not None:
				a.actionPerformed( ActionEvent( focusOwner, ActionEvent.ACTION_PERFORMED, None ) )
Exemplo n.º 3
0
	def startUserInput(self, prompt=None):
		if prompt is not None:
			self.write(prompt, 'prompt')
		self.startInput = self.document.createPosition(self.document.length-1)
		#self.document.setCharacterAttributes(self.document.length-1, 1, self.styles.get('input'), 1)
		self.textpane.caretPosition = self.document.length
		ae = ActionEvent(self.textpane, ActionEvent.ACTION_PERFORMED, 'start input')
		self.inputAction.actionPerformed(ae)
Exemplo n.º 4
0
b2 = swing.JButton(label='foo')
assert b1.label == b2.label == 'foo', 'Button label bean property'

print_test('bean event properties')
# Test bean event properties - single and multiple
flag = 0


def testAction(event):
    global flag
    flag = flag + 1


from java.awt.event import ActionEvent

doit = ActionEvent(b1, ActionEvent.ACTION_PERFORMED, "")

b1.actionPerformed = testAction
flag = 0
b1.doClick()
assert flag == 1, 'expected one action per event but got %s' % flag

b1.actionPerformed.append(testAction)
flag = 0
b1.doClick()
assert flag == 2, 'two actions per event'

b1.actionPerformed = testAction
flag = 0
b1.doClick()
assert flag == 1, 'one actions per event - again'
Exemplo n.º 5
0
def dispatchActionEvent(component):
	event = ActionEvent(component, ActionEvent.ACTION_PERFORMED, \
		component.getLabel(), MouseEvent.BUTTON1)
	component.dispatchEvent(event)