need to edit a Java Cosole app to a Java GUI application. Specifications... Use
ID: 3829413 • Letter: N
Question
need to edit a Java Cosole app to a Java GUI application. Specifications...
Use imported Swing class to create Java GUI form.
Add controls to a Java GUI form.
Modify form control properties with Java code.
Attach Java code to form controls so application is user eventdriven.
please see the code so far...
import java.text.SimpleDateFormat;
import java.util.Date;
public class CompareLoops {
//Declare & Initialize Variables
static double forLoopElapsedTime = 0;
static double whileLoopElapsedTime = 0;
static double doWhileLoopElapsedTime = 0;
//For Loop - Calculate Elapsed Time
public static void calculateForLoopElapsedTime()
{
System.out.println(" ==== For Loop Execution Time ======");
System.out.println("Start Time = " + new SimpleDateFormat("hh:mm:ss a").format(new Date()));
double startTime = System.currentTimeMillis();
long total = 0;
for (int i = 0; i < 10000000; i++)
{
total += i;
}
System.out.println("End Time = " + new SimpleDateFormat("hh:mm:ss a").format(new Date()));
double stopTime = System.currentTimeMillis();
forLoopElapsedTime = (stopTime - startTime)/1000;
System.out.println("While loop average elapsed time = " + forLoopElapsedTime + " seconds");
System.out.println("Completed Loops = " + total);
}
//While Loop - Calculate Elapsed Time
public static void calculateWhileLoopElapesdTime()
{
System.out.println(" ==== While Loop Execution Time ======");
System.out.println("Start Time = " + new SimpleDateFormat("hh:mm:ss a").format(new Date()));
double startTime = System.currentTimeMillis();
long total = 0;
long i = 0;
while(i < 10000000){
total += i;
i++;
}
System.out.println("End Time = " + new SimpleDateFormat("hh:mm:ss a").format(new Date()));
double stopTime = System.currentTimeMillis();
whileLoopElapsedTime = (stopTime - startTime)/1000;
System.out.println("Do While loop average elapsed time = " + whileLoopElapsedTime + " seconds");
System.out.println("Completed Loops = " + total);
}
//Do While Loop - Calculate Elapsed Time
public static void calculateDoWhileLoopElapsedTime()
{
System.out.println(" ==== Do While Loop Execution Time ======");
System.out.println("Start Time = " + new SimpleDateFormat("hh:mm:ss a").format(new Date()));
double startTime = System.currentTimeMillis();
long total = 0;
long i = 0;
do{
total += i;
i++;
}while(i < 10000000);
System.out.println("End Time = " + new SimpleDateFormat("hh:mm:ss a").format(new Date()));
double stopTime = System.currentTimeMillis();
doWhileLoopElapsedTime = (stopTime - startTime)/1000;
System.out.println("For loop average elapsed time = " + doWhileLoopElapsedTime + " seconds");
System.out.println("Completed Loops = " + total);
}
//Compare Elapsed Time
public static void compareElaspedTime()
{
System.out.print(" ");
if(forLoopElapsedTime < whileLoopElapsedTime){
if(forLoopElapsedTime < doWhileLoopElapsedTime){
System.out.println("Fastest execution time : For Loop " +forLoopElapsedTime+ " seconds");
}else{
System.out.println("Fastest execution time : Do While Loop " +doWhileLoopElapsedTime+ " seconds");
}
}else{
if(whileLoopElapsedTime < doWhileLoopElapsedTime){
System.out.println("Fastest execution time : While Loop " +whileLoopElapsedTime+ " seconds");
}else{
System.out.println("Fastest execution time : Do While Loop " +doWhileLoopElapsedTime+ " seconds");
}
}
}
public static void main(String[] args)
{
System.out.println("Average Elapsed Time for 10,000,000 loops in seconds");
System.out.println(" _________________________________ ");
calculateForLoopElapsedTime();
calculateWhileLoopElapesdTime();
calculateDoWhileLoopElapsedTime();
compareElaspedTime();
}
}
*****Must Include These Events
Form Load event
While Loop button Click event
For Loop button Click event
Do While Loop button Click event
Clear All button Click event
************Please model the GUI after after these C# outputs with buttons, etc.
Use imported Swing class to create Java GUI form.
Add controls to a Java GUI form.
Modify form control properties with Java code.
Attach Java code to form controls so application is user eventdriven.
Explanation / Answer
#include <jni.h>
JDK1_1InitArgs vm_args;
JNIEnv* env;
JavaVM* jvm;
vm_args.version = 0x00010001;
JNI_GetDefaultJavaVMInitArgs(&vm_args);
vm_args.classpath =
".;g:/java/jdk1.1.3/lib/classes.zip;";
JNI_CreateJavaVM(&jvm, &env, &vm_args);
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.