LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-07-2010, 01:59 PM   #1
Larry James
Member
 
Registered: Jun 2000
Location: Buffalo, New York
Distribution: Ubuntu, Raspbian
Posts: 381

Rep: Reputation: 40
What can be done to make these code examples work on web Browsers?


I have tried numerous versions of “Hello World” examples over the web to display the text on a web page. All the examples work on my local machine in the application viewer, but they don’t work when from a web browser. I have tried both Firefox and IE.

Some of them include:

http://java.sun.com/docs/books/tutor...orldSwing.java

Firefox error:

Code:
java.lang.reflect.InvocationTargetException
	at com.sun.deploy.util.DeployAWTUtil.invokeAndWait(Unknown Source)
	at sun.plugin2.applet.Plugin2Manager.runOnEDT(Unknown Source)
	at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
	at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassCastException: start.HelloWorldSwing cannot be cast to java.applet.Applet
	at sun.plugin2.applet.Plugin2Manager$12.run(Unknown Source)
	at java.awt.event.InvocationEvent.dispatch(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)
Exception: java.lang.reflect.InvocationTargetException
http://en.wikipedia.org/wiki/Swing_%28Java%29

Error when viewed on Firefox:

Code:
java.lang.reflect.InvocationTargetException
	at com.sun.deploy.util.DeployAWTUtil.invokeAndWait(Unknown Source)
	at sun.plugin2.applet.Plugin2Manager.runOnEDT(Unknown Source)
	at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
	at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassCastException: start.SwingExample cannot be cast to java.applet.Applet
	at sun.plugin2.applet.Plugin2Manager$12.run(Unknown Source)
	at java.awt.event.InvocationEvent.dispatch(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)
Exception: java.lang.reflect.InvocationTargetException
An Ideal Code if someone could decipher why it fails from a browser is:

Code:
 import javax.swing.*;

public class SwingHelloWorld extends JFrame {
    public SwingHelloWorld(String name) {
      super(name);
      this.setDefaultCloseOperation(EXIT_ON_CLOSE);

      JLabel label = new JLabel(name);
      // label.setPreferredSize(new Dimension(210, 80));
      this.getContentPane().add(label);

      this.pack();
      this.setVisible(true);
    }


  public static void main(String argv[]) {
        SwingHelloWorld swingHelloWorld = new SwingHelloWorld("This would be great if it worked via a browser!");
  }
}

Error from Firefox:

