JavaScript call to Java applet

Sorry if this message get posted twice, but I haven't seen the 1st. I sent.
I seem to have a problem with a form trying to call an applet. I hava a button like this:
<input type=button value="Add" onClick="Nota.addRow('2','3','12.80','Cacahuates Mafer 1/2 kg.')">
my Nota.addRow method is thisone:
public void addRow (String idS, String qtyS, String priceS, String desc) {
int id= Integer.parseInt (idS);
int qty= Integer.parseInt (qtyS);
float price= Float.parseFloat (priceS);
remove (total);
renglones[renglonCnt]= new Renglon (id,qty,price,desc);
add (renglones[renglonCnt]);//<- This line is not adding the Row when i call it from JavaScript. Otherwise it works just fine...
//total= Renglon.Total();
//add (total);
System.out.println("El id es: " + Integer.toString(id));
System.out.println("La cantidad es: " + Integer.toString(qty));
System.out.println("El precio es: " + Float.toString(price));
System.out.println("La descripcion es: " + desc.toString());
System.out.println("El precio del objeto es: " + Float.toString(renglones[renglonCnt].getTotal()));
renglonCnt++;
Altough my addRow works when I callit from a Nota object it doesn't when i call it from javascript.
total is just a panel that you get from class Renglon.
And Renglon is a Panel class too.
I'll appreciate any help, thanks.
Jeronimo

Hey, that's really good news, does it actually adds the row to the applet and gets the new total?!
Anyway, i tried 1.) (wich describes the applet quite well) and 2.) but still doesn't works for me. Also changed the "price" line...
Im using:
Navigator 4.72
IE 5.50
Netscape 6
Here's the html code (the form):
<form>
<table border=5 WIDTH=500 align=center>
<tr>
<TD width=30%>
<table border=1 width="100%" >
<tr>
<th WIDTH="20%"> Cantidad </th>
<th WIDTH="26%"> Descripci&oacute;n </th>
<th WIDTH="20%">Precio Unitario</th>
<th WIDTH="20%"> Agregar </th>
</tr>
<tr>
<td WIDTH="20%" align=center>
     <input size=2 name=cantidad maxlength=2>
     </td>
<td WIDTH="26%">
     Cerveza Sol 600ml.
     </td>
<td WIDTH="20%">
     $15.50
     </td>
<td WIDTH="20%" align=center>
     <input type=button value="Add" onClick="document.Nota.addRow('1','12','15.50','Cerveza-Sol-600ml.')">
     </td>
</tr>
<tr>
<td WIDTH="20%" align=center><input size=2 maxlength=2></td>
<td WIDTH="26%">
     Cacahuates Mafer 1/2 kg.
     </td>
<td WIDTH="20%">
     $12.80
     </td>
<td WIDTH="20%" align=center>
     <!--<input type=button value="Add" onClick="Nota.addRow('2','3','12.80','Cacahuates Mafer 1/2 kg.')">
     -->
     <input type=button value="Test" onClick="alert (Nota)"
     </td>
</tr>
<tr>
<td WIDTH="20%" align=center><input size=2 maxlength=2></td>
<td WIDTH="26%"> </td>
<td WIDTH="20%"> </td>
<td WIDTH="20%" align=center>
     <input type=button value="Add">
     </td>
