maandag 3 juni 2013

Setting the drawing color


Below is shown how to set the drawing color to a red green and blue value. This is done by using new Color folowed by the rgb colors.

I am now posting the code directly and not a applet with it because that does not work anymore with google sites(with me anyway)

import java.awt.*;
import java.applet.*;

public class testproject extends Applet implements Runnable {
    // Graphics for double buffering.
    Graphics    bufferGraphics;
    Image        offscreen;
    
    public void init() {
        setBackground(Color.black);
        offscreen = createImage(getSize().width,getSize().height);
        bufferGraphics = offscreen.getGraphics();
        new Thread(this).start();
    }

    public void run(){
        for(;;){
            repaint();
            try{
                Thread.sleep(10);
            }
            catch (InterruptedException e){    
            }    
        }
    }
    
    public void update(Graphics g){
        bufferGraphics.clearRect(0,0,getSize().width,getSize().height);
        // Here the color is set using new Color followed by
        // the rgb values. In this case 200,0,0
        bufferGraphics.setColor(new Color(200,0,0));
        bufferGraphics.drawString("Test",10,10);
        
        g.drawImage(offscreen,0,0,this);
        
    }

}

Jcreator is no longer free I think

For about 10 years I have been using Jcreator to program and view java sourcecode. Today I saw that there was a new version out and I downloaded it and installed it. I should not have done this because the free version now is a trail version. There was a message that there were only 30 days available.
I tried looking around and saw on the softpedia site that it was free but it downloads the same trail version. I put a comment there that has to be aproved first. In that I wrote that it was not the free version.

I had to look back into my archives and now have a 2004 version of jcreator that works.

I am thinking of picking up java again. Though I may not stick to using it. I am viewing java code atm. Maybe I will post new source code on the blog again.