Code:
java.lang.reflect.InvocationTargetException
	at com.sun.deploy.util.DeployAWTUtil.invokeAndWait(Unknown Source)
	at sun.plugin2.applet.Plugin2Manager.runOnEDT(Unknown Source)
	at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
	at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.RuntimeException: java.lang.InstantiationException: start.SwingHelloWorld
	at sun.plugin2.applet.Plugin2Manager$12.run(Unknown Source)
	at java.awt.event.InvocationEvent.dispatch(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.lang.InstantiationException: start.SwingHelloWorld
	at java.lang.Class.newInstance0(Unknown Source)
	at java.lang.Class.newInstance(Unknown Source)
	... 9 more
Exception: java.lang.reflect.InvocationTargetException
The latter code is very short and would serve the intended purpose most ideal. It can accept input and allow me to replace the “System.out.println” function that works so well to display when working with code in the development environment.

Thanks in advance for any input on this.

-- L. James

--
L. D. James
ljames@apollo3.com
www.apollo3.com/~ljames
 
Old 03-07-2010, 07:03 PM   #2
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,771

Rep: Reputation: 2070Reputation: 2070Reputation: 2070Reputation: 2070Reputation: 2070Reputation: 2070Reputation: 2070Reputation: 2070Reputation: 2070Reputation: 2070Reputation: 2070
Browers run Applets. Swing has JApplets.

EDIT: that is you need to use one of these rather than JFrame.

Last edited by ntubski; 03-08-2010 at 09:31 AM. Reason: clarity
 
1 members found this post helpful.
Old 03-07-2010, 08:04 PM   #3
Larry James
Member
 
Registered: Jun 2000
Location: Buffalo, New York
Distribution: Ubuntu, Raspbian
Posts: 381

Original Poster
Rep: Reputation: 40
Quote:
Originally Posted by ntubski View Post
Browers run Applets. Swing has JApplets.
Do you think you can give an example of how to make display a string in a browser using Java with either Applets or JApplets? I guess you're saying that the JApplets are not able to output to Browsers.

I kind of thought the purpose of Java was to enhance browsers. I'm surprised it had progressed to a state that doesn't work on Java anymore.

I asked a similar question on Sun and they said to use Swing for displaying on Browsers, but didn't give me a suggestion how to actually make an application that would run on the browser using Swing. So I spent another week trying many variations.

Thanks in advance if you or anyone else has an example that would actually work.

-- L. James

--
L. D. James
ljames@apollo3.com
www.apollo3.com/~ljames
 
Old 03-08-2010, 09:30 AM   #4
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,771

Rep: Reputation: 2070Reputation: 2070Reputation: 2070Reputation: 2070Reputation: 2070Reputation: 2070Reputation: 2070Reputation: 2070Reputation: 2070Reputation: 2070Reputation: 2070
Quote:
Originally Posted by Larry James View Post
Do you think you can give an example of how to make display a string in a browser using Java with either Applets or JApplets? I guess you're saying that the JApplets are not able to output to Browsers.
No, sorry I wan't clear. JApplet is the swing equivalent of Applet, like JFrame is the swing equivalent of Frame. Your program was using JFrame, I meant that you should use Applet or JApplet instead.

Quote:
I kind of thought the purpose of Java was to enhance browsers. I'm surprised it had progressed to a state that doesn't work on Java anymore.

I asked a similar question on Sun and they said to use Swing for displaying on Browsers, but didn't give me a suggestion how to actually make an application that would run on the browser using Swing. So I spent another week trying many variations.

Thanks in advance if you or anyone else has an example that would actually work.
Getting Started With Applets.
 
1 members found this post helpful.
Old 03-08-2010, 04:51 PM   #5
Larry James
Member
 
Registered: Jun 2000
Location: Buffalo, New York
Distribution: Ubuntu, Raspbian
Posts: 381

Original Poster
Rep: Reputation: 40
Quote:
Originally Posted by ntubski View Post
No, sorry I wan't clear. JApplet is the swing equivalent of Applet, like JFrame is the swing equivalent of Frame. Your program was using JFrame, I meant that you should use Applet or JApplet instead.


Getting Started With Applets.
Ntubski, thanks for the information and explanation. I probably should have told you that I had found a couple of hello worlds that would actually print to the web. I’ve been studying for a long time before posting messages asking for some assistance.

I posted a similar message on the sun.com New Java User forum and got bashed kind of heavily for not using JFrames and JLabels and told to study it. I studied it a lot but as you see, while performing the examples as produced by Sun following their samples exactly, don’t work.

It really appears to be extremely complex when none of the examples on their site (that includes JFrames or JLabels) will work, and they actually have code and lessons with the examples of how to display the compiles results on a web browser.

I actually have about 5 “Hello worlds” that I found that will display on a browser. However, none of them comes with a Main class, and I can’t figure out how to get my own test to the code, as in the case of the link you gave.

I have tried to add a main class. In some of my attempts I have successfully got it to function on my local computer, but it fails when I try to have code function in a browser.

Here is the code I have (directly from your link):

Code:
import javax.swing.JApplet;
import javax.swing.SwingUtilities;
import javax.swing.JLabel;

public class HelloWorld extends JApplet {
    //Called when this applet is loaded into the browser.
    public void init() {
        //Execute a job on the event-dispatching thread; creating this applet's GUI.
        try {
            SwingUtilities.invokeAndWait(new Runnable() {
                public void run() {
                    JLabel lbl = new JLabel("Hello World");
                    add(lbl);
                }
            });
        } catch (Exception e) {
            System.err.println("createGUI didn't complete successfully");
        }
    }
}
I would like to add:

Code:
public static void main(String[] args) {
        // JOptionPane.showMessageDialog(null, "Hello, World!");
        /*
         * Code to call the print HelloWorld class above with my chosen text
         * string and replacing:
         * new JLabel("Hello World")
         * with a variable such as:
         * new JLabel(mystring);
         */
    }
Thanks again for the input. Believe me, I have been reading for a long time and trying many combination. I have gone over many of the tutorials and compiled very complex packages that the Sun lessons that will not display on the web.

If I can just get past this hurtle I’ll be very far along the way.

Thanks again for any assistance.

-- L. James

--
L. D. James
ljames@apollo3.com
www.apollo3.com/~ljames
 
Old 03-08-2010, 07:49 PM   #6
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,771

Rep: Reputation: 2070Reputation: 2070Reputation: 2070Reputation: 2070Reputation: 2070Reputation: 2070Reputation: 2070Reputation: 2070Reputation: 2070Reputation: 2070Reputation: 2070
Applets don't start from the main() method, what happens is that an Applet object is constructed, and it's init() and start() methods are called. The thing is that String[] args refers to command line arguments, but when an Applet is run from a browser there is no command line.

I confess I didn't look closely at the tutorial I linked to; I assumed Sun's official stuff would be good, but I agree with you that it appears to be needlessly complex. I learned Java from here, I think the chapter about Applets is much easier to understand.
 
1 members found this post helpful.
Old 03-08-2010, 08:08 PM   #7
Larry James
Member
 
Registered: Jun 2000
Location: Buffalo, New York
Distribution: Ubuntu, Raspbian
Posts: 381

Original Poster
Rep: Reputation: 40
Quote:
Originally Posted by ntubski View Post
Applets don't start from the main() method, what happens is that an Applet object is constructed, and it's init() and start() methods are called. The thing is that String[] args refers to command line arguments, but when an Applet is run from a browser there is no command line.

I confess I didn't look closely at the tutorial I linked to; I assumed Sun's official stuff would be good, but I agree with you that it appears to be needlessly complex. I learned Java from here, I think the chapter about Applets is much easier to understand.
Can you think of a way to pass a variable from a different class to this:

Code:
import javax.swing.JApplet;
import javax.swing.SwingUtilities;
import javax.swing.JLabel;

public class HelloWorld extends JApplet {
    
    String myhello;
    
    //Called when this applet is loaded into the browser.
    public void init() {
        //Execute a job on the event-dispatching thread; creating this applet's GUI.
        try {
            SwingUtilities.invokeAndWait(new Runnable() {
                public void run() {
                    JLabel lbl = new JLabel(myhello);
                    add(lbl);
                }
            });
        } catch (Exception e) {
            System.err.println("createGUI didn't complete successfully");
        }
    }
}
I have other code that performs a function that I would like to have the results output to a browser. If you look at the code above you’ll see the myhello string variable, but I don’t know how to get the information to the string. Looking at the tutorials I’ve been following for the past few months I’m able to get information pasts to the applet by the main class.

I’ll add the links you gave me to the reading and studying that I’m doing. But in the meantime can you look at the code and help me to be able to pass a variable to the output?

Thanks again for all the input.

-- L. James

--
L. D. James
ljames@apollo3.com
www.apollo3.com/~ljames
 
Old 03-08-2010, 08:24 PM   #8
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,771

Rep: Reputation: 2070Reputation: 2070Reputation: 2070Reputation: 2070Reputation: 2070Reputation: 2070Reputation: 2070Reputation: 2070Reputation: 2070Reputation: 2070Reputation: 2070
I'm not sure I understand what you want, would this work?

Code:
import javax.swing.JApplet;
import javax.swing.SwingUtilities;
import javax.swing.JLabel;

public class HelloWorld extends JApplet {

    String dosomething() {
        // code that returns some output
    }
    
    //Called when this applet is loaded into the browser.
    public void init() {
        //Execute a job on the event-dispatching thread; creating this applet's GUI.
        try {
            SwingUtilities.invokeAndWait(new Runnable() {
                public void run() {
                    JLabel lbl = new JLabel(dosomething());
                    add(lbl);
                }
            });
        } catch (Exception e) {
            System.err.println("createGUI didn't complete successfully");
        }
    }
}
 
1 members found this post helpful.
Old 03-08-2010, 08:54 PM   #9
Larry James
Member
 
Registered: Jun 2000
Location: Buffalo, New York
Distribution: Ubuntu, Raspbian
Posts: 381

Original Poster
Rep: Reputation: 40
Quote:
Originally Posted by ntubski View Post
I'm not sure I understand what you want, would this work?

...
Actually I believe it’s the opposite. A different class will send a string to the HelloWorld class, and the HelloWorld Class will print the string.

I have another class that does a lot of work. When it finishes it will sent a string to the HelloWorld class, which will output what it receives.

I can easily receive strings from a different class if the class have a static main and receives arguments. But I don’t know how to make this HelloWorld class (which does a good job of printing) receive anything.

The HelloWorld class will look something like:

Code:
import javax.swing.JApplet;
import javax.swing.SwingUtilities;
import javax.swing.JLabel;

public class HelloWorld extends JApplet {
    
    String myhello = "String from calling class";
    
    //Called when this applet is loaded into the browser.
    public void init() {
        //Execute a job on the event-dispatching thread; creating this applet's GUI.
        try {
            SwingUtilities.invokeAndWait(new Runnable() {
                public void run() {
                    JLabel lbl = new JLabel(myhello);
                    add(lbl);
                }
            });
        } catch (Exception e) {
            System.err.println("createGUI didn't complete successfully");
        }
    }
}
My other class with does all the work will call the HelloWorld class (of course the finished production HelloWorld class will have a different name such as PrintToWeb class). The other CallingClass after it finishes its functions and calculations will call the HelloWorld class. It’ll look something like this:

Code:
 public class CallingClass {
    HelloWorld ("This is the sring that is being passed");
}
My problem is that I’m having problems with the HelloWorld class receiving a variable from the calling class. I’m also having problems calling the HelloWorld Class. I can put other classes and constructors into the HelloWorld class and call them, but they won’t pass the information to the lines that print the text.

-- L. James

--
L. D. James
ljames@apollo3.com
www.apollo3.com/~ljames
 
Old 03-09-2010, 05:56 PM   #10
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,771

Rep: Reputation: 2070Reputation: 2070Reputation: 2070Reputation: 2070Reputation: 2070Reputation: 2070Reputation: 2070Reputation: 2070Reputation: 2070Reputation: 2070Reputation: 2070
Quote:
Originally Posted by Larry James View Post
My other class with does all the work will call the HelloWorld class (of course the finished production HelloWorld class will have a different name such as PrintToWeb class). The other CallingClass after it finishes its functions and calculations will call the HelloWorld class. It’ll look something like this:

Code:
 public class CallingClass {
    HelloWorld ("This is the sring that is being passed");
}
Execution starts from the Applet code, so HelloWorld has to be the one to call other classes, maybe you want to create a Thread like this?
Code:
import javax.swing.JApplet;
import javax.swing.JLabel;

public class HelloWorld extends JApplet {
    
    JLabel lbl;
    Thread caller;
    
    public void init() {
        caller = new Thread(new CallingClass(this));
        lbl = new JLabel();
        add(lbl);
    }
    
    public void start() {
        caller.start();
    }

    // probably shouldn't be called from a different thread
    // but let's ignore that for now
    void setOutput(String str) {
        lbl.setText(str);
    }
}

class CallingClass implements Runnable {
    HelloWorld applet;
    
    CallingClass(HelloWorld applet) {
        this.applet = applet;
    }
    
    public void run() {
        applet.setOutput("a string");
        
        // do some more stuff...
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            return;
        }
        
        applet.setOutput("another string");
    }
}
 
