Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I solved my recent problem:</p> <pre><code>from javax.swing import JToolBar from javax.swing import JButton from javax.swing import JFrame import time from java import awt from java.awt import BorderLayout class Canvas(awt.Canvas): u"Canvas - drawing area" def __init__(self,winSize = 400): self.play = False self.background=awt.Color.black self.winSize = winSize self.l = 0 self.bi = BufferedImage(winSize, winSize, BufferedImage.TYPE_INT_RGB) self.offScreenGraphics = self.bi.getGraphics() def playSim(self, play): if play == True: self.play = True self.repaint() else: self.play = False def paint(self, g): self.offScreenGraphics.fillRect(50, int(self.winSize/4), self.l, int(self.winSize/2)) if self.l &lt; self.winSize: self.l += 1 else: self.l = 0 g.drawImage(self.bi, 0, 0, None) time.sleep(0.02) if self.play == True: self.repaint() class Example(JFrame): def __init__(self): super(Example, self).__init__() self.initUI() def initUI(self): winSize = 600 toolbar = JToolBar() self.playButton = JButton("Start", actionPerformed=self.playButtonPress ) toolbar.add(self.playButton) self.add(toolbar, BorderLayout.NORTH) self.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) self.setSize(winSize, winSize) self.setResizable(False) self.setLocationRelativeTo(None) self.setVisible(True) self.canvas = Canvas(winSize) self.getContentPane().add(self.canvas) self.setTitle("TEST") self.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) def playButtonPress(self, e): if self.playButton.getLabel() == "Start": self.canvas.playSim(True) self.playButton.setLabel("Stop") else: self.playButton.setLabel("Start") self.canvas.playSim(False) if __name__ == '__main__': Example() </code></pre> <p>Now I've another(rather trivial) problem: How can I make from this <em>python file</em> *the class file* which would be ready to publish it on website as an applet?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload