import javax.swing.*; import java.awt.*; import java.awt.image.BufferStrategy; public class Form extends JFrame { prostredi p=new prostredi(this); public Form() { initComponents(); //this.setBackground(Color.black); //Nefungueje!!! this.setSize(400,400); this.createBufferStrategy(2); //repaint(); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ // private void initComponents() { setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(0, 400, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(0, 300, Short.MAX_VALUE) ); pack(); } // public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new Form().setVisible(true); } }); } public void paint(Graphics g) { super.paint(g); p.kresliVozovku(g); p.kresliPruh(g); } public void drawStuff() { BufferStrategy bf = this.getBufferStrategy(); Graphics g = null; try { g = bf.getDrawGraphics(); // It is assumed that mySprite is created somewhere else. // This is just an example for passing off the Graphics object. p.kresliPruh(g); p.kresliVozovku(g); } finally { // It is best to dispose() a Graphics object when done with it. g.dispose(); } // Shows the contents of the backbuffer on the screen. bf.show(); // Variables declaration - do not modify // End of variables declaration } }