Old 03-09-2010, 10:26 PM   #11
Larry James
Member
 
Registered: Jun 2000
Location: Buffalo, New York
Distribution: Ubuntu, Raspbian
Posts: 381

Original Poster
Rep: Reputation: 40
Quote:
Originally Posted by ntubski View Post
Execution starts from the Applet code, so HelloWorld has to be the one to call other classes, maybe you want to create a Thread like this?
Thanks, Ntubski. The code works, but the concept isn’t quite right. I was studying how java handles methods, classes, objects, etc. so that I could clarify the question/objective better. I was writing something that might explain it.

Since your code demonstrates a lot of this (java classes and objects) I’m using it to try to figure out how to get it done.

The problem with HelloWorld calling the class that uses it is that it won’t know every class that will decide to use it. From my reading, classes are often singer *.java files. So the HelloWorld (which has the ability to print to the web) will be a singer class file that other classes (java files) can call.

The HelloWorld class (file) could be named “PrintToWeb.java”. The calling class (or file) can be named anything. It could be, “TheCurrentBuffaloWeather.java”, or “TheBuffaloBillsAverageScore.java”.

The calling call (or file) would call the “HelloWorld.java” by having a line that says:

Code:
class CallingClass1()
{
    // do some work
    HelloWord("Output from the work done.");
    // or better named PrintToWeb(“Output from the work done.”);
}
The HelloWorld.class (or java file) will be contained in the package where any program can call it for it’s output.

I should have renamed the HelloWorld code to PrintToWeb or something similar to have made it understood better that it can’t be expected to know the name of each class that will call it so that it can provide the (caller’s) output to the Web.

-- L. James

--
L. D. James
ljames@apollo3.com
www.apollo3.com/~ljames
 
Old 03-09-2010, 11:15 PM   #12
Larry James
Member
 
Registered: Jun 2000
Location: Buffalo, New York
Distribution: Ubuntu, Raspbian
Posts: 381

Original Poster
Rep: Reputation: 40
Ntubski. I know my whole concept of having a class to print to the web is an unnecessary redundancy to most of you, because whenever you want to print to the web, you just include a few lines of code that will print and include it in any of your classes as is already done with the HelloWorld web, or something as simple as:

Code:
import java.awt.Graphics;
public class HelloWorld extends java.applet.Applet {
    public void init() {
	resize(150,25);
    }
    public void paint(Graphics g) {
	g.drawString("Hello world!", 50, 25);
    }
}
But my problem is, I have trouble (being new to Java) with adding the few lines to every code that I write. I’ll eventually get familiar with Java in such a way that I’ll understand it and be able to do it.

But in the meantime, I thought I’d kill two birds at one time. Take something that can print to the Web, and learn how to interface with one class from another class. This will help my understanding of Java classes, methods, constructors and many other components that will soon start to fall together.

