/** * Create an instance of {@link Drawing } * */ public Drawing createDrawing() { return new Drawing(); }
/** * Create an instance of {@link Drawing } * */ public Drawing createDrawing() { return new Drawing(); }
Drawing instance=new Drawing(); frame.add(instance); frame.addKeyListener(instance);
public class Game extends JFrame implements ActionListener { Drawing object = new Drawing(); Timer t = new Timer(1, this); int score; ArrayList<Enemy> bombs = new ArrayList<Enemy>(); public Game() { t.start(); setDefaultCloseOperation(EXIT_ON_CLOSE); setSize(700, 600); add(object); add(new JLabel("Hello")); validate(); createBombs(); setVisible(true); } }
public static Drawing deepClone(Drawing drawing) { try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(drawing.shapes); //Serializes the drawing.shapes ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); ObjectInputStream ois = new ObjectInputStream(bais); return new Drawing((LinkedList<Shape>)ois.readObject()); //Deserializing and reading } catch (IOException e) { return null; } catch (ClassNotFoundException e) { return null; } }
public static void createGUI(){ JFrame frame = new JFrame("My Frame"); JComponent component = new Drawing(); component.setOpaque(true); frame.add(component); frame.setSize(600,400); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); }
import javax.swing.JFrame; import javax.swing.JPanel; @SuppressWarnings("serial") public class Main extends JPanel{ public static void main(String[] args) { JFrame jf = new JFrame("Matrix raining code - by Ran Galili"); jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jf.setSize(700,700); jf.setResizable(false); jf.add(new Drawing()); jf.setVisible(true); } }
frame.setTitle("Belisha Beacon"); frame.setLayout(new BorderLayout(0, 0)); final Drawing shapes = new Drawing();
this.artworks = new ArrayList<ArtObject>(); artworks.add(new Painting("Mona Lisa")); artworks.add(new Drawing("Madame Palmyre with Her Dog")); artworks.add(new Painting("The Night Watch"));