</tr>
<tr>
<td WIDTH="20%" align=center><input size=2 maxlength=2></td>
<td WIDTH="26%"> </td>
<td WIDTH="20%"> </td>
<td WIDTH="20%" align=center><input type=button value="Add"></td>
</tr>
</table>
</td>
<td width="40%">
<applet name=Nota code=Nota.class width=350 height=250> </applet>
</td>
</tr>
<tr>
<td colspan=2 align=center>
<input type=button value="Enviar Pedido">
</td>
</tr>
</table>
</form>
Here's the Nota applet code:
import java.awt.*;
import java.applet.*;
public class Nota extends Applet {
private Renglon renglones[];
private BarraTitulo titulo;
private int renglonCnt;
private Panel total;
public void init () {
setLayout (new GridLayout(12,1));
renglonCnt=0;
renglones= new Renglon [10];
total= Renglon.Total();
public void start () {
String titulos[]= new String [4];
titulos[0]="(-) Cantidad (+)";
titulos[1]="Descripcion";
titulos[2]="Precio Unitario";
titulos[3]="Total";
titulo= new BarraTitulo (titulos,12);
add (titulo);
add (total);
public void addRow (String idS, String qtyS, String priceS, String desc) {
int id= Integer.parseInt (idS);
int qty= Integer.parseInt (qtyS);
//float price= Float.parseFloat (priceS);
float price= Float.valueOf (priceS).floatValue();
remove (total);
renglones[renglonCnt]= new Renglon (id,qty,price,desc);
add (renglones[renglonCnt]);
//total= Renglon.Total();
//add (total);
//THESE LINES SHOW EVERTHING WELL IN THE JAVA CONSOLE, BUT THESE ARE JUST FOR DEBUG. System.out.println("El id es: " + Integer.toString(id));
System.out.println("La cantidad es: " + Integer.toString(qty));
System.out.println("El precio es: " + Float.toString(price));
System.out.println("La descripcion es: " + desc.toString());
System.out.println("El precio del objeto es: " + Float.toString(renglones[renglonCnt].getTotal()));
renglonCnt++;
This is the Renglon class code:
import java.awt.*;
import java.awt.event.*;
public class Renglon extends Panel implements ActionListener {
private TextField qty, description, up, total;
private Button more, less;
private int cantidad, identificador;
private float unitP;
private String descripcion;
static float elTotal= 0;
static Panel totalP= new Panel();
static Label c4tot= new Label();
public Renglon () {
this(1, 1, (float) 2.50, "Algun articulo");
public Renglon (int id, int q, float pu, String desc) {
identificador= id;
cantidad= q;
unitP= pu;
descripcion= desc;
elTotal+= cantidad * unitP;
Panel addsub;
setLayout (new GridLayout (1,4));
addsub= new Panel();
addsub.setLayout(new GridLayout(1,3));
less= new Button ("<<");
more= new Button (">>");
less.addActionListener (this);
more.addActionListener (this);
Integer c= new Integer (cantidad);
qty= new TextField (c.toString());
description= new TextField (descripcion);
Float x= new Float (unitP);
up= new TextField ("$" + x.toString());
Float t= new Float (getTotal());
total= new TextField ("$" + t.toString());
qty.setEditable (false);
description.setEditable (false);
up.setEditable (false);
total.setEditable (false);
addsub.add (less);
addsub.add (qty);
addsub.add (more);
add (addsub);
add (description);
add (up);
add (total);
setVisible (true);
public float getTotal () {
return ((float) cantidad*unitP);
public void actionPerformed (ActionEvent e) {
if (e.getActionCommand().equals("<<")){
cantidad--;
elTotal-= unitP;
if (cantidad < 0) {
cantidad=0;
     elTotal+= unitP;
} else {
cantidad++;
elTotal+= unitP;
Float nuevoTot= new Float (getTotal());
Integer c= new Integer (cantidad);
qty.setText (c.toString());
total.setText ("$" + nuevoTot.toString());
Float et= new Float (elTotal);
c4tot.setText("$" + et.toString());
static public Panel Total () {
totalP.setLayout (new GridLayout(1,4));
Label c1,c2,c3;
Float totalF= new Float (elTotal);
c1= new Label("");
c2= new Label("");
c3= new Label("Total:");
c4tot= new Label("$" + totalF.toString());
totalP.add(c1);
totalP.add(c2);
totalP.add(c3);
totalP.add(c4tot);
totalP.setVisible(true);
return (totalP);
And just in case, this is the BarraTitulo class code:
import java.awt.*;
public class BarraTitulo extends Panel {
public BarraTitulo (String [] titulos) {
this (titulos,15);
public BarraTitulo (String [] titulos, int size) {
Label labels;
Font ft= new Font("Serif",Font.BOLD, size);
int length= titulos.length + 1;
setLayout (new GridLayout (1,length));
setFont (ft);
for (int i=0; i< titulos.length; i++) {
labels= new Label(titulos);
add (labels);
Thanx again for your time.
Jeronimo

Similar Messages

  • Easy way to convert javascript to a java applet?

    Hello all! I am relatively new to java and java programming and had a question about converting a JavaScript to a java applet or even a standalone application. I included the JavaScript code for a checkers game below and wanted to know what would be the easiest way to convert this code if at all possible?
    Thanks in advance,
    Bob
    <SCRIPT language=JavaScript>
    <!--
    version = 1.0;
    // -->
    </SCRIPT>
    <SCRIPT language=JavaScript1.1>
    <!--
    version = 1.1;
    // -->
    </SCRIPT>
    <SCRIPT language=JavaScript>
    <!--
    if (version==1.0)
    document.write("Your browser doesn't have JavaScript 1.1 capabilities. "
    + "This checkers game script only works on Netscape 3+ and MSIE 4+.");
    // -->
    </SCRIPT>
    <SCRIPT language=JavaScript1.1>
    <!--
    // Checkers Game
    // black.gif
    // gray.gif
    // you1.gif -- normal piece (player/red)
    // you2.gif -- highlighted piece
    // you1k.gif -- kinged normal piece
    // you2k.gif -- kinged highlighted piece
    // me1.gif -- normal piece (computer/black)
    // me2.gif -- highlighted piece
    // me1k.gif -- kinged normal piece
    // me2k.gif -- kinged highlighted piece
    function preload() {
    this.length = preload.arguments.length;
    for (var i = 0; i < this.length; i++) {
    this[i] = new Image();
    this.src = preload.arguments[i];
    var pics = new preload("black.gif","gray.gif",
    "you1.gif","you2.gif","you1k.gif","you2k.gif",
    "me1.gif","me2.gif","me1k.gif","me2k.gif");
    var black = -1; // computer is black
    var red = 1; // visitor is red
    var square_dim = 35;
    var piece_toggled = false;
    var my_turn = false;
    var double_jump = false;
    var comp_move = false;
    var game_is_over = false;
    var safe_from = safe_to = null;
    var toggler = null;
    var togglers = 0;
    function Board() {
    board = new Array();
    for (var i=0;i<8; i++) {
    board[i] = new Array();
    for (var j=0;j<8;j++)
    board[i][j] = Board.arguments[8*j+i];
    board[-2] = new Array(); // prevents errors
    board[-1] = new Array(); // prevents errors
    board[8] = new Array(); // prevents errors
    board[9] = new Array(); // prevents errors
    var board;
    Board(1,0,1,0,1,0,1,0,
    0,1,0,1,0,1,0,1,
    1,0,1,0,1,0,1,0,
    0,0,0,0,0,0,0,0,
    0,0,0,0,0,0,0,0,
    0,-1,0,-1,0,-1,0,-1,
    -1,0,-1,0,-1,0,-1,0,
    0,-1,0,-1,0,-1,0,-1);
    function message(str) {
    if (!game_is_over)
    document.disp.message.value = str;
    function moveable_space(i,j) {
    // calculates whether it is a gray (moveable)
    // or black (non-moveable) space
    return (((i%2)+j)%2 == 0);
    function Coord(x,y) {
    this.x = x;
    this.y = y;
    function coord(x,y) {
    c = new Coord(x,y);
    return c;
    document.write("<table border=0 cellspacing=0 cellpadding=0 width="+(square_dim*8+8)
    +"<tr><td><img src='black.gif' width="+(square_dim*8+8)
    +" height=4><br></td></tr>");
    for(var j=0;j<8;j++) {
    document.write("<tr><td><img src='black.gif' width=4 height="+square_dim+">");
    for(var i=0;i<8;i++) {
    if (moveable_space(i,j))
    document.write("<a href='javascript:clicked("+i+","+j+")'>");
    document.write("<img src='");
    if (board[i][j]==1) document.write("you1.gif");
    else if (board[i][j]==-1) document.write("me1.gif");
    else if (moveable_space(i,j)) document.write("gray.gif");
    else document.write("black.gif");
    document.write("' width="+square_dim+" height="+square_dim
    +" name='space"+i+""+j+"' border=0>");
    if (moveable_space(i,j)) document.write("</a>");
    document.write("<img src='black.gif' width=4 height="+square_dim+"></td></tr>");
    document.write("<tr><td><img src='black.gif' width="+(square_dim*8+8)
    +" height=4><br></td></tr></table><br>"
    +"<form name='disp'><textarea name='message' wrap=virtual rows=2 cols=40></textarea><br><input "
    +"type=button value=\"Start the Game Over\" onClick=\"location.href+=''\"></form>");
    function clicked(i,j) {
    if (my_turn) {
    if (integ(board[i][j])==1) toggle(i,j);
    else if (piece_toggled) move(selected,coord(i,j));
    else message("First click one of your red pieces, then click where you want to move it");
    } else {
    message("It's not your turn yet. Hang on a sec!");
    function toggle(x,y) {
    if (my_turn) {
    if (piece_toggled)
    draw(selected.x,selected.y,"you1"+((board[selected.x][selected.y]==1.1)?"k":"")+".gif");
    if (piece_toggled && (selected.x == x) && (selected.y == y)) {
    piece_toggled = false;
    if (double_jump) { my_turn = double_jump = false; computer(); }
    } else {
    piece_toggled = true;
    draw(x,y,"you2"+((board[x][y]==1.1)?"k":"")+".gif");
    selected = coord(x,y);
    } else {
    if ((piece_toggled) && (integ(board[selected_c.x][selected_c.y])==-1))
    draw(selected_c.x,selected_c.y,"me1"+((board[selected_c.x][selected_c.y]==-1.1)?"k":"")+".gif");
    if (piece_toggled && (selected_c.x == x) && (selected_c.y == y)) {
    piece_toggled = false;
    } else {
    piece_toggled = true;
    draw(x,y,"me2"+((board[x][y]==-1.1)?"k":"")+".gif");
    selected_c = coord(x,y);
    function draw(x,y,name) {
    document.images["space"+x+""+y].src = name;
    function integ(num) {
    if (num != null)
    return Math.round(num);
    else
    return null;
    function abs(num) {
    return Math.abs(num);
    function sign(num) {
    if (num < 0) return -1;
    else return 1;
    function concatenate(arr1,arr2) {
    // function tacks the second array onto the end of the first and returns result
    for(var i=0;i<arr2.length;i++)
    arr1[arr1.length+i] = arr2[i];
    return arr1;
    function legal_move(from,to) {
    if ((to.x < 0) || (to.y < 0) || (to.x > 7) || (to.y > 7)) return false;
    piece = board[from.x][from.y];
    distance = coord(to.x-from.x,to.y-from.y);
    if ((distance.x == 0) || (distance.y == 0)) {
    message("You may only move diagonally.");
    return false;
    if (abs(distance.x) != abs(distance.y)) {
    message("Invalid move.");
    return false;
    if (abs(distance.x) > 2) {
    message("Invalid move.");
    return false;
    if ((abs(distance.x) == 1) && double_jump) {
    return false;
    if ((board[to.x][to.y] != 0) || (piece == 0)) {
    return false;
    if ((abs(distance.x) == 2)
    && (integ(piece) != -integ(board[from.x+sign(distance.x)][from.y+sign(distance.y)]))) {
    return false;
    if ((integ(piece) == piece) && (sign(piece) != sign(distance.y))) {
    return false;
    return true;
    function move(from,to) {
    my_turn = true;
    if (legal_move(from,to)) {
    piece = board[from.x][from.y];
    distance = coord(to.x-from.x,to.y-from.y);
    if ((abs(distance.x) == 1) && (board[to.x][to.y] == 0)) {
    swap(from,to);
    } else if ((abs(distance.x) == 2)
    && (integ(piece) != integ(board[from.x+sign(distance.x)][from.y+sign(distance.y)]))) {
    double_jump = false;
    swap(from,to);
    remove(from.x+sign(distance.x),from.y+sign(distance.y));
    if ((legal_move(to,coord(to.x+2,to.y+2)))
    || (legal_move(to,coord(to.x+2,to.y-2)))
    || (legal_move(to,coord(to.x-2,to.y-2)))
    || (legal_move(to,coord(to.x-2,to.y+2)))) {
    double_jump = true;
    message("You may complete the double jump or click on your piece to stay still.");
    if ((board[to.x][to.y] == 1) && (to.y == 7)) king_me(to.x,to.y);
    selected = to;
    if (game_over() && !double_jump) {
    setTimeout("toggle("+to.x+","+to.y+");my_turn = double_jump = false;computer();",1000);
    return true;
    function king_me(x,y) {
    if (board[x][y] == 1) {
    board[x][y] = 1.1; // king you
    draw(x,y,"you2k.gif");
    } else if (board[x][y] == -1) {
    board[x][y] = -1.1; // king me
    draw(x,y,"me2k.gif");
    function swap(from,to) {
    if (my_turn || comp_move) {
    dummy_src = document.images["space"+to.x+""+to.y].src;
    document.images["space"+to.x+""+to.y].src = document.images["space"+from.x+""+from.y].src;
    document.images["space"+from.x+""+from.y].src = dummy_src;
    dummy_num = board[from.x][from.y];
    board[from.x][from.y] = board[to.x][to.y];
    board[to.x][to.y] = dummy_num;
    function remove(x,y) {
    if (my_turn || comp_move)
    draw(x,y,"gray.gif");
    board[x][y] = 0;
    function Result(val) {
    this.high = val;
    this.dir = new Array();
    function move_comp(from,to) {
    toggle(from.x,from.y);
    comp_move = true;
    swap(from,to);
    if (abs(from.x-to.x) == 2) {
    remove(from.x+sign(to.x-from.x),from.y+sign(to.y-from.y));
    if ((board[to.x][to.y] == -1) && (to.y == 0)) king_me(to.x,to.y);
    setTimeout("selected_c = coord("+to.x+","+to.y+");piece_toggled = true;",900);
    setTimeout("bak=my_turn;my_turn=false;toggle("+to.x+","+to.y+");my_turn=bak;",1000);
    if (game_over()) {
    setTimeout("comp_move = false;my_turn = true;togglers=0;",600);
    message("Ok. It's your turn. You may make your move.");
    return true;
    function game_over() { // make sure game is not over (return false if game is over)
    comp = you = false;
    for(var i=0;i<8;i++) {
    for(var j=0;j<8;j++) {
    if(integ(board[i][j]) == -1) comp = true;
    if(integ(board[i][j]) == 1) you = true;
    if (!comp) message("You beat me!");
    if (!you) message("Gotcha! Game over.");
    game_is_over = (!comp || !you)
    return (!game_is_over);
    // the higher the jump_priority, the more often the computer will take the jump over the safe move
    var jump_priority = 10;
    function computer() {
    // step one - prevent any jumps
    for(var j=0;j<8;j++) {
    for(var i=0;i<8;i++) {
    if (integ(board[i][j]) == 1) {
    if ((legal_move(coord(i,j),coord(i+2,j+2))) && (prevent(coord(i+2,j+2),coord(i+1,j+1)))) {
    return true;
    } if ((legal_move(coord(i,j),coord(i-2,j+2))) && (prevent(coord(i-2,j+2),coord(i-1,j+1)))) {
    return true;
    } if (board[i][j] == 1.1) {
    if ((legal_move(coord(i,j),coord(i-2,j-2))) && (prevent(coord(i-2,j-2),coord(i-1,j-1)))) {
    return true;
    } if ((legal_move(coord(i,j),coord(i+2,j-2))) && (prevent(coord(i+2,j-2),coord(i+1,j-1)))) {
    return true;
    // step two - if step one not taken, look for jumps
    for(var j=7;j>=0;j--) {
    for(var i=0;i<8;i++) {
    if (jump(i,j))
    return true;
    safe_from = null;
    // step three - if step two not taken, look for safe single space moves
    for(var j=0;j<8;j++) {
    for(var i=0;i<8;i++) {
    if (single(i,j))
    return true;
    // if no safe moves, just take whatever you can get
    if (safe_from != null) {
    move_comp(safe_from,safe_to);
    } else {
    message("You beat me!!");
    game_is_over = true;
    safe_from = safe_to = null;
    return false;
    function jump(i,j) {
    if (board[i][j] == -1.1) { 
    if (legal_move(coord(i,j),coord(i+2,j+2))) {
    move_comp(coord(i,j),coord(i+2,j+2));
    setTimeout("jump("+(i+2)+","+(j+2)+");",500);
    return true;
    } if (legal_move(coord(i,j),coord(i-2,j+2))) {
    move_comp(coord(i,j),coord(i-2,j+2));
    setTimeout("jump("+(i-2)+","+(j+2)+");",500);
    return true;
    } if (integ(board[i][j]) == -1) {
    if (legal_move(coord(i,j),coord(i-2,j-2))) {
    move_comp(coord(i,j),coord(i-2,j-2));
    setTimeout("jump("+(i-2)+","+(j-2)+");",500);
    return true;
    } if (legal_move(coord(i,j),coord(i+2,j-2))) {
    move_comp(coord(i,j),coord(i+2,j-2));
    setTimeout("jump("+(i+2)+","+(j-2)+");",500);
    return true;
    return false;
    function single(i,j) {
    if (board[i][j] == -1.1) {
    if (legal_move(coord(i,j),coord(i+1,j+1))) {
    safe_from = coord(i,j);
    safe_to = coord(i+1,j+1);
    if (wise(coord(i,j),coord(i+1,j+1))) {
    move_comp(coord(i,j),coord(i+1,j+1));
    return true;
    } if (legal_move(coord(i,j),coord(i-1,j+1))) {
    safe_from = coord(i,j);
    safe_to = coord(i-1,j+1);
    if (wise(coord(i,j),coord(i-1,j+1))) {
    move_comp(coord(i,j),coord(i-1,j+1));
    return true;
    } if (integ(board[i][j]) == -1) {
    if (legal_move(coord(i,j),coord(i+1,j-1))) {
    safe_from = coord(i,j);
    safe_to = coord(i+1,j-1);
    if (wise(coord(i,j),coord(i+1,j-1))) {
    move_comp(coord(i,j),coord(i+1,j-1));
    return true;
    } if (legal_move(coord(i,j),coord(i-1,j-1))) {
    safe_from = coord(i,j);
    safe_to = coord(i-1,j-1);
    if (wise(coord(i,j),coord(i-1,j-1))) {
    move_comp(coord(i,j),coord(i-1,j-1));
    return true;
    return false;
    function possibilities(x,y) {
    if (!jump(x,y))
    if (!single(x,y))
    return true;
    else
    return false;
    else
    return false;
    function prevent(end,s) {
    i = end.x;
    j = end.y;
    if (!possibilities(s.x,s.y))
    return true;
    else if ((integ(board[i-1][j+1])==-1) && (legal_move(coord(i-1,j+1),coord(i,j)))) {
    return move_comp(coord(i-1,j+1),coord(i,j));
    } else if ((integ(board[i+1][j+1])==-1) && (legal_move(coord(i+1,j+1),coord(i,j)))) {
    return move_comp(coord(i+1,j+1),coord(i,j));
    } else if ((board[i-1][j-1]==-1.1) && (legal_move(coord(i-1,j-1),coord(i,j)))) {
    return move_comp(coord(i-1,j-1),coord(i,j));
    } else if ((board[i+1][j-1]==-1.1) && (legal_move(coord(i+1,j-1),coord(i,j)))) {
    return move_comp(coord(i+1,j-1),coord(i,j));
    } else {
    return false;
    function wise(from,to) {
    i = to.x;
    j = to.y;
    n = (j>0);
    s = (j<7);
    e = (i<7);
    w = (i>0);
    if (n&&e) ne = board[i+1][j-1]; else ne = null;
    if (n&&w) nw = board[i-1][j-1]; else nw = null;
    if (s&&e) se = board[i+1][j+1]; else se = null;
    if (s&&w) sw = board[i-1][j+1]; else sw = null;
    eval(((j-from.y != 1)?"s":"n")+((i-from.x != 1)?"e":"w")+"=0;");
    if ((sw==0) && (integ(ne)==1)) return false;
    if ((se==0) && (integ(nw)==1)) return false;
    if ((nw==0) && (se==1.1)) return false;
    if ((ne==0) && (sw==1.1)) return false;
    return true;
    message("You may begin! Select a piece to move.");
    my_turn = true;
    // -->
    </SCRIPT>

    Well, you can get a free tutorial to Java at http://www.mindview.net/. It's the "Thinking In Java" book. You can download the whole book from that site, it's about a thousand pages. If you read that whole book, you'll know exactly where to start and probably how to finish it too.
    As a gimmie, think about it -- you'll have to remove all of the browser-detect code, since browser-detection is only done to determine which version of JavaScript is supported by the browser.

  • Calling a Java Applet - Javascript

    Hey guys,
    I'm still fairly new to Java. I'm having a hard time getting my Applet to run properly.
    Basically, this is what I want it to do:
    I have a web page with a series of fields on it (a form). I have a submit button. When the user clicks the submit button, it activates a Javascript function in a seperate file that validates ALL of these fields. The validation that it does is merely to determine whether or not the fields are blank.
    Once it's accomplished this task, I THEN want it to run a Java applet.
    Everything works up until the point at which it runs the Java applet. I'm not sure how exactly I'm supposed to call the applet from Javascript.
    In every example of a web page that I see that has an applet, it has something that looks like this:
    <APPLET CODE="classname.class >
    </APPLET>That's all fine and good, but the problem is that it automatically calls the Applet then. I don't want it to do that. Is there a way that I can CALL the applet at the very end of a JS file? I mean, I don't want anything to load, no grey boxes or any of that stuff until I actually call it..
    Any idea?
    Thanks!
    Todd

    dude,
    have you managed to call an applet method from firefox?
    I'm not sure it is working at all.
    I've read few articles and everyone is complaining about the same error:
    Error: document.appl01 has no properties
    in the case above the applet was called "appl01"
    I've tried using
    document.applets[0].<the applet method>
    and I've got the same result..

  • IE6 leaks "Handles" when calling *ANY* Java applet

    Hello all IE experts,
    It seems that IE has "Handles" leak when it calls Java Applet.
    Every call to a Java method from JavaScript, IE allocate a handle and does
    not free it.
    THIS DOES NOT HAPPEN when I use mozilla or Netscape.
    Versions:
    * Windows 2000 SP 3 (The most recent, with all fixes of hfnetchk)
    * Internet Explorer (The most recent one, with all fixes of hfnetchk)
    Version 6.0.2800.1106
    SP1
    Q328970
    Q324929
    Q810847
    Q813951
    * Java Plug-in - 1.4.1_02-b06
    If you compile the applet and use the test html, then press "Test" you will
    notice that 1000 (or more) handles are allocated (At Windows Task Manager).
    If you press again you will see that another 1000 (or more) handles are
    allocated. The handles are NEVER released, even if you browse to other
    sites. You can enjoy this process until there are no more handles to
    allocate... :)
    Notice that the applet I use does nothing... I've checked this with various
    of applets on the web and the results are the same.
    Can anyone help?
    Best Regards,
    Alon Bar-Lev
    ** The following html is used: (test1.htm)
    <html>
    <head>
    <script LANGUAGE="JavaScript">
    function OnTest () {
    for (var i=0;i<1000;i++) { a1.method1 (); }
    </script>
    </head>
    <body>
    <input type=button onclick="OnTest ()" value="Test"></input>
    <APPLET code="test1.applet1.class" archive="test1.jar" id="a1" name="a1">No
    Java</APPLET>
    </body>
    </html>
    ** The following applet: (test1/applet1.java)
    package test1;
    import java.applet.*;
    public class applet1 extends Applet {
    public void method1 () {}
    ** The following makefile: (Makefile)
    JAVAC="$(J2SE)\bin\javac" -classpath $(CLASSPATH)
    JAR="$(J2SE)\bin\jar" -cvf
    CLASSPATH=.
    all:
    $(JAVAC) test1/*.java
    $(JAR) test1.jar test1/*.class

    New information:
    This happens from Java version 1.4.0_01.
    This did not happen in Java version 1.4.0.
    Alon.

  • Calling a java applet

    Hi all
    I have made a java applet, which gets some client machine
    information. I have to call that applet from my form. Is there
    any way to do so. Also is there any way that my applet which
    gets the installed printer on client machine, can pass the name
    of the printer to the calling form ???

    To call an applet you can use web.show_document builtin to call
    an html page that activates the applet.
    To pass parameters to form you can have your applet write the
    info to the database or the server's file system and then have
    form read it from there.
    You might also be interested in the ability to have a Javabean
    inside a form that can communicate with the form directly.

  • Unix script call from java applet

    In perl you can use the system command to call a unix command like mv or ls. How do run a unix command from a java applet?

    normaly java applets are not allowed to execute any code. But there is a possibility to ask the user to be allowed to..
    in Netscpae you can use the following:
    import netscape.security.PrivilegeManager;
    then somewhere in the class...
    PrivilegeManager.enablePrivilege( "UniversalExecAccess" );
    then the user can press 'grant' or 'deni'. If he pressed grant, you can do the following:
    Process process = Runtime.getRuntime().exec( "command" );
    //where command is what ever command you like to execute
    hope that helps.
    lexip

  • I'm trying to develop a PKI enabled plugin for firefox using add-on builder. how do you call a java applet using add-on javascript on add-on builder ?

    i have a signed applet which encrypts and digitally signs text information. i need to call this applet from the add-on javascript on firefox's add-on builder . how do i do it ?
    i've tried using contentScript and contentScriptFile to load the html file which calls the applet vis applet tag , it doesnt work.
    this is the error which croped up:
    Java Plug-in 1.6.0_26
    Using JRE version 1.6.0_26-b03-383-11A511 Java HotSpot(TM) 64-Bit Server VM
    User home directory = /Users/sreer1990
    c: clear console window
    f: finalize objects on finalization queue
    g: garbage collect
    h: display this help message
    l: dump classloader list
    m: print memory usage
    o: trigger logging
    q: hide console
    r: reload policy configuration
    s: dump system and deployment properties
    t: dump thread list
    v: dump thread stack
    x: clear classloader cache
    0-5: set trace level to <n>
    java.lang.NullPointerException
    at sun.net.www.ParseUtil.toURI(ParseUtil.java:261)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:861)
    at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:836)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1172)
    at sun.plugin.PluginURLJarFileCallBack.downloadJAR(PluginURLJarFileCallBack.java:81)
    at sun.plugin.PluginURLJarFileCallBack.access$000(PluginURLJarFileCallBack.java:48)
    at sun.plugin.PluginURLJarFileCallBack$2.run(PluginURLJarFileCallBack.java:150)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.plugin.PluginURLJarFileCallBack.retrieve(PluginURLJarFileCallBack.java:127)
    at sun.net.www.protocol.jar.URLJarFile.retrieve(URLJarFile.java:186)
    at sun.net.www.protocol.jar.URLJarFile.getJarFile(URLJarFile.java:50)
    at sun.net.www.protocol.jar.JarFileFactory.get(JarFileFactory.java:70)
    at sun.net.www.protocol.jar.JarURLConnection.connect(JarURLConnection.java:104)
    at sun.plugin.net.protocol.jar.CachedJarURLConnection.connect(CachedJarURLConnection.java:201)
    at sun.plugin.net.protocol.jar.CachedJarURLConnection.getJarFileInternal(CachedJarURLConnection.java:145)
    at sun.plugin.net.protocol.jar.CachedJarURLConnection.getJarFile(CachedJarURLConnection.java:91)
    at com.sun.deploy.security.DeployURLClassPath$JarLoader.getJarFile(DeployURLClassPath.java:752)
    at com.sun.deploy.security.DeployURLClassPath$JarLoader.access$800(DeployURLClassPath.java:631)
    at com.sun.deploy.security.DeployURLClassPath$JarLoader$1.run(DeployURLClassPath.java:698)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.deploy.security.DeployURLClassPath$JarLoader.ensureOpen(DeployURLClassPath.java:690)
    at com.sun.deploy.security.DeployURLClassPath$JarLoader.<init>(DeployURLClassPath.java:652)
    at com.sun.deploy.security.DeployURLClassPath$3.run(DeployURLClassPath.java:400)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.deploy.security.DeployURLClassPath.getLoader(DeployURLClassPath.java:389)
    at com.sun.deploy.security.DeployURLClassPath.getLoader(DeployURLClassPath.java:366)
    at com.sun.deploy.security.DeployURLClassPath.getResource(DeployURLClassPath.java:230)
    at sun.plugin2.applet.Plugin2ClassLoader$2.run(Plugin2ClassLoader.java:966)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.plugin2.applet.Plugin2ClassLoader.findClassHelper(Plugin2ClassLoader.java:955)
    at sun.plugin2.applet.Applet2ClassLoader.findClass(Applet2ClassLoader.java:134)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Plugin2ClassLoader.java:250)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Plugin2ClassLoader.java:180)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Plugin2ClassLoader.java:240)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Plugin2ClassLoader.java:180)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Plugin2ClassLoader.java:161)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Plugin2ClassLoader.java:675)
    at sun.plugin2.applet.Plugin2Manager.createApplet(Plugin2Manager.java:3046)
    at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Plugin2Manager.java:1498)
    at java.lang.Thread.run(Thread.java:680)
    Exception: java.lang.NullPointerException

    Try posting at the Web Development / Standards Evangelism forum at MozillaZine. The helpers over there are more knowledgeable about web page development issues with Firefox. <br />
    http://forums.mozillazine.org/viewforum.php?f=25 <br />
    You'll need to register and login to be able to post in that forum.

  • Firefox 2.0.0.8 = security alert when calling a Java applet method

    I have a JavaHelp applet that I launch using a method that I called
    from JavaScript when a user clicks on a link.
    A problem I found with Firefox 2.0.0.8 and JRE 1.4 is that when I
    click on the link it will try to display a security alert window, but
    the window appears to freeze up when it is being displayed and hangs
    the browser. For example, I cannot see any of the buttons that should
    be on the security window. Rather the main window is empty. However,
    if my applet exposes a button that the user can directly click, the
    security window displays properly and can be dismissed.
    With the same JavaHelp applet, the link works fine if I use it Firefox
    2.0 and JRE 1.6 or JRE 1.5, and with IE 6.0 and IE 7.0. I uninstalled
    and reinstalled Firefox with JRE 1.4, and I couldn't reproduce the
    problem. However, I'm concerned that this problem may resurface in
    the future.
    Has anyone ever seem a similar problem? And if so, are there any easy
    workarounds?

    >
    I have a JavaHelp applet.. >I suggest you launch it using Java Web Start (JWS).
    Here is a test of a direct launch of the HelpButton JavaHelp applet.
    <http://www.physci.org/jh/test.html#launch>
    It would only take minor changes to the code to make the button entirely redundant, and have the code automatically launch the HelpViewer, once the user clicks the link to the JNLP launch file.
    That 'JavaHelp/JWS' page is my test page for launching JavaHelp in a variety of forms.

  • Calling javascript method from java

    Hi this is sri,
    I have one doubt on Java Applets "how to call the javascript method from java Applet".Can u give me the complete sample code for one program(both java applet file and html file also)because i can easily understand the programming flow.
    Thanks ,
    Srilekha.

    It's an extremely important skill to learn how to search the web. Not only will it increase your research and development talents, it will also save you from asking questions that have already been answered numerous times before. By doing a little research before you ask a question, you'll show that you're willing to work and learn without needing to have your hand held the entire time; a quality that is seemingly rare but much appreciated by the volunteers who are willing to help you.
    If you've done the research, found nothing useful, and decide to post your question, it's a great idea to tell us that you've already searched (and what methodologies you used to do your research). That way, we don't refer you back to something you've already seen.
    To get you started, here's a link...
    http://www.google.com/search?q=call+java+from+javascript

  • How to provide javascript implementation in java

    hi all
    I am workiing in a project where i need to automate the javascript processing from java.
    suppose if a page has load event and it has some function to do , from java i need to do the functionality for javascript and generate a new DOM for the webpage.
    In this i need to provide the functionality for
    document.write()
    how to provide the write functionality from java.
    suppose
    <form>
    docuement.write("some thing do tadd in form may be some html code");
    </form>
    so how can i add this content in write to a element called FORM and if a page has many forms how to add it to specific one.
    waiting for some hints
    thanking you

    try this link
    http://java.sun.com/products/plugin/1.3/docs/jsobject.html
    import netscape.javascript.*;
    import java.applet.*;
    import java.awt.*;
    class MyApplet extends Applet {
         public void init() {
             JSObject win = JSObject.getWindow(this);
             JSObject doc = (JSObject) win.getMember("document");
             JSObject loc = (JSObject) doc.getMember("location");
             String s = (String) loc.getMember("href");  // document.location.href
             win.call("f", null);                      // Call f() in HTML page

  • Run Priviliged Code in a Java Applet

    I am calling a Java applet from Javascript. The Java code needs to run in privileged mode.  Eventually it is going to display a file chooser which will display files from the local hard disk, but for now it just returns a simple dummy value.  The problem I am having is that the call from JavaScript to Java returns PrivilegedActionException. The applet is in a signed Jar file.  I'm running 8u25.
    Here's the Java class:
        // Java code
        public class OHLib extends Applet {
            public String getFile() {
                String result;
                try {
                    result = (String) AccessController.doPrivileged(new PrivilegedAction() {
                        public String run() {
                            // JFileChooser code will go here
                            return "xxx";
                } catch (Exception e) {
                    e.printStackTrace();
                return result;
    Can anybody tell me what's wrong with this code?  I would also be interested to know why the above try/catch block is not catching the exception.  The only place I see the exception is in the browser F12 developer tools.
    Here's the JavaScript code:
        function BrowseForFile() {
            var x;
            try {
                 // this code generates PrivilegedActionException
                 x = ohApplet.getFile();
            } catch (e) {
                 console.log(e);
    The applet is deployed on my web page as follows:
    <script src="/plugins/deployJava.js"></script>
    <script>
         var attributes = {
             id:'ohApplet',
             code:'OHLib',
             codebase: 'java',
             archive: 'OHLib.jar',
             width:1,
             height:1,
         var parameters = {
          jnlp_href: 'OHLib.jnlp',
          classloader_cache: 'false',
         deployJava.runApplet(attributes, parameters, '1.8');
    <script>
    The applet is in a signed jar file, with the following manifest:
    Application-Name: <appname>
    Permissions: all-permissions
    Codebase: <domain>.dev <domain>.com
    Caller-Allowable-Codebase: <domain>.dev <domain>.com
    Application-Library-Allowable-Codebase: <domain>.dev <domain>.com
    The JNLP file is as follows:
        <?xml version="1.0" encoding="UTF-8"?>
        <jnlp spec="1.0+" codebase="" href="">
            <information>
                <title>title</title>
                <vendor>vendor</vendor>
            </information>
            <security>
                <all-permissions />
            </security>
            <resources>
                <j2se version="1.8+" href="http://java.sun.com/products/autodl/j2se" />
                <jar href="OHLib.jar" main="true" />
            </resources>
            <applet-desc
                 main-class="OHLib"
                 name="OHLib"
                 width="1"
                 height="1">
             </applet-desc>
        </jnlp>       

    The problem was that I was not including the anonymous inner class (OHLib$1.class) in the jar file. My original jar command looked like this:
    jar cfmv OHLib.jar "../../jar_manifest.txt" OHLib.class
    Changing it to below fixed the problem:
    jar cfmv OHLib.jar "../../jar_manifest.txt" OHLib.class OHLib$1.class
    Credits go to this page  for the solution.

  • Type Mismatch error while calling a Java Function from Visual Basic 6.0...

    Hi,
    I'm having a problem in calling the Java Applet's Function from Visual Basic. First, I'm getting the handle of the Java Applet and components of it using "Document.Applets(n)" which is a HTML function. I'm calling this function from Visual Basic. My code is something like this...
    ' // Web1 is IE Browser in my Form.
    Dim Ap,Comp
    Dim Bol as Boolean
    Bol = true
    Ap = Web1.Document.Applets(0).getWindow() ' \\ Gets the Parent Window.
    Ap.setTitle("My Java Applet") ' \\ Sets the Title of the window.
    msgbox Ap.getVisibility() ' \\ This will return a Java boolean ( true or false )
    Ap.setVisibility(Bol) ' \\ Function Syntax is : void setVisibility(boolean b)
    Here in my code , i'm able to call any function that which accepts Integer or String but not boolean. So, i m facing problem with Ap.setVisibility() function. It gives me a "Type mismatch error" while executing it. Can you please tell me a way to do this from Visual Basic !
    I'm using Visual Basic 6.0, Windows 2000 , J2SDK 1.4.2_05.
    Please help me Friends.
    Thanks and Regards,
    Srinivas Annam.

    Hi
    I am not sure about this solution. try this
    Declare a variable as variant and store the boolean value in that variable and then use in ur method.
    Post ur reply in this forum.
    bye for now
    sat

  • Java-applet counter

    Hi there,
    I've created a java-applet that can be widely used so I encourage people to include the java applet into other sites by means of the <applet code="blah.class" codebase="http://www.blah.com/"></applet>I'm wondering however if it would be possible to keep statistics of how many times the applet is loaded. I created a free Nedstat subscription and here's some html code:
    <!-- Begin Nedstat Basic code -->
    <script language="JavaScript" type="text/javascript" src="http://m1.nedstatbasic.net/basic.js">
    </script>
    <script language="JavaScript" type="text/javascript" >
    <!--
      nedstatbasic("FPZ43f3d3d287Df", 0);
    // -->
    </script>
    <noscript>
    <a target="_blank" href="http://www.nedstatbasic.net/stats?FPZ43f3d3d287Df"><img
    src="http://m1.nedstatbasic.net/n?id=FPZ43f3d3d287Df"
    border="0" width="18" height="18"
    alt="Nedstat Basic - Free web site statistics
    Personal homepage website counter"></a><br>
    <a target="_blank" href="http://www.nedstatbasic.net/">Free counter</a>
    </noscript>
    <!-- End Nedstat Basic code -->I'm guessing that the javascript here "does the counting". Is there any possibility to include this javascript in the java applet, and how could it be done?
    Thank you very much,
    happy holidays
    W.

    cool i found another solution :-)
    cheers
    W.

  • Embedded Java Applet NullPointerException in JSPX pages

    We have a ADF web application programmed in JDeveloper 11g (11.1.2.4.0), which was migrated over from a 10g (10.1.3.5.0) project
    Within the application, occasionally, we need to call a Java Applet which is placed in a public_html/applet folder. The jars show up in the Web-Content tab of the ViewController in the Application Navigator, just like it did in 10g.
    The applet tag looks like this:
    <applet height="100" width="100" code="applet.SetupApplet" archive="applet/SSetupApplet.jar">
                <param name="debug" value="true"/>   
    </applet>
    I've also tried calling the applet with the Java deploy applet script
    <trh:script source="http://java.com/js/deployJava.js"></trh:script>
        <trh:script>
            var attributes = {code:'applet.SetupApplet',
            archive:'applet/SSetupApplet.jar'};
            var parameters = {} ;
            var version = '1.6' ;
            deployJava.runApplet(attributes, parameters, version);
       </trh:script>
    When I navigate to the login.jspx page that has this tag, it pops the Java Console open, but doesn't actually run the applet (or show the prompts to allow using the Applet). Instead, the applet is shown with an error and the error says "NullPointerException". I've double-checked the path and it's correct (with incorrect paths, I get a ClassNotFoundException). In the application server logs, I see the following error:
    <Warning> <Socket> <BEA-000449> <Closing socket as no data read from it on IPADDRESS during the configured idle timeout of 5 secs>
    I created a normal .jsp file that's outside the ADF Faces Context in the applet folder. Navigating to it with the same applet tags does have the Java applet run without the socket error. The same code in 10g works fine.
    Is there anything I'm missing?
    Thanks.

    Hi,
    this is how I did it in 11g R1: http://www.oracle.com/technetwork/developer-tools/adf/learnmore/71-adf-to-applet-communication-307672.pdf
    Frank

  • Java Applet call javascript problem

    Hi I have a web page as follow and embedded a applet. The applet call the java script, and instead of showing an alarm, the browser show the javascript code. Is that strange ? Any suggestion for this problem.
    HTML:
    ================================================================
    <HTML>
         <HEAD>
         function ShowEmbd()
              alert("Test Applet call Javascript");
         </SCRIPT>
         </HEAD>
         <BODY>
         <FORM NAME="AppletEmbdStart">
              <OBJECT classid="clsid:48B2DD7B-6B52-4DB0-97C9-ECB940113B47" id="CIVON_DEmbdObj" width="0" height="0"></OBJECT>
              <APPLET code="MyApplet.class" width="0" height="0"></APPLET>
         </FORM>
         </BODY>
    </HTML>MyApplet.java
    =========================================================================
    import netscape.javascript.*;
    public class MyApplet extends javax.swing.JApplet
         private JSObject m_win = null;
         private JSObject m_doc = null;
         public void init()
              getJSWin().call("ShowEmbd", null);
         private getJSDoc()
              if(m_doc == bull)
                   m_doc = (JSObject) getJSWin().getMember("document");
              return m_doc;
         private JSObject getJSWin()
              if (m_win == null)
                   m_win = netscape.javascript.JSObject.getWindow(this);
              return m_win;
    }The page was load and it should call the applet MyApplet. The MyApplet should do the init() method and call the Javascript "ShowEmbd()", BUT, instead of show alert from ShowEmbd(), the browser show the code of ShowEmbd() itself ...... It did not run the javascript and shows the alert ??
    The browser shows a message from status bar "The applet not initial" ???? why ???
    Can anyone help ?!

    On first look:
    I am not sure about the Object Tag, but the Applet Tag requires the MAYSCRIPT attribute before Java can call Javascript.

Maybe you are looking for

  • I use version 4.01. How do I backup bookmarks and then import them into my laptop?

    I want to export my bookmarks from my desktop and then import them into Firefox on my laptop. The Help file tells me to open "Organize Bookmarks" 'but I can't find it! Help!

  • Adobe Setup has stopped working

    "Adobe Setup has stopped working" Everytime I try to run Adobe installer or uninstaller the setup crashes! video example: http://www.screencast-o-matic.com/watch/cjXUiIntb

  • Podcasts synching in reverse order

    I use an iPod Touch w/iTunes on the Mac and despite how I sort my podcasts inside iTunes, they sync up from newest to oldest on my Touch. I want them to sync up oldest to newest so I can listen in that order. Is there any way to do this?? Thanks in a

  • Selecting data in order inserted

    Hi, What's the best way to guarantee selecting records from a table in the order they were inserted? Should there be a sequence on the table or can I use rowid? Thanks Sean

  • Migrating Exchange 2013 public mailboxes to a new server

    We have a client that is leaving their current Hosting company and wants to move to our hosting facility. We have recreated their DC,an Exchange Hub, and Exchange Store. We have exported and imported all of their recipient mailboxes and flipped the s