?
Solved

creating applet from non-applet code

Posted on 1998-11-04
6
Medium Priority
?
192 Views
Last Modified: 2013-11-23
I have code that queries a database and then lists the results on the screen.

Currently, it is working in the DOS window only, and I need to change it to an applet. (ideally with a button that sends the query)

I am compiling with 1.1.6, on an NT system. I will be running the applet from Internet Explorer.

Obviously, I am very new to Java, so please be kind.

Thanks!
Accidentprone
0
Comment
Question by:accidentprone
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 6

Expert Comment

by:gadio
ID: 1226943
accidentprone, what you should do is the folowing:

1. Create a new class the extends java.awt.Applet
2. Override the start() function, and instantiate your main class (the one with the main method)
3. Run the main metod with any parameters.

This should give you the application running as an applet.
From here you have to start working on the user interface.
Also note that the applet can only form communication to the server from which it comes from, so the database shoud be on the server machine (or some sort of proxy server for the database).

Tell me if that made sense to you so far.


0
 
LVL 6

Expert Comment

by:gadio
ID: 1226944
I forgot to mension that you will have to create a small html file to run that applet.
0
 

Author Comment

by:accidentprone
ID: 1226945
That looks like it should make sense, but when it comes to implementing it, well, it makes very clear that I haven't learned anything about java yet.

My db is on the hard drive, and so is the java code, which I will only be running locally. That part seems to be fine when I run the app in the DOS window.

Here's the beginning of my code: could you indicate more of what you were describing? THANKS!!!!
_______________________________________

import java.net.URL;
import java.sql.*;
import java.util.*;

public class test {
      public static void main (String args[]) {
            int y = 0;
            simpleselect q = new simpleselect ("db1", "SELECT * FROM Exercise");
            System.out.println("Finished");
      }
}

<code continues to describe simpleselect...>
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:accidentprone
ID: 1226946
(sheepish grin) I don't know that much about html, either...Here's what I've got so far, (using MS Front Page Express) but I don't know what to do with the button, and the browswer can't find the applet.  

(you see why I gave this question so many points: it probably isn't that difficult, but it does require patience!)
0
 

Author Comment

by:accidentprone
ID: 1226947
Here's that attempted html code I mentioned:
_____________________________________
<html>

<head>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Microsoft FrontPage Express 2.0">
<title>Hw4 Applet page</title>
</head>

<body bgcolor="#FFFFFF">

<p>Applet page</p>

<p>Select * from Exercise in db1</p>

<form method="POST">
    <p><input type="button" name="B1" value="Query"></p>
    <p><applet code="test.class" align="baseline" width="128"
    height="128"></applet></p>
</form>
</body>
</html>
0
 

Accepted Solution

by:
ahannink earned 600 total points
ID: 1226948
hello accidentprone.
first make your test class an applet. see the code below
seccond I sugest you put a button in your applet, I wrote it down for you. But remember it's a small example.

import java.net.URL;
import java.sql.*;
import java.util.*;
import java.applet.*;
import java.awt.*;
import java.net.*; // i'm not sure of this one, probably not necessary
import java.io.*;  // i'm not sure of this one, probably not necessary

       public class test extends applet
{
       public static void main (String args[])
       {
       }
public void init()
{
// do your initialazations here
// create a button
  Button b = new Button("Start Query") ;
// add the button to visual applet
  add(b);

}
public void start()
{// do your start calls here
// nothing here because of we're waiting for the button to push.
}

public boolean handleEvent(Event event)
{
    if( (event.id = Event.ACTION_EVENT)&&
        (event.arg.equals("Start Query")) )
    {
       // call the query function
        startQuery();
        return true
    }
    return false;
}
public void startQuery()
{
       int y = 0;
       simpleselect q = new simpleselect ("db1", "SELECT * FROM Exercise");
       System.out.println("Finished");

}
}

       <code continues to describe simpleselect...>


I think you try this. Leave the html unchanged. I think that one looks good for now.

good luck
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Suggested Courses
Course of the Month8 days, 2 hours left to enroll

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question