Results 1 to 2 of 2
  1. #1
    tnt417 is offline Member
    Join Date
    Sep 2015
    Rep Power

    Question Java 2d graphics rendering method

    this is my code but it doesn't work:
    Java Code:
    private void render() {
    		BufferStrategy bs = this.getBufferStrategy();
    		if(bs == null){
    		Graphics g = bs.getDrawGraphics();
    			g.fillRect(0, 0, 720, 480);

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Northern Virginia, United States
    Rep Power

    Default Re: Java 2d graphics rendering method

    When asking for help, code snippets are not very useful. Check out the tutorial in my signature on how to do graphics. Here are the basics.

    1. Create a class of some name (YourClass) and extend JPanel
    2. Add an instance of YourClass to an instance of JFrame
    3. In YourClass, override paintComponent
    and place your fillRect code in that method.

    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

Similar Threads

  1. help with Graphics method
    By The original stinger in forum Java Applets
    Replies: 4
    Last Post: 05-21-2012, 10:29 PM
  2. Rendering graphics on JPanel
    By wired-in=p in forum New To Java
    Replies: 4
    Last Post: 10-06-2011, 07:08 AM
  3. Replies: 0
    Last Post: 09-12-2011, 02:06 PM
  4. Putting graphics into the run() method.
    By theCardboardBox in forum New To Java
    Replies: 11
    Last Post: 11-17-2010, 07:33 PM
  5. java graphics within main method
    By jforce93 in forum New To Java
    Replies: 4
    Last Post: 02-02-2010, 11:33 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts