Skip to content

Commit

Permalink
update jpanel with event handling
Browse files Browse the repository at this point in the history
  • Loading branch information
jggatc committed Jun 24, 2015
1 parent 6eeec51 commit a6c9637
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.txt
@@ -1,3 +1,6 @@
0.28_dev
-update jpanel with event handling that registers appropriate mouse position.

0.27 2015-04-12
-update font to enhance fonts access.
-update image load to allow file-like argument.
Expand Down
22 changes: 12 additions & 10 deletions display.py
Expand Up @@ -19,7 +19,7 @@
__docformat__ = 'restructuredtext'


class Frame(JFrame, MouseListener, MouseMotionListener, MouseWheelListener, KeyListener):
class Frame(JFrame):

def __init__(self, title, size):
JFrame.__init__(self, title)
Expand All @@ -31,10 +31,21 @@ def __init__(self, title, size):
self.jpanel = Panel(size)
self.getContentPane().add(self.jpanel)
self.pack()


class Panel(JPanel, MouseListener, MouseMotionListener, MouseWheelListener, KeyListener):

def __init__(self, size):
JPanel.__init__(self)
self.setPreferredSize(Dimension(size[0],size[1]))
self.surface = pyj2d.surface.Surface(size, BufferedImage.TYPE_INT_RGB)
self.setBackground(Color.BLACK)
self.addMouseListener(self)
self.addMouseMotionListener(self)
self.addMouseWheelListener(self)
self.addKeyListener(self)
self.setFocusable(True)
self.requestFocusInWindow()
self.event = pyj2d.event
self.modKey = pyj2d.event.modKey

Expand Down Expand Up @@ -80,15 +91,6 @@ def keyReleased(self, event):
def keyTyped(self, event):
pass


class Panel(JPanel):

def __init__(self, size):
JPanel.__init__(self)
self.setPreferredSize(Dimension(size[0],size[1]))
self.surface = pyj2d.surface.Surface(size, BufferedImage.TYPE_INT_RGB)
self.setBackground(Color.BLACK)

def paintComponent(self, g2d):
self.super__paintComponent(g2d)
g2d.drawImage(self.surface, 0, 0, None)
Expand Down

0 comments on commit a6c9637

Please sign in to comment.