Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Applet wont run in i.e. 2

Status
Not open for further replies.

djbjr

Programmer
Dec 7, 2001
106
US
Quick question, I am a Oracle guy so be patient this is my first app ever in Java. I wrote this with the help of NetBeans if that makes a difference

I wrote the following code to generate numbers:

/*
* JApplet.java
*
* Created on April 27, 2004, 12:59 PM
*/

/**
*
* @author bowcudj
*/
import java.sql.*;
public class JApplet extends javax.swing.JApplet {

/** Initializes the applet JApplet */
public void init() {
initComponents();

{




}

}

/** This method is called from within the init() method to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
private void initComponents() {
jButton1 = new javax.swing.JButton();
num1 = new java.awt.TextField();
num2 = new java.awt.TextField();
num3 = new java.awt.TextField();
num4 = new java.awt.TextField();
num5 = new java.awt.TextField();
jLabel1 = new javax.swing.JLabel();
mega_num = new java.awt.TextField();

getContentPane().setLayout(new java.awt.FlowLayout());

jButton1.setText("Generate");
jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jButton1MouseClicked(evt);
}
});

getContentPane().add(jButton1);

getContentPane().add(num1);

getContentPane().add(num2);

getContentPane().add(num3);

getContentPane().add(num4);

getContentPane().add(num5);

jLabel1.setText("Mega Number");
getContentPane().add(jLabel1);

mega_num.setFont(new java.awt.Font("Dialog", 1, 12));
mega_num.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
mega_numActionPerformed(evt);
}
});

getContentPane().add(mega_num);

}

private void mega_numActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}

private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {

int int1 = (int)(1);
int res1 = (int)(48);

int lot1 = (int)(48);
int lot2 = (int)(48);
int lot3 = (int)(48);
int lot4 = (int)(48);
int lot5 = (int)(48);


int int2 = (int)(1);
int res2 = (int)(48);
int int3 = (int)(1);
int res3 = (int)(48);
int int4 = (int)(1);
int res4 = (int)(48);
int int5 = (int)(1);
int res5 = (int)(48);
int int6 = (int)(1);
int res6 = (int)(48);


for(int i=0; i<5; i++)
{
int1 = 1+(int) (1804*Math.random());
if (int1 < 39) {
res1 = 1; }
else if (int1 < 82) {
res1 = 2; }
else if (int1 < 124) {
res1 = 3; }
else if (int1 < 171) {
res1 = 4; }
else if (int1 < 221) {
res1 = 5; }
else if (int1 < 263) {
res1 = 6; }
else if (int1 < 298) {
res1 = 7; }
else if (int1 < 341) {
res1 = 8; }
else if (int1 < 383) {
res1 = 9; }
else if (int1 < 412) {
res1 = 10; }
else if (int1 < 447) {
res1 = 11; }
else if (int1 < 483) {
res1 = 12; }
else if (int1 < 521) {
res1 = 13; }
else if (int1 < 565) {
res1 = 14; }
else if (int1 < 602) {
res1 = 15; }
else if (int1 < 646) {
res1 = 16; }
else if (int1 < 674) {
res1 = 17; }
else if (int1 < 708) {
res1 = 18; }
else if (int1 < 743) {
res1 = 19; }
else if (int1 < 783) {
res1 = 20; }
else if (int1 < 816) {
res1 = 21; }
else if (int1 < 842) {
res1 = 22; }
else if (int1 < 873) {
res1 = 23; }
else if (int1 < 922) {
res1 = 24; }
else if (int1 < 957) {
res1 = 25; }
else if (int1 < 1001) {
res1 = 26; }
else if (int1 < 1036) {
res1 = 27; }
else if (int1 < 1080) {
res1 = 28; }
else if (int1 < 1120) {
res1 = 29; }
else if (int1 < 1164) {
res1 = 30; }
else if (int1 < 1192) {
res1 = 31; }
else if (int1 < 1237) {
res1 = 32; }
else if (int1 < 1275) {
res1 = 33; }
else if (int1 < 1313) {
res1 = 34; }
else if (int1 < 1354) {
res1 = 35; }
else if (int1 < 1394) {
res1 = 36; }
else if (int1 < 1423) {
res1 = 37; }
else if (int1 < 1467) {
res1 = 38; }
else if (int1 < 1498) {
res1 = 39; }
else if (int1 < 1525) {
res1 = 40; }
else if (int1 < 1561) {
res1 = 41; }
else if (int1 < 1594) {
res1 = 42; }
else if (int1 < 1636) {
res1 = 43; }
else if (int1 < 1675) {
res1 = 44; }
else if (int1 < 1718) {
res1 = 45; }
else if (int1 < 1770) {
res1 = 46; }
else res1 = 47;

if (res1 == lot1) {
i = i - 1; }
else if (res1 == lot2) {
i = i - 1; }
else if (res1 == lot3) {
i = i - 1; }
else if (res1 == lot4) {
i = i - 1; }
else if (res1 == lot5) {
i = i - 1; }
else if (lot1 == 48) {
lot1 = res1;}
else if (lot2 == 48) {
lot2 = res1;}
else if (lot3 == 48) {
lot3 = res1;}
else if (lot4 == 48) {
lot4 = res1;}
else if (lot5 == 48) {
lot5 = res1;}

}


//MEGANUMBER

int1 = 1+(int) (364*Math.random());
if (int1 < 17) {
res1 = 1; }
else if (int1 < 25) {
res1 = 2; }
else if (int1 < 35) {
res1 = 3; }
else if (int1 < 47) {
res1 = 4; }
else if (int1 < 53) {
res1 = 5; }
else if (int1 < 66) {
res1 = 6; }
else if (int1 < 78) {
res1 = 7; }
else if (int1 < 93) {
res1 = 8; }
else if (int1 < 114) {
res1 = 9; }
else if (int1 < 131) {
res1 = 10; }
else if (int1 < 146) {
res1 = 11; }
else if (int1 < 156) {
res1 = 12; }
else if (int1 < 173) {
res1 = 13; }
else if (int1 < 188) {
res1 = 14; }
else if (int1 < 199) {
res1 = 15; }
else if (int1 < 214) {
res1 = 16; }
else if (int1 < 225) {
res1 = 17; }
else if (int1 < 239) {
res1 = 18; }
else if (int1 < 249) {
res1 = 19; }
else if (int1 < 266) {
res1 = 20; }
else if (int1 < 276) {
res1 = 21; }
else if (int1 < 293) {
res1 = 22; }
else if (int1 < 313) {
res1 = 23; }
else if (int1 < 332) {
res1 = 24; }
else if (int1 < 356) {
res1 = 25; }
else if (int1 < 365) {
res1 = 26; }
else res1 = 27;


num1.setText("" + lot1);
num2.setText("" + lot2);
num3.setText("" + lot3);
num4.setText("" + lot4);
num5.setText("" + lot5);
mega_num.setText("" + res1);

// TODO add your handling code here:
}


// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private java.awt.TextField mega_num;
private java.awt.TextField num1;
private java.awt.TextField num2;
private java.awt.TextField num3;
private java.awt.TextField num4;
private java.awt.TextField num5;
// End of variables declaration

}


I know this is kinda sloppy but hey this is my first so be nice :)

Here is my HTML:

<html>
<applet code=JApplet.class width=400 height=200>
</applet>
</html>



Enlighten me with your wisdom, maybe someday I can tune a query for ya!

Thanks in advance
 
>>>>> Enlighten me with your wisdom, maybe someday I can tune a query for ya!

Apart from the fact that there must me some algorithm for your six-million "if" statements, what exactly is the problem you are having ?
 
When I run stand alone (using the betbeans debugger) it works fine.

When I insert it into my HTML it run load when i launch the page.
 
Works fine for me. What version of IE are you using?
 
and give me a break on that nasty if statement. I couldnt figure out how to connect to an access DB to store that data I need. That's my next thing to figure out.
 
I just upgraded to i.e. 6.0 and it still doesnt work.

Could it be some setting I have?

I emailed it to a friend and he couldnt see it either.

Is there a way to execute this on its own? Not in a browser?

I know you can execute on a command line but this has a GUI.
 
What is your runtime environment version?

[blue]"Well, once again my friend, we find that science is a two headed beast. One head is nice, it gives us aspirin and other modern conveniences,...but the other head of science is BAD! Oh, beware the other head of science, Arthur; it bites!!" - The Tick[/blue]
 
I just upgraded to 1.4.1_03 and it still doesnt work
 
It works for me too: linux, konqueror, java1.5 (beta).

But this is a bit unusual and confusing - while correct:
Code:
class JApplet extends javax.swing.JApplet
You could try the applet in the appletviewer:
Code:
appletviewer JApplet.html

Perhaps your .class - file isn't in the same directory as the .html?

Is your project somehow related to days and dates?
 
Well the class got screwed up somehow because I compiled it and re wrote the HTML page and now it works.

But hey I have the latest versrion of i.e. and runtime env

YIPPEE!

Thanks guys for all of your help, this was my first Java applet and it actually worked! Very excited.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top