Click here to Skip to main content
15,886,857 members
Home / Discussions / Java
   

Java

 
Questionjava Pin
Member 120298853-Oct-15 0:39
Member 120298853-Oct-15 0:39 
AnswerRe: java Pin
Richard MacCutchan3-Oct-15 1:22
mveRichard MacCutchan3-Oct-15 1:22 
QuestionJava problem beginner Pin
Member 120276961-Oct-15 23:33
Member 120276961-Oct-15 23:33 
AnswerRe: Java problem beginner Pin
Richard MacCutchan2-Oct-15 0:17
mveRichard MacCutchan2-Oct-15 0:17 
GeneralRe: Java problem beginner Pin
Member 120276962-Oct-15 1:46
Member 120276962-Oct-15 1:46 
GeneralRe: Java problem beginner Pin
Richard MacCutchan2-Oct-15 1:53
mveRichard MacCutchan2-Oct-15 1:53 
QuestionStoring private data in the cloud via hash functions? Pin
Keld Ølykke30-Sep-15 10:30
Keld Ølykke30-Sep-15 10:30 
QuestionJava Graphics class Pin
Member 1200394822-Sep-15 8:04
Member 1200394822-Sep-15 8:04 
import java.lang.*;
import java.awt.*;
import java.awt.event.*;

public class Post extends Frame
{
	public Post()
	{
		this.addWindowListener(new MyWinAdap());
	}
	public void paint(Graphics g)
	{
		g.setColor(Color.black);
		Dots d = new Dots();
		Text t = new Text();
		d.start();
		t.start();
		
	}
	public static void main(String[] args)
	{
		Post dtd = new Post();
		dtd.setTitle("Dots and Displaying text");
		dtd.setSize(500,500);
		dtd.setVisible(true);
	}
}

class Dots extends Thread
{
	public void run()
	{
		int x,y;
		Graphics g;
		for(;;)
		{
			x=(int)(Math.random() * 500);
			y=(int)(Math.random() * 500);
			g.drawLine(x,y,x,y);
			try
			{
				Thread.sleep(20);
			}
			catch(Exception ex)
			{
				//Exception handler
			}
		}
	}
}

class Text extends Thread
{
	public void run()
	{
		Graphics g;
		g.drawString("Hello!",100,100);
	}
}

class MyWinAdap extends WindowAdapter
{
	public void windowClosing(WindowEvent e)
	{
		System.exit(0);
	}
}




It gives an error - "variable g might not have been intialised".
I want two or more threads working on the same frame displaying different kind of data.
How can I do this??Confused | :confused:
Is there any solution to this??
I'm a beginner please guide me..
AnswerRe: Java Graphics class Pin
Richard MacCutchan22-Sep-15 21:11
mveRichard MacCutchan22-Sep-15 21:11 
AnswerRe: Java Graphics class Pin
Anji Reddy26-Sep-15 6:20
Anji Reddy26-Sep-15 6:20 
QuestionUninstalling the Sun java application server problems Pin
Stephen Holdorf22-Sep-15 2:01
Stephen Holdorf22-Sep-15 2:01 
AnswerRe: Uninstalling the Sun java application server problems Pin
Richard MacCutchan22-Sep-15 21:09
mveRichard MacCutchan22-Sep-15 21:09 
QuestionWhile upgrading the axis2, i got the following java.lang.RuntimeException: Undefined 'Security policy namespace cannot be null.' resource property Pin
RohitSonawat17-Sep-15 1:26
RohitSonawat17-Sep-15 1:26 
SuggestionRe: While upgrading the axis2, i got the following java.lang.RuntimeException: Undefined 'Security policy namespace cannot be null.' resource property Pin
Richard MacCutchan17-Sep-15 1:54
mveRichard MacCutchan17-Sep-15 1:54 
Questiontranscript management using java Pin
Member 1197700411-Sep-15 4:45
Member 1197700411-Sep-15 4:45 
AnswerRe: transcript management using java Pin
Richard MacCutchan11-Sep-15 5:31
mveRichard MacCutchan11-Sep-15 5:31 
Questionbooks examples of precedures stored for sqlserver Pin
DAGOBERTO PAVEZ CASELLA8-Sep-15 6:37
professionalDAGOBERTO PAVEZ CASELLA8-Sep-15 6:37 
AnswerRe: books examples of precedures stored for sqlserver Pin
Afzaal Ahmad Zeeshan8-Sep-15 6:53
professionalAfzaal Ahmad Zeeshan8-Sep-15 6:53 
AnswerRe: books examples of precedures stored for sqlserver Pin
Wendelius8-Sep-15 7:08
mentorWendelius8-Sep-15 7:08 
QuestionDOM XSS and createElement() and getElementsByTagName() methods Pin
Supriya Tonape2-Sep-15 19:54
Supriya Tonape2-Sep-15 19:54 
SuggestionRe: DOM XSS and createElement() and getElementsByTagName() methods Pin
Richard MacCutchan2-Sep-15 21:14
mveRichard MacCutchan2-Sep-15 21:14 
GeneralRe: DOM XSS and createElement() and getElementsByTagName() methods Pin
Supriya Tonape2-Sep-15 22:22
Supriya Tonape2-Sep-15 22:22 
Questionjava Pin
Samson Edward2-Sep-15 15:22
Samson Edward2-Sep-15 15:22 
AnswerRe: java Pin
Richard MacCutchan2-Sep-15 21:13
mveRichard MacCutchan2-Sep-15 21:13 
GeneralMutation Testing tool for Java Pin
Bobby Lough1-Sep-15 9:27
Bobby Lough1-Sep-15 9:27 

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.