Last active
January 3, 2016 09:19
-
-
Save b7w/8441746 to your computer and use it in GitHub Desktop.
Simple canvas example on jpython
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# Какая-то хренова магия, | |
# но с нима начинает рабоать import для javax и awt | |
import pawt | |
from javax.swing import JFrame, JPanel | |
from java.awt import Canvas, Color, BorderLayout | |
class SimpleComponent(Canvas): | |
def paint(self, graphics): | |
graphics.setColor(Color(255, 0, 0)) | |
graphics.drawString("Hello", 32, 32) | |
graphics.drawLine(32, 32, 64, 64) | |
if __name__ == "__main__": | |
frame = JFrame("Hell pyJava") | |
frame.defaultCloseOperation = JFrame.EXIT_ON_CLOSE | |
frame.setSize(400, 400) | |
panel = JPanel(layout=BorderLayout()) | |
panel.add(SimpleComponent(), BorderLayout.CENTER) | |
frame.add(panel) | |
frame.setVisible(True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment