Html file to run an Applet using swings in 1.4.1 or 1.3.1

Can anyone send me an html document to launch the applet in a browser. I have very basic html, but I need one that uses the appropriate plug-in and that has parameters such as height, width, etc. My applet uses tabbed panes, dialog boxes and comboboxes. It works well with appletviewer, but does not work in IE or Netscape.
Thank you for your help
here is what I am using which does does show anything but a grey screen
<HTML>
<HEAD>
<TITLE>
CIS 602 Semister Project
</TITLE>
</HEAD>
<BODY>
<BR>
<H3>
<CENTER>
Swing
</CENTER>
</H3>
<H3>
<BR><BR>
<P><H3>
<CENTER>
<BR><BR>
<P><h2>
Structured Problem Solving Strategy
</h2>
<blockquote>
<!--"CONVERTED_APPLET"-->
<!-- CONVERTER VERSION 1.1 -->
<SCRIPT LANGUAGE="JavaScript"><!--
var info = navigator.userAgent; var ns = false;
var ie = (info.indexOf("MSIE") > 0 && info.indexOf("Win") > 0 && info.indexOf("Windows 3.1") < 0);
//--></SCRIPT>
<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!--
var ns = (navigator.appName.indexOf("Netscape") >= 0 && ((info.indexOf("Win") > 0 && info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0)));
//--></SCRIPT></COMMENT>
<SCRIPT LANGUAGE="JavaScript"><!--
if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = "570" HEIGHT = "500" codebase="http://java.sun.com/products/plugin/1.1.2/jinstall-112-win32.cab#Version=1,1,2,0"><NOEMBED><XMP>');
else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.4.2" java_CODE = "semiclient.class" WIDTH = "570" HEIGHT = "500" pluginspage="http://java.sun.com/products/plugin/1.1.2/plugin-install.html"><NOEMBED><XMP>');
//--></SCRIPT>
<APPLET CODE = "semiclient.class" WIDTH = "570" HEIGHT = "500" ></XMP>
<PARAM NAME = CODE VALUE = "semiclient.class" >
<PARAM NAME="type" VALUE="application/x-java-applet;version=1.4.2">
</APPLET>
</NOEMBED></EMBED></OBJECT>
<!--
<APPLET CODE = "semiclient.class" WIDTH = "570" HEIGHT = "500" >
</APPLET>
-->
<!--"END_CONVERTED_APPLET"-->
</Center>
<BLOCKQUOTE><PRE>
</PRE></BLOCKQUOTE>
</H3>
<BLOCKQUOTE><PRE>
</PRE></BLOCKQUOTE>
</H3>
</BODY></HTML>

Try this:
<HTML>
<HEAD>
<TITLE>CIS 602 Semister Project</TITLE>
</HEAD>
<BODY>
<CENTER><H3>Swing</H3></CENTER><CENTER><H2>Structured Problem Solving Strategy</H2></CENTER>
        <OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
            width="750"
            height="575"
            align="baseline"
            codebase="http://java.sun.com/products/plugin/autodl/jinstall-1_4_0-win.cab">
            <PARAM NAME="code"       VALUE="full.qualified.ClassName">
            <PARAM NAME="codebase"   VALUE="path/to/your/class/files/or/archive/">
            <PARAM NAME="archive"    VALUE="nameOfJarWhichContainsClassFiles.jar">
            <PARAM NAME="type"       VALUE="application/x-java-applet;version=1.4">
            <PARAM NAME="scriptable" VALUE="false">
            <COMMENT>
                <EMBED type="application/x-java-applet;version=1.4"
                    width="750"
                    height="575"
                    align="baseline"
                    code="full.qualified.ClassName"
                    codebase="path/to/your/class/files/or/archive/"
                    archive="nameOfJarWhichContainsClassFiles.jar"
                    pluginspage="http://java.sun.com/products/plugin/1.4/plugin-install.html">
                    <NOEMBED>
                        No Java 2 SDK, Standard Edition v 1.4 support for APPLET!!
                    </noembed>
                </embed>
            </COMMENT>
        </OBJECT>
</BODY>
</HTML>

Similar Messages

  • How to run an Applet using the JDK1.3.1 platform?

    I'm a beginner of Java Applet.
    I've type in the sample program provided in the text book, and compiled it using the jdk1.3.1 platform.
    Usually we run a java program using java [filename], right?
    How about running an applet file?
    What is appletviewer function?
    Thanks!

    I try to put it in a HTML page but it required me to download a Java Virtual Machine.
    I've been searching sources for that but stil cannot get.
    This is always what I get:
    [We're sorry, you cannot view this page because it requires the Microsoft Java Virtual Machine (MSJVM). Your machine does not have the MSJVM installed. For more information please visit www.microsoft.com/java.]
    I visit java.sun.com. On the right side of the page listed with the HOT DOWNLOADS.
    I click on the Java VM but still cannot get anything...
    Can u help me on that?
    I've been trying for 2 days already.
    Thanks!

  • Chat Applet using RMI .... trouble running the Applet using the IE browser.

    Hi,
    I'm trying to run a chat application using RMI technology. Actually, this wasn't created from the scratch. I got this one from from the cd that comes with the book I bought and I did some refinements on it to suit what I wanted to:
    These are the components of the chat application:
    1. RApplet.html - invokes the applet
    html>
    <head>
    <title>Sample Applet Using Dialog Box (1.0.2) - example 1</title>
    </head>
    <body>
    <h1>The Sample Applet</h1>
    <applet code="RApplet.class" width=460 height=160>
    </applet>
    </body>
    </html>
    2. RApplet.java - Chat session client applet.
    import java.rmi.*;
    import java.applet.*;
    import java.awt.event.*;
    import java.awt.*;
    import java.io.*;
    import java.rmi.server.*;
    //import ajp.rmi.*;
    public class RApplet extends Applet implements ActionListener {
    // The buttons
    Button sendButton;
    Button quitButton;
    Button startButton;
    Button clearButton;
    // The Text fields
    TextField nameField;
    TextArea typeArea;
    // The dialog for entering your name
    Dialog nameDialog;
    // The name the server knows us as
    String privateName;
    // The name we want to be known as in the chat session
    String publicName;
    // The remote chats erver
    ChatServer chatServer;
    // The ChatCallback
    ChatCallbackImplementation cCallback;
    // The main Chat window and its panels
    Frame mainFrame;
    Panel center;
    Panel south;
    public void init() {
    // Create class that implements ChatCallback.
    cCallback = new ChatCallbackImplementation();
         // Create the main Chat frame.
         mainFrame = new Frame("Chat Server on : " +
                        getCodeBase().getHost());
         mainFrame.setSize(new Dimension(600, 600));
         cCallback.displayArea = new TextArea();
         cCallback.displayArea.setEditable(false);
         typeArea = new TextArea();
         sendButton = new Button("Send");
         quitButton = new Button("Quit");
         clearButton = new Button("Clear");
         // Add the applet as a listener to the button events.
         clearButton.addActionListener(this);
         sendButton.addActionListener(this);
         quitButton.addActionListener(this);
         center = new Panel();
         center.setLayout(new GridLayout(2, 1));
         center.add(cCallback.displayArea);
         center.add(typeArea);
         south = new Panel();
         south.setLayout(new GridLayout(1, 3));
         south.add(sendButton);
         south.add(quitButton);
         south.add(clearButton);
         mainFrame.add("Center", center);
         mainFrame.add("South", south);
         center.setEnabled(false);
         south.setEnabled(false);
         mainFrame.show();
         // Create the login dialog.
         nameDialog = new Dialog(mainFrame, "Enter Name to Logon: ");
         startButton = new Button("Logon");
         startButton.addActionListener(this);
         nameField = new TextField();
         nameDialog.add("Center", nameField);
         nameDialog.add("South", startButton);
         try {
         // Export ourselves as a ChatCallback to the server.
         UnicastRemoteObject.exportObject(cCallback);
         // Get the remote handle to the server.
         chatServer = (ChatServer)Naming.lookup("//" + "WW7203052W2K" +
                                  "/ChatServer");
         catch(Exception e) {
         e.printStackTrace();
         nameDialog.setSize(new Dimension(200, 200));
         nameDialog.show();
    * Handle the button events.
    public void actionPerformed(ActionEvent e) {
         if (e.getSource().equals(startButton)) {
         try {
              nameDialog.setVisible(false);;
              publicName = nameField.getText();
              privateName = chatServer.register(cCallback, publicName);
              center.setEnabled(true);
              south.setEnabled(true);
              cCallback.displayArea.setText("Connected to chat server as: " +
                             publicName);
              chatServer.sendMessage(privateName, publicName +
                             " just connected to server");
         catch(Exception ex) {
              ex.printStackTrace();
         else if (e.getSource().equals(quitButton)) {
         try {
              cCallback.displayArea.setText("");
              typeArea.setText("");
              center.setEnabled(false);
              south.setEnabled(false);
              chatServer.unregister(privateName);
              nameDialog.show();
         catch(Exception ex) {
              ex.printStackTrace();
         else if (e.getSource().equals(sendButton)) {
         try{
              chatServer.sendMessage(privateName, typeArea.getText());
              typeArea.setText("");
         catch(Exception ex) {
              ex.printStackTrace();
         else if (e.getSource().equals(clearButton)) {
         cCallback.displayArea.setText("");
    public void destroy() {
         try {
         super.destroy();
         mainFrame.setVisible(false);;
         mainFrame.dispose();
         chatServer.unregister(privateName);
         catch(Exception e) {
         e.printStackTrace();
    3. Chatcallback.java - interface used by clients to connect to the server.
    import java.rmi.*;
    public interface ChatCallback extends Remote {
    public void addMessage(String publicName,
                   String message) throws RemoteException;
    4. ChatcallbackImplementation.java - implements Chatcallback interface.
    import java.rmi.*;
    import java.io.*;
    import java.awt.event.*;
    import java.awt.*;
    public class ChatCallbackImplementation implements ChatCallback {
    // The buttons
    // The Text fields
    TextArea displayArea;
    public void addMessage(String publicName,
                   String message) throws RemoteException {
    displayArea.append("\n" + "[" + publicName + "]: " + message);
    5. Chatserver.java - interface for the chat server.
    import java.rmi.*;
    import java.io.*;
    public interface ChatServer extends Remote {
    public String register(ChatCallback object,
                   String publicName) throws RemoteException;
    * Remove the client associated with the specified registration string.
    * @param registeredString the string returned to the client upon registration.
    public void unregister(String registeredString) throws RemoteException;
    * The client is sending new data to the server.
    * @param assignedName the string returned to the client upon registration.
    * @param data the chat data.
    public void sendMessage(String registeredString, String message) throws RemoteException;
    6. ChatServerImplementation.java - implements Chatserver interface.
    import java.rmi.*;
    import java.util.*;
    import java.rmi.server.*;
    import java.io.*;
    * A class that bundles the ChatCallback reference with a public name used
    * by the client.
    class ChatClient {
    private ChatCallback callback;
    private String publicName;
    ChatClient(ChatCallback cbk, String name) {
         callback = cbk;
         publicName = name;
    // returns the name.
    String getName() {
         return publicName;
    // returns a reference to the callback object.
    ChatCallback getCallback() {
         return callback;
    public class ChatServerImplementation extends UnicastRemoteObject
    implements ChatServer {
    // The table of clients connected to the server.
    Hashtable clients;
    // Tne number of current connections to the server.
    private int currentConnections;
    // The maximum number of connections to the server.
    private int maxConnections;
    // The output stream to write messages to.
    PrintWriter writer;
    * Create a ChatServer.
    * @param maxConnections the total number if connections allowed.
    public ChatServerImplementation(int maxConnections) throws RemoteException {
         clients = new Hashtable(maxConnections);
         this.maxConnections = maxConnections;
    * Increment the counter keeping track of the number of connections.
    synchronized boolean incrementConnections() {
         boolean ret = false;
         if (currentConnections < maxConnections) {
         currentConnections++;
         ret = true;
         return ret;
    * Decrement the counter keeping track of the number of connections.
    synchronized void decrementConnections() {
         if (currentConnections > 0) {
         currentConnections--;
    * Register with the ChatServer, with a String that publicly identifies
    * the chat client. A String that acts as a "magic cookie" is returned
    * and is sent by the client on future remote method calls as a way of
    * authenticating the client request.
    * @param object The ChatCallback object to be used for updates.
    * @param publicName The String the object would like to be known as.
    * @return The actual String assigned to the object for removing, etc. or
    * null if the client could not register.
    public synchronized String register(ChatCallback object, String publicString) throws RemoteException {
         String assignedName = null;
         if (incrementConnections()) {
         ChatClient client = new ChatClient(object, publicString);
         assignedName = "" + client.hashCode();
         clients.put(assignedName, client);
         out("Added callback for: " + client.getName());
         return assignedName;
    * Remove the client associated with the specified registration string.
    * @param registeredString the string returned to the client upon registration.
    public synchronized void unregister(String registeredString) throws RemoteException {
         ChatCallback cbk;
         ChatClient sender;
         if (clients.containsKey(registeredString)) {
         ChatClient c = (ChatClient)clients.remove(registeredString);
         decrementConnections();
         out("Removed callback for: " + c.getName());
         for (Enumeration e = clients.elements(); e.hasMoreElements(); ) {
              cbk = ((ChatClient)e.nextElement()).getCallback();
              cbk.addMessage("ChatServer",
                        c.getName() + " has left the building...");
         else {
         out("Illegal attempt at removing callback (" + registeredString + ")");
    * Sets the logging stream.
    * @param out the stream to log messages to.
    protected void setLogStream(Writer out) throws RemoteException {
         writer = new PrintWriter(out);
    * The client is sending new message to the server.
    * @param assignedName the string returned to the client upon registration.
    * @param data the chat data.
    public synchronized void sendMessage(String registeredString, String message) throws RemoteException {
         ChatCallback cbk;
         ChatClient sender;
         try {
         out("Recieved from " + registeredString);
         out("Message: " + message);
         if (clients.containsKey(registeredString)) {
              sender = (ChatClient)clients.get(registeredString);
              for (Enumeration e = clients.elements(); e.hasMoreElements(); ) {
                   cbk = ((ChatClient)e.nextElement()).getCallback();
                   cbk.addMessage(sender.getName(), message);
         else {
              out("Client " + registeredString+ " not registered");
         catch(Exception ex){
         out("Exception thrown in newData: " + ex);
         ex.printStackTrace(writer);
         writer.flush();
    * Write s string to the current logging stream.
    * @param message the string to log.
    protected void out(String message){
         if(writer != null){
         writer.println(message);
         writer.flush();
    * Start up the Chat server.
    public static void main(String args[]) throws Exception {
         try {
         // Create the security manager
         System.setSecurityManager(new RMISecurityManager());
         // Instantiate a server
         ChatServerImplementation c = new ChatServerImplementation(10);
         // Set the output stream of the server to System.out
         c.setLogStream(new OutputStreamWriter(System.out));
         // Bind the server's name in the registry
         Naming.rebind("//" + args[0] + "/ChatServer", c);
         c.out("Bound in registry.");
         catch (Exception e) {
         System.out.println("ChatServerImplementation error:" +
                        e.getMessage());
         e.printStackTrace();
    Using my own machine (connected to a network), I tried to test this one out by setting mine as the server and also the client. I did the following:
    1. Compile the source code.
    2. Use rmic to generate the skeletons and/or stubs from the ChatCallbackImplementation and ChatServerImplementation.
    3. Start the rmiregistry with no CLASSPATH
    4. Start the server successfully.
    5. Start the applet using the AppletViewer command.
    It worked fined.
    The problem is when I ran the applet using the browser, IE explorer, the dialog boxes, frame and buttons did appear. I was able to do the part of logging on. But after that, the applet seemed to have hang. No message appeared that says I'm connected (which appeared using the appletviewer). I clicked the send button. No response.
    I double-checked my classpath. I did have my classpath set correctly. I'm still trying to figure out the problem. Up to now, I don't have any clue what it is.
    I will appreciate much if someone can help me figure what's could have possibly been wrong ....
    Thanks a lot ...

    Hi Domingo,
    I had a similar problem running applet/rmi with IE.
    Looking in IE..view..JavaConsole error messages my applet was unable to find java.rmi.* classes.
    I checked over java classes in msJVM, they're not present.
    ( WinZip C:\WINDOWS\JAVA\Packages\9rl3f9ft.zip and others from msVM installed )
    ( do not contain the java.rmi.* packages )
    I have downloaded and installed the latest msJVM for IE5. ( I think its included in later versions)
    @http://www.objectweb.org/rmijdbc/RJfaq.html I found ref to rmi.zip download to provide
    these classes. I couldn't get the classes from the site but I managed to find a ref to IBM
    site @http://alphaworks.ibm.com/aw.nsf/download/rmi which had similar download.
    The download however didn't solve my problems. I was unable to install rmi.zip with
    RmiPatch.exe install.
    I solved this by extracting the class files from rmi.zip and installing them at C:\WINDOWS\JAVA\trustlib ( msJVM installation trusted classes lib defined in
    registry HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Java VM\TrustedLibsDirectory )
    This solved the problem. My rmi/applet worked.
    Hope this helps you.
    Chris
    ([email protected])

  • I can not open files in my jZIP folders, they are either .PHP or html files what program do I use or how do I open them... Doug

    Hi I have download files using jZIP and then I can't find a program that will open them... they are .PHP and .html file extensions... what do I do.. Doug

    Hello ,
    Dear friend ''''' .PHP ''''' files are a server side pages or scripts it needs a server to run on it or to be executed , so you will have to install something like apache server you will find a great application that enables your system to work as a localhost server
    >> http://download.cnet.com/XAMPP/3000-10248_4-10703782.html
    but HTML file can easily opened by any browser like Firefox or IE
    also if you need to edit the content of their code you will have to obtain a code editor like Notebad++
    >>http://download.cnet.com/Notepad/3000-2352_4-10327521.html
    thanks for your time i wish i could helped you.

  • Memory leak with 1.6.0_07 in applet using Swing

    Java Plug-in 1.6.0_07
    Using JRE version 1.6.0_07 Java HotSpot(TM) Client VM
    Windows XP - SP2
    I have a commercial application that has developed a memory leak with the introduction of the latest plugin. The applets chew up memory and eventually freeze. They did not before. Using jvisualm I see a build up of native arrays, primarily int[][] and char[]. I'm still investigating. Anyone have a similar experience?
    The Applet uses a swing interface, uses buffered images and swing timers, and regularly performs http connections to the server which result in actions via the SwingUtil.invokeLater() method.

    I am Using Internet Explorer Browser Version 6.0.Huge security hole.
    Its not throwing Error / Exception Wrap a try/catch at the highest level possible.
    Catch 'Throwable'. And log/display it somewhere.

  • How to read an html file and replace a text using text_io

    hi,
    i want ro read an html file using text_io and replace a particular text with a new text
    eg: i want to replace a text called "data.js" and with "maps.js"
    how do i do this?

    You have to write your own code to do that. TEXT_IO is just a low level text file interface.
    You need to read in all the text, save it in some internal format (array of varchar2's maybe or in the DB) and then perform a search on the text you have read in, find out where the instances of "data.js" are located and substitute them with "maps.js" After that you need to write to a new file and delete the old one. There is no way to search and replace inside the existing file (what's sometimes referred to as 'in-place' substitution).
    See the help section called About the TEXT_IO package for an overview of how it works and some code examples.

  • Progress bar on Applet using swing

    Not sure if this is Swing related or applet related, so I'll post it here... :-)
    Long work should be done on a Worker thread an not inside the Swing Dispacher thread .
    So normally I create a Runnable object that calls something like doWork(), and pass the runnable object as a parameter to the Sing utilities invokelater() function.
    My question is inside the worker thread how to update the GUI, in this case the progress bar?
    Can I just call from inside doWork() with no problems the progressbar.setValue(X)?
    Do I need to create another thread and use it too update the UI?
    Is something like this valid ?
    public void doWork() {
    // work work work
    progressbar.setValue(5);
    //more work
    progressbar.setValue(15);
    // and so on
    Thanks for the help!

    Not sure if this is Swing related or applet related,
    so I'll post it here... :-)It's definitely Swing related.
    Long work should be done on a Worker thread an not
    inside the Swing Dispacher thread . This is true.
    So normally I create a Runnable object that calls
    something like doWork(), and pass the runnable object
    as a parameter to the Sing utilities invokelater()
    function.This does not start a worker thread but rather schedules your Runnable object to be run on the EDT.
    My question is inside the worker thread how to update
    the GUI, in this case the progress bar?SwingUtilities or EventQueue have invokeLater and invokeAndWait specifically for this purpose.
    Can I just call from inside doWork() with no problems
    the progressbar.setValue(X)?
    Do I need to create another thread and use it too
    update the UI?No. Here's where you could use invokeLater.
    Is something like this valid ?
    public void doWork() {
    // work work work
    rogressbar.setValue(5);
    //more work
    progressbar.setValue(15);
    // and so onNo.
    >
    Thanks for the help!Like pete has pointed out, this seems to be a job for SwingWorker.

  • Calculator applet using swing

    please Help!!!!!
    This thing keeps giving a Null Pointer Exception whenever you click a button it compiles fine and runs ok until a button is clicked.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class MyCalculator extends JApplet implements ActionListener {
    private char op = 0;
    private float num1 = 0, num2 = 0, value = 0 ;
    private boolean clearNext = false;
    private JTextField display, textField2;
    private JButton buttonEq, buttonPlus, buttonMinus, buttonMult,buttonCos;
    private JButton buttonDiv,buttonPlusMinus,buttonDec,buttonC,buttonSin;
    private JButton buttonTan;
    private JButton button = new JButton();
    private boolean start = true;
    // create GUI components
    public void init() {
    Container con = getContentPane();
    con.setLayout( new BorderLayout());
    con.setBackground(Color.darkGray);
    //add display display
    JTextField display = new JTextField( "0", 15 );
    display.setBackground(Color.black);
    display.setForeground(Color.red);
    display.setEditable(false);
    JTextField textField2 = new JTextField( " Design and Implementation By Erwin Zeitner" );
    textField2.setBackground(Color.black);
    textField2.setForeground(Color.red);
    textField2.setEditable(false);
    //create numbered buttons
    JButton button0 = new JButton("0" );
    button0.setBackground(Color.blue);
    JButton button1 = new JButton( "1" );
    button1.setBackground(Color.blue);
    JButton button2 = new JButton( "2" );
    button2.setBackground(Color.blue);
    JButton button3 = new JButton( "3" );
    button3.setBackground(Color.blue);
    JButton button4 = new JButton( "4" );
    button4.setBackground(Color.blue);
    JButton button5 = new JButton( "5" );
    button5.setBackground(Color.blue);
    JButton button6 = new JButton( "6" );
    button6.setBackground(Color.blue);
    JButton button7 = new JButton( "7" );
    button7.setBackground(Color.blue);
    JButton button8 = new JButton( "8" );
    button8.setBackground(Color.blue);
    JButton button9 = new JButton( "9" );
    button9.setBackground(Color.blue);
    //create function buttons
    JButton buttonC = new JButton( "clear" );
    buttonC.setBackground(Color.green);
    JButton buttonPlus = new JButton( "+" );
    buttonPlus.setBackground(Color.green);
    JButton buttonMinus = new JButton( "-" );
    buttonMinus.setBackground(Color.green);
    JButton buttonMult = new JButton( "*" );
    buttonMult.setBackground(Color.green);
    JButton buttonDiv = new JButton( "/" );
    buttonDiv.setBackground(Color.green);
    JButton buttonSin = new JButton( "Sin" );
    buttonSin.setBackground(Color.green);
    JButton buttonCos = new JButton( "Cos" );
    buttonCos.setBackground(Color.green);
    JButton buttonTan = new JButton( "Tan" );
    buttonTan.setBackground(Color.green);
    JButton buttonDec = new JButton( "." );
    buttonDec.setBackground(Color.blue);
    JButton buttonEq = new JButton( "=" );
    buttonEq.setBackground(Color.orange);
    JButton buttonPlusMinus = new JButton( "+/-" );
    buttonPlusMinus.setBackground(Color.blue);
    //create a panel for each row
    JPanel row1 = new JPanel();
    row1.setBackground(Color.darkGray);
    JPanel row2 = new JPanel();
    row2.setBackground(Color.darkGray);
    JPanel row3 = new JPanel();
    row3.setBackground(Color.darkGray);
    JPanel row4 = new JPanel();
    row4.setBackground(Color.darkGray);
    JPanel row5 = new JPanel();
    row5.setBackground(Color.darkGray);
    JPanel row6 = new JPanel();
    row6.setBackground(Color.darkGray);
    JPanel row7 = new JPanel();
    row7.setBackground(Color.darkGray);
    //create panel for rows and set layout
    JPanel p = new JPanel();
    p.setLayout(new GridLayout( 7,1,0,5 ));
    p.setBackground(Color.darkGray);
    //set layout for rows
    GridLayout grid = new GridLayout(1,4,5,0);
    //add buttons & display field to rows
    row1.setLayout(grid);
    row1.add(display);
    //add row to panel
    p.add(row1);
    row2.setLayout(grid);
    buttonC.addActionListener(this);
    row2.add(buttonC);
    buttonSin.addActionListener(this);
    row2.add(buttonSin);
    buttonCos.addActionListener(this);
    row2.add(buttonCos);
    buttonTan.addActionListener(this);
    row2.add(buttonTan);
    //add row to panel
    p.add(row2);
    row3.setLayout(grid);
    button7.addActionListener(this);
    row3.add(button7);
    button8.addActionListener(this);
    row3.add(button8);
    button9.addActionListener(this);
    row3.add(button9);
    buttonPlus.addActionListener(this);
    row3.add(buttonPlus);
    //add row to panel
    p.add(row3);
    row4.setLayout(grid);
    button4.addActionListener(this);
    row4.add(button4);
    button5.addActionListener(this);
    row4.add(button5);
    button6.addActionListener(this);
    row4.add(button6);
    buttonMinus.addActionListener(this);
    row4.add(buttonMinus);
    //add row to panel
    p.add(row4);
    row5.setLayout(grid);
    button1.addActionListener(this);
    row5.add(button1);
    button2.addActionListener(this);
    row5.add(button2);
    button3.addActionListener(this);
    row5.add(button3);
    buttonMult.addActionListener(this);
    row5.add(buttonMult);
    //add row to panel
    p.add(row5);
    row6.setLayout(grid);
    button0.addActionListener(this);
    row6.add(button0);
    buttonDec.addActionListener(this);
    row6.add(buttonDec);
    buttonPlusMinus.addActionListener(this);
    row6.add(buttonPlusMinus);
    buttonDiv.addActionListener(this);
    row6.add(buttonDiv);
    //add row to panel
    p.add(row6);
    row7.setLayout(grid);
    buttonEq.addActionListener(this);
    row7.add(buttonEq);
    //add row to panel
    p.add(row7);
    // add panel and textField2 to the container
    con.add(p,BorderLayout.CENTER);
    con.add(textField2,BorderLayout.SOUTH);
    public void actionPerformed(ActionEvent e) {
    String buttonPressed = e.getActionCommand();
    try {
    if (buttonPressed.equals( "+/-" )) {
    value = getValue(display.getText());
    value *= -1;
    clearOutput();
    addToOutput("" + value );
    else switch ( buttonPressed.charAt(0) ) {
    case '+':
    case '-':
    case '*':
    case '/':
    buttonEq.setEnabled(true);
    buttonPlus.setEnabled(false);
    buttonMinus.setEnabled(false);
    buttonMult.setEnabled(false);
    buttonDiv.setEnabled(false);
    num1 = getValue(display.getText());
    op = buttonPressed.charAt(0);
    clearNext = true;
    break;
    case '=':
    buttonEq.setEnabled(true);
    buttonPlus.setEnabled(true);
    buttonMinus.setEnabled(true);
    buttonMult.setEnabled(true);
    buttonDiv.setEnabled(true);
    getResult();
    num1 = getValue(display.getText());
    op = 0 ;
    clearNext = true;
    break;
    case 'C':
    float num1 = getValue(display.getText());
    op = buttonPressed.charAt(0);
    getResult();
    clearNext = false;
    break;
    case 'S':
    num1 = getValue(display.getText());
    op = buttonPressed.charAt(0);
    getResult();
    clearNext = false;
    break;
    case 'T':
    num1 = getValue(display.getText());
    op = buttonPressed.charAt(0);
    getResult();
    clearNext = false;
    break;
    case 'c':
    clearOutput();
    op = 0 ;
    num1 = (float) 0 ;
    break;
    default:
    if (clearNext) {
    clearOutput();
    clearNext = false;
    addToOutput(buttonPressed);
    catch( Exception exception) {
    System.err.println(exception.toString());
    public void getResult() {
    float num2 = getValue(display.getText());
    switch (op) {
    case '+':
    num1 += num2;
    break;
    case '-':
    num1 -= num2;
    break;
    case '*':
    num1 *= num2;
    break;
    case '/':
    if (num2 != 0)
    num1 /= num2;
    else
    num1 = 0;
    break;
    case 'C':
    Math.cos(num1);
    break;
    case 'S':
    Math.sin(num1);
    break;
    case 'T':
    Math.tan(num1);
    break;
    clearOutput();
    addToOutput( "" + num1 );
    clearNext = true;
    public void addToOutput( String buttonPressed) {
    String newOutput = display.getText();
    if (buttonPressed.equals(".")) {
    if (newOutput.indexOf(".") == -1)
    newOutput += ".";
    else
    newOutput += buttonPressed;
    int newLength = newOutput.length();
    display.setText(newOutput);
    public void clearOutput() {
    try{
    display.setText( "" );
    catch(Exception c) {
    System.err.println(c.toString());
    public float getValue(String arg) {
    if (arg.equals("."))
    arg = "0";
    Float f = Float.valueOf(arg);
    return f.floatValue();

    I have found your error please change this to the below one
    //add display display
    JTextField display = new JTextField( "0", 15 );
    display.setBackground(Color.black);
    display.setForeground(Color.red);
    display.setEditable(false);
    //add display display
    display = new JTextField( "0", 15 );
    display.setBackground(Color.black);
    display.setForeground(Color.red);
    display.setEditable(false);
    if you noticed, you declared the display as a global variable but did not intialized it that is why u get NullPointerException.
    By declaring JTextField display again in a method it only belong to that method which is init()
    The other textfield also have to be changed if you wish to access it from elsewhere(ex. textfield2 )
    Thanks
    Joey

  • Applet(using SSL sockets) application in browser

    hello everyone,
    I am new to this forum, and this is my first forum in this site, please help me,
    My problem is,
    I have done an applet application which uses the SSL sockets, and it is working fine if i use the appletviewer tool, with the arguments of policy and URL, when i run this command "appletviewer -J-Djava.security.policy=mypolicy.policy URL of my html page" in the command mode its working fine.
    I have wrote HTML file for running the applet, and when i used it in the browser i was not able to get output , i was getting the error "NoTrustedCertificates found", i have setted the properties of truststore and password in the program itself like,
    System.setProperty("javax.net.ssl.trustStore", System.getProperty("java.home")+"cert");
    System.setProperty("javax.net.ssl.trustStorePassword", "pwd");
    and i also used the policy tool. I have stored my certificate along with the jar file, and i was getting this error
    can anyone please help me, or suggest me the right way to reach my target.
    Thanx in advance

    Hai,
    I have made my client applet running from the remote system, and the client was establishing SSL sockets, and there is a problem in Handshake, NO TRUSTED CERTIFICATE found was the error, and i had loaded the certificates ( one is used for signing the certificate, and the other is used for the SSL sockets authentication ) in my applet client code i have setted the system properties like
    System.setProperty("javax.net.ssl.trustStore", System.getProperty("java.home")+"\\lib\\security\\cert");
    System.setProperty("javax.net.ssl.trustStorePassword", "pwd");
    and this is the certificate which is used for SSL sockets authentication, and i stored the cert in the "jre\lib\security\" directory, and im using the jdk1.4.2_05 version.
    At the client side the error is
    Network Error: sun.security.validator.ValidatorException: No trusted certificate found.
    at com.sun.net.ssl.internal.ssl.BaseSSLSocketImpl.a(Unknown Source)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(Unknown Source)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(Unknown Source)
    at com.sun.net.ssl.internal.ssl.SunJSSE_az.a(Unknown Source)
    at com.sun.net.ssl.internal.ssl.SunJSSE_az.a(Unknown Source)
    at com.sun.net.ssl.internal.ssl.SunJSSE_ax.a(Unknown Source)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(Unknown Source)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.j(Unknown Source)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(Unknown Source)
    at com.sun.net.ssl.internal.ssl.AppOutputStream.write(Unknown Source)
    at java.io.OutputStream.write(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    Caused by: sun.security.validator.ValidatorException: No trusted certificate found
    at sun.security.validator.SimpleValidator.buildTrustedChain(Unknown Source)
    at sun.security.validator.SimpleValidator.engineValidate(Unknown Source)
    at sun.security.validator.Validator.validate(Unknown Source)
    at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(Unknown Source)
    at com.sun.net.ssl.internal.ssl.JsseX509TrustManager.checkServerTrusted(Unknown Source)
    At the server side the error is
    javax.net.ssl.SSLHandshakeException: Received fatal alert: certificate_unknown
    at com.sun.net.ssl.internal.ssl.BaseSSLSocketImpl.a(Unknown Source)
    at com.sun.net.ssl.internal.ssl.BaseSSLSocketImpl.b(Unknown Source)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.b(Unknown Source)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(Unknown Source)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.j(Unknown Source)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(Unknown Source)
    at com.sun.net.ssl.internal.ssl.AppInputStream.read(Unknown Source)
    at com.ClientNeg.run(ClientNeg.java:76)
    at java.lang.Thread.run(Unknown Source)
    i was not able to understand what went wrong , so any one please help me in doing my work.
    Thanx
    dwurity

  • Using Swing applet to write data to file on SERVER

    Hello,
    I'm in the process of writing an applet using Swing (SDK v1.4.2). Here's the deal. The JApplet calls a JPanel, which will be used by customers on my site to enter data. I'm adding a <Save> button to the "form" which is supposed to write data to a file on the server (in order to preserve the customer's preferences).
    Please note that I am NOT attempting to write data to the customer's hard disk. That requires digital certificates, etc. which I am trying to avoid for now.
    Instead, I am using the URL class to access the file:
    URL page = new URL("http://www.whatever.com/mycustomers/preferences.txt")
    I then use the URLConnection class to establish the connection:
    URLConnection conn = this.page.openConnection();
    conn.setDoInput(true);
    conn.setDoOutput(true);
    conn.connect();
    etc...
    I've created a text file (preferences.txt) on my web site. Using the classes InputStreamReader, BufferedStreamReader, and StringBuffer, I can successfully read the file into a JOptionPane in my applet.
    The problem comes when I try to write data TO this file. I know the file exists because the applet can read it. I've set the permissions on the file to 666. I've got all of the appropriate syntax within a try statment that catches an IOException. I also have JOptionPanes all over the place to let me know where the program is. I've tried different combinations of output streams like BufferedWriter, BufferedOutputStream, StringWriter, but the file does not get updated. When the applet runs, it does not throw any exceptions, not even when I change the URL from "HTTP://www.whatever.com/prefs.txt" to "HTTP:/www.whatever.com/prefs.txt" (only one slash on HTTP, shouldn't I get a MalformedURLException?)
    I apologize for all the background, but I thought you might need it. The bottom line is:
    1) Can an applet write to a file on a remote server (not local hard disk)?
    2) If so, what (if any) caveats are there?
    3) Is there a way to check for file existence or be able to create a new file?
    4) I'm using the HTTP protocol - is there some restriction that prevents an applet from writing to a file using that protocol? If so, is there a workaround?
    5) Assuming that creating/writing a file using the method I've described is possible, what would be the appropriate output streams to use? (Currently, I'm using OutputStreamWriter with BufferedWriter).
    I've been struggling with this for a while. Any help/suggestions would be appreciated.
    Thanks
    P.S. I also posted this message on the Applet development forum, but I've received no response as of yet.

    Http servers support PUT as a mechanism to upload data to a specified URL. Get on the other hand which is what most people are familiar with is how you retrieve that data. The basic URLConnection is an abstraction of the Http connection which can be used for GET and POST operations by default based on doInput(true|false).. If you which to use any of the http methods other than GET|POST you will have to cast the URLConnection to HttpURLConnection so you can gain access to the specific Http functionaility that could not be abstracted.
    Since you are using a hosting service the chances are that you won't be able to use HTTP PUT on their server. Most servers do not support HTTP PUT without configuring them todo so. Now Apache allows localized config through the .htacess file. It might be possible (keep in mind I am not an apache expert) to configure a particular directory to allow HTTP PUT using this .htacess file it may not be possible. You will have to consult the Apache web server documentation for that answer.
    But regardless you can use the HttpURLConnection and the PUT method to send data from your applet to the server. In fact that is the preferred way to do this. If you can not configure your web server to support that method then you will have to develop a Servlet to do it. A servlet has several methods such as doGet(), doPost(), and doPut(). You would override the doPut() method get the URI path create a file and a FileOutputStream to that file, get from the request the inputstream, possibly skip the http headers, and then write byte for byte the incoming data to your OutputStream until you reach the end at which point you would close the OutputStream and send an Http Response of some sort. Typically in HTTP it would be 200 OK plus some web content. You content can be empty so long as your applet recognizes that is what it should expect...
    And away you go...

  • Kindly help me how to view html file in swing using jbutton

    hello..im a begginer at j2se language and im working on my school project..kindly help me how to view html files by clicking button at javax.swing..thanks

    Here you go:public class HTMLViewer implements Runnable, ActionListener
         public void run() {
              JFrame frame = new JFrame("View HTML");
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              JButton button = new JButton("Click me!");
              button.addActionListener(this);
              Container cp = frame.getContentPane();
              cp.add(button, BorderLayout.CENTER);
              frame.pack();
              frame.setLocationRelativeTo(null);
              frame.setVisible(true);
         public void actionPerformed(ActionEvent e) {
              if (Desktop.isDesktopSupported()) {
                   Desktop d = Desktop.getDesktop();
                   try {
                        d.browse(new URI("www.google.com"));
                   } catch (IOException ex) {
                        ex.printStackTrace();
                   } catch (URISyntaxException ex) {
                        ex.printStackTrace();
         public static void main(String[] args) {
              EventQueue.invokeLater(new HTMLViewer());
    }If that's not what you're looking for you need to ask more specific questions.

  • Applet use with HTML// also appletviewer question

    I am new to the language. I am trying to start an applet in a folder that I created on my hard drive(C:). I have included the following code in my HTML in my folder.
    <applet code="NotHelloWorldApplet.class"
    width= "300" height= "300">
    </applet>
    I have already compiled the program; I have the net beans 1_4_2 compiler, and it has compiled without errors.
    The code is :
    import java.awt.*;
    import javax.swing.*;
    public class NotHelloWorldApplet extends JApplet
    public void init()
    Container contentPane = getContentPane();
    JLabel label = new JLabel("Not a Hello, World applet",
    SwingConstants.CENTER);
    contentPane.add(label);
    I have also downloaded Plug-In; if that means anything. When I open the HTML folder a grey box appears; then at the bottom of the window it says that it cannot find the file; even though the file exists(I have looked with the file finder and it is in my file directory). Is it in the wrong directory? How does the file folder in windows know how to run and execute a java program with the preceding HTML code. This is the method explained in a current text book that I am using. It tells me to
    1. to compile the source code into class files.
    I used the compiler and I successfully created a .class file, (obviously the title of the program is .java program, but the class file does exist.
    Then 2. add the above code in the HTML program(which I did).
    I would like to get applets running but do not know how to correct this problem. Is there more HTML code that I need to run a java program in the folder's code.
    Also, the textbook I am using tells me to preview the applet with appletviewer. I loaded the appletviewer into the editing screen and it is a bunch of hieroglyphics. One of two possible problems are that it is not included with the Net_Beans_1.4.2(it was from another download) or the download was contaminated. Anyway, the question I have is; is appletviewer an application that is viable with Net_Beans_1.4.2 and if it is from where and how do I run or execute it to preview my applets before I run them inside an HTML document.
    Derk_the_Zeeman
    [email protected]

    Sounds to me like you're having trouble with NetBeans, not applets or appletviewer. You should consult their docs on how to access their version of appletviewer.
    It also sounds to me like you're using the book CoreJava by Horstmann/Cornell.
    Notice that they package TextPad with their book. This is for a good reason. It is very easy to be suckered into thinking you know what is going on when you have an IDE that does stuff for you. I know. I programmed in VB for a while, and I thought I knew how to do Windows programming. But I didn't. VB was doing all the work for me while I was drawing boxes on the screen and patting myself on the back. It took several major blows to the ego before I found out that all I really knew how to do was how to draw a bunch of silly boxes.
    New programmers should start out with a text editor. They get a better feel of what is going on.
    I don't know how NetBeans works -- even now I prefer TextPad over any IDE I've tried. But appletviewer works in the same way the java and javac command works, except that the argument it takes is the name of the html file which contains those applet tags (<APPLET>).
    I have some thoughts on your problem:
    1) you have an html file somewhere, but you don't know where. It is somehow created in a "window". the tag
    applet code="NotHelloWorldApplet.class"
    means "look in this directory for the class NotHelloWorldApplet.class" So if the html file you have created is not in this directory, how will appletviewer (or NetBean equivalent) know where it is? (hence, "class not found")
    2) Is this correct? You have downloaded the plug-in for your browsers, but you didn't try using your browsers to see the applet?
    If so, try this: go to IE or Netscape (or whatever you favorite browser is) and try in IE File-->Open and hit the browse button, or in Netscape File--> Open File
    Next, try to find the file "NotHelloWorldApplet.html" or whatever it is you called the "window". Open the html file.
    If it doesn't work, check to see if the html file is in the same directory as the class file (repeat procedure, but now look at files of type "All")
    3) You can make an html file with notepad. You don't need anything special. Just type in the html code that Horstmann/Cornell include into notepad and save as an html.
    Does this help?
    :) jen

  • I can't use swing components in my applets

    When I write an applet without any swing components, my browser never has any trouble finding the classes it needs, whether they're classes I've written or classes that came with Java. However, when I try to use swing components it cannot find them, because it is looking in the wrong place:
    On my computer I have a directory called C:\Java, into which I installed my Java Development Kit (so Sun's classes are stored in the default location within that directory, wherever that is), and I store my classes in C:\Java\Files\[path depends on package]. My browser gives an error message along the lines of "Cannot find class JFrame at C:\Java\Files\javax\swing\JFrame.class"; it shouldn't be looking for this non-existent directory, it should find the swing components where it finds, for example, the Applet class and the Graphics class.
    Is there any way I can set the classpath on my browser? Are the swing components stored separately from other classes (I'm using the J2SE v1.3)?
    Thanks in advance.

    Without having complete information, it appears that you are running your applets using the browser's VM. Further, I assume you are using either IE or Netscape Navigator pre-v6. In that case, your browser only supports Java 1.1, and Swing was implemented in Java 1.2. You need to use the Java plug-in in order to use the Swing classes (see the Plug-in forum for more information), or else download the Swing classes from Sun and include them in your CLASSPATH.
    HTH,
    Carl Rapson

  • Help Needed in opening a HTML File from swing application

    Hi,
    I am opening a HTML file in Internet Explorer from my swing application.
    I am using the code given below
    private final static String WIN_FLAG = "url.dll,FileProtocolHandler";
    private final static String WIN_PATH = "rundll32";
    String cmd = WIN_PATH + " " + WIN_FLAG + " " + url;
    // url is HTML file Path
    Process p = Runtime.getRuntime().exec( cmd );
    The HTML file is opening up,but it always opens behind the swing application,that makes me every time to maximize the HTML file after it being opened up.
    I want to open it in front of the Swing Application.
    Any Help Please ?
    - Manikandan

    Check your Application's JFrame properties (may be ur Frame is set to be in top position ,always),and also check running your application in some other OS.

  • Include many jars for a complex signed applet in html file??

    hello
    I'd like to know how it's possible to put a signed applet in an html file, that needs many jar files.
    I explain myself: I know that to create a signed applet and to put it in an html file, I need to create a Jar file that contains this applet, create a private key with keytool, sign the jar and include it in my html file with the tag <applet code="....." archive="......jar".... />
    This works fine if my applet is a simple program that only uses the clases present by default in the jdk.
    In my case, I have a big project, with many packages. In one of these packages, I have my applet that uses some classes of the other packages, which use classes from imported jars, such as BouncyCastle, and others...
    There is still no problem when I run the applet from the applet viewer.
    The problem appears when I put the JAR file with all these classes in the html file: there is a problem since it doesn't know anything of these classes imported from these jars.. It's quite obvious actually.
    My question is: how do I do to make the html file aware of these classes? Is there an html tag that allows us to include many jar files? Do I have to decompress all these jars, take all the directories, add them to the directories of my project and create a BIG jar (that's what I did, but it's really dirty, and heavy! (11M))??
    Does anyone have an idea about how I can do it?
    Thanks for your help
    Philippe

    11 MB is pretty big for an applet.
    Let's say your applet uses java 3d, normally a client would download and
    install this seporately, meaning the jars needed end up in lib/ext directory where
    any applet can find them.
    Check what applets need to be installed (put in lib/ext) and what can be
    downloaded:
    <object .....
    <param name="archive" value="myJar.jar, myOtherjar.jar" />

Maybe you are looking for

  • Want Welcome screen to open up all the time in itunes

    I'm trying to sync my ipod to itunes and want the Welcome screen to appear when I open itunes.  Instead, the program takes me straight to my library.  How can I get itunes to always open up to my Welcome screen?

  • Idoc for Customer to Customer Posting

    Hi I want to upload finance data in SAP using IDOCS through XI I'm using the following idocs 1) GL to GL Posting ........ ACC_GL_POSTING01 (Accounting: General G/L Account Posting) 2) GL to Customer Posting ..... ACLREC01 (Posting in accounting: Bill

  • Information on mapping  and how to configure the mapping?

    Hi All         Experts!!!  i am new XI and any one can provide the information mapping ?         Like purpose of mapping? how to configure ? what are different mappings?         In detail pls... Adv..thanks Cheers Rakesh

  • Third party sales interface

    We have been asked to design a third party sales interface for a set of countries. Provider also uses SAP and there are a few prereqs: 1. Goods will be received directly by provider 2. We will have to invoice provider based on their sales 3. A lot of

  • Install Workbook Precalculation Service

    Hello, I am trying to install the workbook precalculation service locally on my PC, but did not succeed up to now. I have installed the following on my PC: - Microsoft .Net Framework 1.1 - SAP Gui 6.40 (with extra patches) - BW Workbook Precalculatio