Click here to Skip to main content
15,920,596 members
Home / Discussions / Java
   

Java

 
QuestionCPU usage per process Pin
kartikdasani22-Aug-11 1:42
kartikdasani22-Aug-11 1:42 
AnswerRe: CPU usage per process Pin
Richard MacCutchan22-Aug-11 2:20
mveRichard MacCutchan22-Aug-11 2:20 
AnswerRe: CPU usage per process Pin
jschell22-Aug-11 9:33
jschell22-Aug-11 9:33 
GeneralRe: CPU usage per process Pin
David Skelly22-Aug-11 22:01
David Skelly22-Aug-11 22:01 
Questionstegnography in java Pin
ROHIT_BHATIA21-Aug-11 8:00
ROHIT_BHATIA21-Aug-11 8:00 
AnswerRe: stegnography in java Pin
David Skelly21-Aug-11 22:00
David Skelly21-Aug-11 22:00 
AnswerRe: stegnography in java Pin
Manfred Rudolf Bihy22-Aug-11 3:53
professionalManfred Rudolf Bihy22-Aug-11 3:53 
QuestionJava Applet not drawing to screen [modified] Pin
Liam S. Crouch20-Aug-11 4:33
Liam S. Crouch20-Aug-11 4:33 
Here is my Applet code. It does not draw to the applet screen! I have tested that it loops, but nothing appears! Can i have some help figuring out this?

Java
package net.petterroea;

import java.applet.Applet;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.image.BufferedImage;

public class TheBox extends Applet implements Runnable{
	Input input;
	Screen screen;
	boolean running;
	Thread thisThread;
	Image backBuffer;
	public TheBox()
	{
		thisThread = new Thread(this);
		input = new Input(this);
		this.setPreferredSize(new Dimension(640, 480));
		this.addKeyListener(input);
		this.addFocusListener(input);
		this.addMouseListener(input);
		Media.loadImages();
		screen = new MainMenuScreen();
	}
	@Override
	public void start()
	{
		running = true;
		thisThread.run();
	}
	@Override
	public void stop()
	{
		running = false;
	}
	@Override
	public void run() 
	{
		Graphics realg = null;
		Graphics g = null;
		while(running)
		{
			synchronized(this)
			{
				System.out.println(this.getWidth() + " " + this.getHeight());
				realg = this.getGraphics();
				if(backBuffer == null)
				{
					backBuffer = createImage(this.getWidth(), this.getHeight());
				}
				else if(backBuffer.getWidth(null) != this.getWidth() || backBuffer.getHeight(null) != this.getHeight())
				{
					backBuffer = createImage(this.getWidth(), this.getHeight());
					
				}
				
				g = backBuffer.getGraphics();
				screen.tick(g);
				realg.drawImage(backBuffer, 0, 0, null);
				try {
					Thread.sleep(50);
				} catch (InterruptedException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		}
	}
}


modified on Saturday, August 20, 2011 10:47 AM

AnswerRe: Java Applet not drawing to screen Pin
Richard MacCutchan20-Aug-11 6:41
mveRichard MacCutchan20-Aug-11 6:41 
GeneralRe: Java Applet not drawing to screen Pin
Liam S. Crouch20-Aug-11 7:44
Liam S. Crouch20-Aug-11 7:44 
GeneralRe: Java Applet not drawing to screen Pin
Richard MacCutchan20-Aug-11 23:28
mveRichard MacCutchan20-Aug-11 23:28 
GeneralRe: Java Applet not drawing to screen Pin
Richard MacCutchan21-Aug-11 8:18
mveRichard MacCutchan21-Aug-11 8:18 
QuestionHow to save the state of applet after changes on webpage? Pin
CodeGust17-Aug-11 15:35
CodeGust17-Aug-11 15:35 
AnswerRe: How to save the state of applet after changes on webpage? Pin
Peter_in_278017-Aug-11 15:49
professionalPeter_in_278017-Aug-11 15:49 
QuestionJava webserver : how to serve applets Pin
Roysten181817-Aug-11 11:43
Roysten181817-Aug-11 11:43 
AnswerRe: Java webserver : how to serve applets [modified] Pin
Peter_in_278017-Aug-11 13:36
professionalPeter_in_278017-Aug-11 13:36 
GeneralRe: Java webserver : how to serve applets Pin
Roysten181818-Aug-11 13:56
Roysten181818-Aug-11 13:56 
GeneralRe: Java webserver : how to serve applets Pin
Peter_in_278018-Aug-11 14:26
professionalPeter_in_278018-Aug-11 14:26 
AnswerRe: Java webserver : how to serve applets Pin
jschell18-Aug-11 12:48
jschell18-Aug-11 12:48 
GeneralRe: Java webserver : how to serve applets Pin
Roysten181818-Aug-11 13:58
Roysten181818-Aug-11 13:58 
Questioncreating a class with coding_?. Pin
quartaela11-Aug-11 5:14
quartaela11-Aug-11 5:14 
AnswerRe: creating a class with coding_?. Pin
Richard MacCutchan11-Aug-11 5:59
mveRichard MacCutchan11-Aug-11 5:59 
GeneralRe: creating a class with coding_?. Pin
quartaela11-Aug-11 6:07
quartaela11-Aug-11 6:07 
AnswerRe: creating a class with coding_?. Pin
jschell11-Aug-11 13:13
jschell11-Aug-11 13:13 
GeneralRe: creating a class with coding_?. Pin
quartaela12-Aug-11 12:43
quartaela12-Aug-11 12:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.