Click here to Skip to main content
15,895,283 members
Home / Discussions / Java
   

Java

 
Generaljava.util.List memory usage Pin
thrasher08154-Oct-08 10:55
thrasher08154-Oct-08 10:55 
Questionhow to close acceptandopen for streamconncetionnotifier Pin
manju23reddy2-Oct-08 18:16
manju23reddy2-Oct-08 18:16 
Questiontext twist game project help...... Pin
reanne_8830-Sep-08 21:20
reanne_8830-Sep-08 21:20 
AnswerRe: text twist game project help...... Pin
toxcct30-Sep-08 22:54
toxcct30-Sep-08 22:54 
GeneralRe: text twist game project help...... Pin
reanne_881-Oct-08 4:53
reanne_881-Oct-08 4:53 
Questionhi Pin
my data27-Sep-08 22:06
my data27-Sep-08 22:06 
AnswerRe: hi Pin
toxcct28-Sep-08 21:43
toxcct28-Sep-08 21:43 
QuestionKoch Snowflake Pin
vultron_322926-Sep-08 13:10
vultron_322926-Sep-08 13:10 
Hey folks,
I have a question about writing the koch snowflake in java. When I compile my code I only get the snowflake on one side(so im guessing this is the koch curve instead) and I was wondering how do I get it to all the sides in order to form the snowflake? Here is my code, I know I am missing something but i'm not so sure what. thanks for the help:

import javax.swing.*;
import java.awt.*;

public class drawSnowflake extends JApplet
{
int level=0;
public void init()
{
String levelStr= JOptionPane.showInputDialog("Enter the recursion depth: ");
level = Integer.parseInt(levelStr);
}
public void paint(Graphics g)
{
int pointOne = 60;
int pointTwo = 120;
int pointThree = 160;
int pointFour = 140;


drawKochSide(g, level, pointOne, pointTwo, pointThree, pointFour);

}

private void drawKochSide(Graphics g,int lev, int x1, int y1, int x5, int y5)
{
int deltaX, deltaY, x2, x3, x4, y2,y3, y4;

if (lev<1)
g.drawLine(x1, y1, x5, y5);

else{
deltaX = x5-x1;
deltaY = y5-y1;

x2 = x1 + deltaX / 3;
y2 = y1+ deltaY / 3 ;

x3=(int) ((x1+x5)/2 + Math.sqrt(3.0)*(y1-y5)/6);
y3=(int) ((y1+y5)/2+ Math.sqrt(3.0)* (x5-x1)/6);

x4 = x1 + 2 * deltaX / 3 ;
y4 = y1 + 2 * deltaY / 3 ;

drawKochSide(g, lev-1, x1, y1, x2, y2);
drawKochSide(g, lev-1, x2, y2, x3, y3);
drawKochSide(g, lev-1, x3, y3, x4, y4);
drawKochSide(g, lev-1, x4, y4, x5, y5);
}
}
}
AnswerRe: Koch Snowflake Pin
douss8-Oct-08 4:40
douss8-Oct-08 4:40 
Questionjava-linkedlist Pin
Bavirti25-Sep-08 1:00
Bavirti25-Sep-08 1:00 
AnswerRe: java-linkedlist Pin
toxcct25-Sep-08 2:19
toxcct25-Sep-08 2:19 
GeneralRe: java-linkedlist [modified] Pin
Bavirti25-Sep-08 2:46
Bavirti25-Sep-08 2:46 
GeneralRe: java-linkedlist Pin
toxcct25-Sep-08 2:49
toxcct25-Sep-08 2:49 
QuestionEquivalent to .net usercontrol Pin
Russell Jones22-Sep-08 22:33
Russell Jones22-Sep-08 22:33 
AnswerRe: Equivalent to .net usercontrol Pin
Russell Jones22-Sep-08 23:10
Russell Jones22-Sep-08 23:10 
QuestionOdd String/Vector behavior [solved] Pin
David Crow19-Sep-08 5:55
David Crow19-Sep-08 5:55 
AnswerRe: Odd String/Vector behavior Pin
toxcct19-Sep-08 7:07
toxcct19-Sep-08 7:07 
GeneralRe: Odd String/Vector behavior Pin
David Crow19-Sep-08 7:15
David Crow19-Sep-08 7:15 
Questionhow to send live recording audio Pin
manju23reddy17-Sep-08 21:17
manju23reddy17-Sep-08 21:17 
Questionsimple web cam chat application Pin
Matthew Dally17-Sep-08 17:12
Matthew Dally17-Sep-08 17:12 
QuestionDownloading Bank Account Info... Pin
bane7313-Sep-08 7:36
bane7313-Sep-08 7:36 
QuestionSwing:JDialog Pin
shwetabhas12-Sep-08 10:21
shwetabhas12-Sep-08 10:21 
AnswerRe: Swing:JDialog Pin
toxcct14-Sep-08 22:10
toxcct14-Sep-08 22:10 
QuestionSSN Validation Pin
Sudheer.kumarmatta9-Sep-08 20:16
Sudheer.kumarmatta9-Sep-08 20:16 
Questionproblem in bluetooth programming in java Pin
manju23reddy8-Sep-08 20:09
manju23reddy8-Sep-08 20:09 

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.