Before the dialog in this thread I didn’t even understand that an applet wasn’t a program and had to have the special java (and javax) implementations to provide the functionality that it needs.

By the way, I tried to interface a new class to the code you provided that works by making a new CallingClass file. I tried to follow the example as much as possible and call the HelloWorld file to output from another CallingClass. It compiles without errors but doesn’t print the string that is being attempted to pass. I believe the problem is that the HelloWorld doesn’t know how to respond because the new class has to have its name included in the HelloWorld code (which idealistically shouldn’t need to know who is calling, just to respond by printing the string that it is passed.

The code is:

Code:
import javax.swing.JApplet;

public class CallingClass1 extends JApplet{
    HelloWorld applet;

    CallingClass1(HelloWorld applet){
        this.applet = applet;
    }
    public void run(){
        applet.setOutput("This is a new string!");

        /* Do some stuff here such as check a database
         * and calculate the statics of the Buffalo Bills.
        */
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e){
            return;
        }
    }
}
-- L. James

--
L. D. James
ljames@apollo3.com
www.apollo3.com/~ljames
 
Old 03-09-2010, 11:26 PM   #13
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Java is much, more more than just applets.

Frankly, if you're interested in Java, why not download a copy of NetBeans (http://java.sun.com) or Eclipse (http://www.eclipse.org) and just learn Java - completely independent of trying to run applets in web browsers.

I think you'll learn more, learn faster ... and be much happier.

IMHO .. PSM
 
Old 03-09-2010, 11:35 PM   #14
Larry James
Member
 
Registered: Jun 2000
Location: Buffalo, New York
Distribution: Ubuntu, Raspbian
Posts: 381

Original Poster
Rep: Reputation: 40
Quote:
Originally Posted by paulsm4 View Post
Java is much, more more than just applets.

Frankly, if you're interested in Java, why not download a copy of NetBeans (http://java.sun.com) or Eclipse (http://www.eclipse.org) and just learn Java - completely independent of trying to run applets in web browsers.

I think you'll learn more, learn faster ... and be much happier.

IMHO .. PSM
Thank’s, Paulsm4. I have done that. I started out going over the tutorials a couple of months ago. About a month ago I downloaded and installed Netbeans which I’m using now for my studies.

I’m reading lots going over lot’s of links that is suggested by many people. At the same time I’m also writing code to help me get the gist of some things that have some problems in clicking.

It’s coming together. …Kind of slow, probably for an old man. But I’m glad for the availability of the community to share in helping some to clearup some of the gaps that naturally happens in self studies.

Thanks. Anyone not using Netbeans or Eclipse would really be losing out in a lot of potential. I’m familiar with the popularity of Eclipse though I haven’t used it. But I’m amazed at the power and facility in Netbeans. It’s really amazing that Sun as provided it for free. The things I’ve been doing with the very costly Visual Studio, I’m sure I’ll eventually be able to do with Netbeans.

-- L. James

--
L. D. James
ljames@apollo3.com
www.apollo3.com/~ljames
 
Old 03-10-2010, 02:57 PM   #15
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,771

Rep: Reputation: 2070Reputation: 2070Reputation: 2070Reputation: 2070Reputation: 2070Reputation: 2070Reputation: 2070Reputation: 2070Reputation: 2070Reputation: 2070Reputation: 2070
Quote:
I thought I’d kill two birds at one time.
It's probably going to a lot easier and maybe even faster to tackle one bird at a time.

Quote:
The code works, but the concept isn’t quite right.
Yeah, I'm still having trouble understanding what you're after.

Code:
import javax.swing.JApplet;
import javax.swing.JLabel;

public class CallingClass extends JApplet {
    
    JLabel printToWeb;
    
    public void init() {
        printToWeb = new JLabel();
        add(printToWeb);
    }
    
    public void start() {
        printToWeb.setText("this is a string");
    }
}
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Web code is already open - why not make it free as well LXer Syndicated Linux News 0 01-20-2010 10:30 AM
web browsers work once then stop working on some pgs like linuxmint.com rtfn Linux - Newbie 8 04-10-2009 08:00 AM
Good Code Examples JMJ_coder Programming 10 09-17-2007 07:05 PM
LXer: Adapt Web Apps to Work with Multiple Browsers LXer Syndicated Linux News 0 11-29-2006 06:54 AM
XML Code Examples FLLinux Programming 1 01-17-2006 01:21 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:50 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration