Note that there are some explanatory texts on larger screens.

plurals
  1. PODouble buffering in Jython
    primarykey
    data
    text
    <p>recently I started learning Jython and now I have rather simply problem. I would like to improve quality of my animation. Unfortunately I don't know how to add double buffering to my applet . Could you help me? Best regards!</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 def playSim(self, play): if play == True: self.play = True self.repaint() else: self.play = False def paint(self, g): g.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 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>
    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.
 

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