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 :eek: )
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);
}
}
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 :)