Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #6805
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!news-peer.in.tum.de!news.belwue.de!news.uni-stuttgart.de!news.nask.pl!news.nask.org.pl!news.cyf-kr.edu.pl!agh.edu.pl!news.agh.edu.pl!news.onet.pl!.POSTED!not-for-mail |
|---|---|
| From | MaciekL <__nospam__maclab@o2.pl> |
| Newsgroups | comp.lang.java.programmer |
| Subject | java.awt.Frame - How to repaint without background update |
| Date | Fri, 05 Aug 2011 13:15:52 +0200 |
| Organization | http://onet.pl |
| Lines | 61 |
| Message-ID | <j1gjd9$n0c$1@news.onet.pl> (permalink) |
| NNTP-Posting-Host | 62.29.174.65 |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Content-Transfer-Encoding | 7bit |
| X-Trace | news.onet.pl 1312542953 23564 62.29.174.65 (5 Aug 2011 11:15:53 GMT) |
| X-Complaints-To | niusy@onet.pl |
| NNTP-Posting-Date | Fri, 5 Aug 2011 11:15:53 +0000 (UTC) |
| User-Agent | Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20110624 Thunderbird/5.0 |
| X-Enigmail-Version | 1.2 |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:6805 |
Show key headers only | View raw
Hi,
I'm trying to create simple application with BufferedImage that already
contains some graphical content.
During "repaint" operation, created image should be
redrawn on the screen (without additional graphics functions).
It seems to be easy, but there is something wrong.
During "repaint" operation the window "blinks". It seems that
'background' is displayed before image is drawn.
"javax.swing.JFrame" solves the issue, but I would like to
solve this with basic "java.awt.Frame".
Following application demonstartes the issue.
What should be added to this program to avoid backround repainting ?
/*--::BEG::--[TestApp.java]-------------------------------------------------*/
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);
}
}
/*--::EOF::--[TestApp.java]-------------------------------------------------*/
Regards
--
Maciek
Back to comp.lang.java.programmer | Previous | Next — Next in thread | Find similar
java.awt.Frame - How to repaint without background update MaciekL <__nospam__maclab@o2.pl> - 2011-08-05 13:15 +0200 Re: java.awt.Frame - How to repaint without background update supercalifragilisticexpialadiamaticonormalizeringelimatisticantations <supercalifragilisticexpialadiamaticonormalizeringelimatisticantations@averylongandannoyingdomainname.com> - 2011-08-05 07:36 -0400
csiph-web