Click here to Skip to main content
15,908,445 members
Home / Discussions / Java
   

Java

 
AnswerRe: Developing a Multitenant Application in Java Pin
Richard MacCutchan12-Oct-10 5:46
mveRichard MacCutchan12-Oct-10 5:46 
GeneralChossing a best option Pin
krishnareddy03612-Oct-10 1:46
krishnareddy03612-Oct-10 1:46 
GeneralRe: Chossing a best option Pin
DaveAuld12-Oct-10 1:56
professionalDaveAuld12-Oct-10 1:56 
GeneralRe: Chossing a best option Pin
jschell15-Oct-10 8:38
jschell15-Oct-10 8:38 
Questioncalling servlet in background from jsp Pin
khurram_shahzad10-Oct-10 7:16
khurram_shahzad10-Oct-10 7:16 
AnswerRe: calling servlet in background from jsp Pin
Richard MacCutchan10-Oct-10 8:50
mveRichard MacCutchan10-Oct-10 8:50 
AnswerRe: calling servlet in background from jsp Pin
Member 324727611-Oct-10 21:45
Member 324727611-Oct-10 21:45 
QuestionCanvas inside applet Pin
ekba899-Oct-10 16:14
ekba899-Oct-10 16:14 
Hi i've created a canvas for game and an applet which contains this canvas and can communicate with my database. But when canvas goes into the game loop my applet doesn't respond anything i can't even close it. Also in my canvas' constructor method i make it's background black but it doesn't work either. Here is the code for 2 classes. And for now game loop is empty but i tried it with simple game loop which runs at 25fps and sleeps when needed.
import java.awt.Canvas;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.image.BufferStrategy;

public class GameCanvas extends Canvas implements Runnable{
    private Graphics2D graphics;
    private BufferStrategy bufferStrategy;
    private boolean gameRunning;
    
    public GameCanvas(){
        setBackground(Color.black);
        setSize(300, 300);
    }
    
    public void initGame(){
        createBufferStrategy(2);
        bufferStrategy = getBufferStrategy();
        graphics = (Graphics2D)this.getBufferStrategy().getDrawGraphics();
        gameRunning = true;
        Thread t = new Thread(this);
        t.run();
    }
    
    public void run(){
        gameLoop();
    }
    
    public void gameLoop(){
        while(gameRunning){
            
        }
    }
    
    public void update(){
        
    }
    
    public void drawScreen(){
        graphics.clearRect(0, 0, this.getWidth(), this.getHeight());
        //some drawings;
        if(!bufferStrategy.contentsLost())
            bufferStrategy.show();
    }
}


import java.sql.*;
import javax.swing.JApplet;


public class DatabaseApplet extends JApplet{
	Connection con;
	
	static{
		try{
			Class.forName("com.mysql.jdbc.Driver").newInstance();
		}catch(Exception e){
			e.printStackTrace();
		}
	}
	
	String url = "jdbc:mysql://127.0.0.1:3306/players";
	String name = "root";
	String password = "root";
	GameCanvas gameCanvas;
	
	public void init(){
		setSize(300, 300);
		add(gameCanvas = new GameCanvas());
		try{
			con = DriverManager.getConnection(url, name, password);
		}catch(SQLException e){
			e.printStackTrace();
		}
	}
	
	public void start(){
		gameCanvas.initGame();
	}
	
	public void destroy() {
		try{
			con.close();
		}catch(SQLException e){
			e.printStackTrace();
		}
	}
	
}

AnswerRe: Canvas inside applet Pin
Richard MacCutchan9-Oct-10 21:54
mveRichard MacCutchan9-Oct-10 21:54 
GeneralRe: Canvas inside applet Pin
ekba8910-Oct-10 5:32
ekba8910-Oct-10 5:32 
GeneralRe: Canvas inside applet Pin
Richard MacCutchan10-Oct-10 8:49
mveRichard MacCutchan10-Oct-10 8:49 
GeneralRe: Canvas inside applet Pin
ekba8910-Oct-10 12:08
ekba8910-Oct-10 12:08 
QuestionNeed guidelines on creating LAN enabled J2SE Application With DB (apps as ERP) ? Pin
Alok Sharma ji9-Oct-10 2:35
Alok Sharma ji9-Oct-10 2:35 
AnswerRe: Need guidelines on creating LAN enabled J2SE Application With DB (apps as ERP) ? Pin
Nagy Vilmos9-Oct-10 21:34
professionalNagy Vilmos9-Oct-10 21:34 
GeneralRe: Need guidelines on creating LAN enabled J2SE Application With DB (apps as ERP) ? Pin
Alok Sharma ji10-Oct-10 3:11
Alok Sharma ji10-Oct-10 3:11 
QuestionAndroid Pin
programmervb.netc++8-Oct-10 7:15
programmervb.netc++8-Oct-10 7:15 
AnswerRe: Android Pin
DaveAuld8-Oct-10 8:52
professionalDaveAuld8-Oct-10 8:52 
QuestionOracle Driver problem Pin
itsh117-Oct-10 18:36
itsh117-Oct-10 18:36 
AnswerRe: Oracle Driver problem Pin
Richard MacCutchan7-Oct-10 22:30
mveRichard MacCutchan7-Oct-10 22:30 
AnswerRe: Oracle Driver problem Pin
David Skelly8-Oct-10 1:45
David Skelly8-Oct-10 1:45 
Questionhelp in j2me Pin
allaa2507-Oct-10 5:10
allaa2507-Oct-10 5:10 
AnswerRe: help in j2me Pin
Gerben Jongerius7-Oct-10 7:13
Gerben Jongerius7-Oct-10 7:13 
QuestionSimple Java Problem Pin
andyjin77776-Oct-10 17:55
andyjin77776-Oct-10 17:55 
AnswerRe: Simple Java Problem Pin
Cedric Moonen6-Oct-10 20:33
Cedric Moonen6-Oct-10 20:33 
AnswerRe: Simple Java Problem [modified] Pin
SinghUlarity...8-Oct-10 5:54
SinghUlarity...8-Oct-10 5:54 

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.