Results 1 to 3 of 3

Thread: Drawing Pixel with least effort

  1. #1

    Thread Starter
    Frenzied Member /\/\isanThr0p's Avatar
    Join Date
    Jul 2000
    Location
    They can't stop us! We're on a misson from God.
    Posts
    1,181

    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!

  2. #2
    Frenzied Member DeadEyes's Avatar
    Join Date
    Jul 2002
    Posts
    1,196

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

  3. #3

    Thread Starter
    Frenzied Member /\/\isanThr0p's Avatar
    Join Date
    Jul 2000
    Location
    They can't stop us! We're on a misson from God.
    Posts
    1,181

    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
  •  



Click Here to Expand Forum to Full Width