Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #26866
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!feeder2.ecngs.de!ecngs!feeder.ecngs.de!Xl.tags.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!local2.nntp.ams.giganews.com!nntp.bt.com!news.bt.com.POSTED!not-for-mail |
|---|---|
| NNTP-Posting-Date | Thu, 12 Dec 2013 14:14:48 -0600 |
| Date | Thu, 12 Dec 2013 20:14:47 +0000 |
| From | lipska the kat <"lipskathekat at yahoo dot co dot uk"> |
| Organization | Trollbusters 3 |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130308 Thunderbird/17.0.4 |
| MIME-Version | 1.0 |
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Basic 2d graphics in Java |
| References | <527c86f0-1b3d-4103-bd42-a5dcd9ade567@googlegroups.com> |
| In-Reply-To | <527c86f0-1b3d-4103-bd42-a5dcd9ade567@googlegroups.com> |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 8bit |
| Message-ID | <g-2dncdh0_alhDfPnZ2dnUVZ8jadnZ2d@bt.com> (permalink) |
| Lines | 74 |
| X-Usenet-Provider | http://www.giganews.com |
| X-AuthenticatedUsername | NoAuthUser |
| X-Trace | sv3-WVCCmyGjvEJx7jwijFUbFH7yj73sMVgmgdJ8sauOheDj2A7Mt3ocxkO+In0miHspV/ApPC9aPtaBIT5!7VhKoYRPmugiLPqemIJfKWtQ68IXUWipfGOIbgem/P5EN5ja46ZVY2+4Qzo/vFWbf+G83H574DXd |
| X-Complaints-To | abuse@btinternet.com |
| X-DMCA-Complaints-To | abuse@btinternet.com |
| X-Abuse-and-DMCA-Info | Please be sure to forward a copy of ALL headers |
| X-Abuse-and-DMCA-Info | Otherwise we will be unable to process your complaint properly |
| X-Postfilter | 1.3.40 |
| X-Original-Bytes | 3192 |
| Xref | csiph.com comp.lang.java.programmer:26866 |
Show key headers only | View raw
On 12/12/13 16:45, tomcees_pc@yahoo.com wrote:
> Hello:
>
> I'm working through re-learning java and would like to solicit some help.
>
> Can anyone share some simple java code to:
>
> 1. Set up a small (say 320w x 240h) 2d window.
> 2. Set(color) and Read (color) of pixels within this window.
>
> TIA for your help,
> TomC
Try this
With suitable acknowledgments to Stefan Ram of this parish.
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import javax.swing.JComponent;
import javax.swing.JFrame;
class Main extends JComponent implements Runnable {
int X = 320;
int Y = 200;
private static final long serialVersionUID = 0L;
BufferedImage window = new BufferedImage( X, Y,
BufferedImage.TYPE_INT_RGB );
public int readColor(int x, int y ){
return window.getRGB( x, y );
}
public void setColor( int x, int y, int color ){
window.setRGB( x, y, color );
}
public static void main(String args[] ){
EventQueue.invokeLater(new Main() );
}
@Override
public void run(){
JFrame frame = new JFrame( "Main" );
setPreferredSize( new Dimension( X, Y ));
setColor( X/2, Y/2, 0xFFFFFF );
System.out.println(readColor( X/2, Y/2 ));
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE );
frame.add(this);
frame.pack();
frame.setVisible( true );
}
@Override
public void paintComponent(Graphics graphics ){
graphics.drawImage(window, 0, 0, null );
}
}
--
Lipska the Kat©: Troll hunter, sandbox destroyer,
treacherous feline and farscape dreamer of Aeryn Sun
GNU/Linux user #560883 - http://www.linuxcounter.net
--
Lipska the Kat©: Troll hunter, sandbox destroyer,
treacherous feline and farscape dreamer of Aeryn Sun
GNU/Linux user #560883 - http://www.linuxcounter.net
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Basic 2d graphics in Java tomcees_pc@yahoo.com - 2013-12-12 08:45 -0800
Re: Basic 2d graphics in Java markspace <markspace@nospam.nospam> - 2013-12-12 09:39 -0800
Re: Basic 2d graphics in Java lipska the kat <"lipskathekat at yahoo dot co dot uk"> - 2013-12-12 19:07 +0000
Re: Basic 2d graphics in Java Joerg Meier <joergmmeier@arcor.de> - 2013-12-12 20:43 +0100
Re: Basic 2d graphics in Java lipska the kat <"lipskathekat at yahoo dot co dot uk"> - 2013-12-12 19:47 +0000
Re: Basic 2d graphics in Java lipska the kat <"lipskathekat at yahoo dot co dot uk"> - 2013-12-12 20:14 +0000
Re: Basic 2d graphics in Java tomcees_pc@yahoo.com - 2013-12-12 12:37 -0800
Re: Basic 2d graphics in Java Jeff Higgins <jeff@invalid.invalid> - 2013-12-12 17:42 -0500
csiph-web