Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #6807

Re: java.awt.Frame - How to repaint without background update

From MaciekL <__nospam__maclab@o2.pl>
Newsgroups comp.lang.java.programmer
Subject Re: java.awt.Frame - How to repaint without background update
Date 2011-08-05 13:45 +0200
Organization http://onet.pl
Message-ID <j1gl4o$t0j$1@news.onet.pl> (permalink)

Show all headers | View raw


solved:

Adding additonal update method makes that Background is not displayed

public void update(Graphics g) { paint(g); }

Maciek

-- 
Regards

On 2011-08-05 13:15, MaciekL wrote:
> import java.awt.*;
> import java.awt.image.*;
> public class TestApp extends Frame implements Runnable
> {
>   BufferedImage img = new BufferedImage(640, 480,
> BufferedImage.TYPE_INT_RGB);
>   public TestApp()
>   {
>     Graphics g = img.getGraphics();
>     g.setColor(Color.RED);
>     g.drawRect(0, 0, img.getWidth() - 1, img.getHeight() - 1);
>     g.setColor(Color.BLUE);
>     g.fillRect(1, 1, img.getWidth() - 2, img.getHeight() - 2);
>     (new Thread(this)).start();
>   }
>   public void run()
>   {
>     while (true)
>     {
>       try { Thread.sleep(100); }
>       catch (Exception e) { }
>       repaint();
>     }
>   }
>   public void paint(Graphics g)
>   {
>     g.drawImage(img, 50, 50, this);
>   }
>   public static void main(String [] args)
>   {
>     Frame frame = new TestApp();
>     frame.setSize(740, 580);
>     frame.setLocation(50, 50);
>     frame.setVisible(true);
>   }
> }

Back to comp.lang.java.programmer | Previous | NextNext in thread | Find similar


Thread

Re: java.awt.Frame - How to repaint without background update MaciekL <__nospam__maclab@o2.pl> - 2011-08-05 13:45 +0200
  Re: java.awt.Frame - How to repaint without background update Knute Johnson <september@knutejohnson.com> - 2011-08-05 08:30 -0700
    Re: java.awt.Frame - How to repaint without background update Ian Shef <invalid@avoiding.spam> - 2011-08-05 19:48 +0000

csiph-web