|
-
Nov 16th, 2005, 01:35 PM
#1
Thread Starter
Frenzied Member
Drawing Pixel with least effort
Hey everyone!
Can anyone tell me what is the quickest way to draw some pixels on a window? I am not that familiar with java and I have only programmed some typical university stuff in it (alogrithms but never any output other than writing files).
Now I need an easy way to draw some pixels without anything fancy...
Edit:
I am talking about programming a standalone app with JRE 1.4, so no 5.0 or applet...
any help appreciated!
Faab
(I haven't posted here for over 2 years I think )
Last edited by /\/\isanThr0p; Nov 16th, 2005 at 02:05 PM.
Sanity is a full time job
Puh das war harter Stoff!
-
Nov 16th, 2005, 02:48 PM
#2
Re: Drawing Pixel with least effort
heres a start
Code:
import java.awt.*;
import javax.swing.*;
public class Painting extends JPanel{
public Painting(){
super();
}
public void paint(Graphics g){
Graphics2D g2d = (Graphics2D)g;
g2d.setColor(Color.red);
g2d.drawLine(0,0,this.getWidth(),this.getHeight());
g2d.drawLine(this.getWidth(),0,0,this.getHeight());
}
public static void main(String[] args){
Painting g = new Painting();
JFrame frame = new JFrame("Draw");
frame.setSize(200,200);
frame.getContentPane().add(g);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
-
Nov 16th, 2005, 02:56 PM
#3
Thread Starter
Frenzied Member
Re: Drawing Pixel with least effort
something is wrong with the constructor, but it worked without, so you're my hero for today 
Thx!
I will be having more questions soon, I guess
Sanity is a full time job
Puh das war harter Stoff!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|