Problem with an Applet

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.applet.*;
public class TabbedPaneApplet extends Applet{
     public TabbedPaneApplet(){
        setLayout(new FlowLayout());
             // create JTabbedPane
          JTabbedPane tabbedPane = new JTabbedPane();
          JPanel panelOne = new JPanel();
          panelOne.setLayout( new GridLayout(3, 3, 3, 3) ); 
          panelOne.add( new JButton("1"));
          panelOne.add( new JButton("2"));
          panelOne.add( new JButton("3"));
          panelOne.add( new JButton("4"));
          panelOne.add( new JButton("5"));
          panelOne.add( new JButton("6"));
          panelOne.add( new JButton("7"));
          panelOne.add( new JButton("8"));
          panelOne.add( new JButton("9"));
          tabbedPane.addTab( "Tab One", null, panelOne, "First Panel" );
          // set up panel2 and add it to JTabbedPane
          JPanel panelTwo = new JPanel( new BorderLayout());
          JLabel dukeLabel = new JLabel();
          Icon duke = new ImageIcon( "duke.gif" );                       
          dukeLabel.setIcon( duke );                                   
          dukeLabel.setToolTipText( "Duke Sucks!" );               
          panelTwo.add( dukeLabel, BorderLayout.CENTER );
          tabbedPane.addTab( "Tab Two", null, panelTwo, "Second Panel" );
          // set up panel3 and add it to JTabbedPane
          JPanel panelThree = new JPanel( new BorderLayout());
          JLabel midtermLabel = new JLabel( "Don't forget the midterm in week 5.", SwingConstants.CENTER);
          panelThree.add( midtermLabel, BorderLayout.CENTER );
          tabbedPane.addTab( "Tab Three", null, panelThree, "Third Panel" );      
        add( tabbedPane );
        setSize(600,600);
          setVisible(true);     
     // Setup the GUI.
     public void init(){
          TabbedPaneApplet myApplet = new TabbedPaneApplet();
}The problem is that it will only work if i remove the icon. If i attempt to put in the icon, then the applet will fail to load. This does compile and run in full as a normal program, and it compiles as an applet. It just won't display as an applet if the icon code is in there. Any suggestions on why this might occur?
Thanks.

I was wrong the code is as i show you, please forgive me the problem is when you use the URL as a parameter
I fix it as you see in this little example.
import java.awt.*;
import java.applet.*;
import javax.swing.*;
import java.net.*;
public class Foo extends Applet {
     private JLabel label;
     private JPanel panel;
     private Image image;
     private Icon icon;
     public void init() {
          setSize(400, 400);
          setLayout(new GridLayout(1, 1));
          //copy you name of the image in the second parameter
          image = getImage(getDocumentBase(), "funnywindow.gif");
          icon = new ImageIcon(image);
          label = new JLabel(icon);
          label.setSize(300, 300);
          panel = new JPanel();
          panel.setSize(400, 400);
          panel.add(label);
          panel.setBorder(BorderFactory.createLineBorder(Color.black, 2));
          add(panel);
          setVisible(true);
}

Similar Messages

  • Problems with pacman applet, and advice on a gaming portfolio

    Hi
    I recently made a pacman applet, im having a few problems with it though, the first time the applet is run on a browser, the ghosts(represented by squares) often dont appear or if they do, they are stuck in walls, this never happens when i run offline on my computer. Is this because the very first time the applet is run, it doesnt load properly, but the second time some of the files are in the cache so it loads fully?
    Also everytime i refresh the browser the applet dissapears and is replaced with a blank space and a cross in the top left hand corner, does anyone know the reason for this?
    The applet can be found below, if you do decide to play it, please bear in mind what i have said, so it might not load correctly the first time, if this is the case please refresh, or close the broswer and reopen the link! Also you will need to click the applet for it to gain focus before you can move pacman - use the arrow keys the control pacman.
    http://www.renaissance-designs.co.uk/Satwant/java/pacman/
    Id also be very gratful for some advice - id like a change in career, ive always wanted to get into gaming, ive had some previous knowledge in java i made a programme that could generate its own poetry in java for my dissatation, but i still never had a huge amount of confidence, and so went into websites.
    BUT now i have decided to take the leap back into programming and give it a go, which is why ive made this game.
    I thought id make a portfolio and try and apply for a few gaming jobs. This applet took me two weeks to make and it was in my spare time, i am fully aware its not perfect, and it doesnt look great, but i would like to know what people think of it, also how many more games do you think i should make, before i apply for gaming jobs? Does anyone have any advice on what would make a good portfolio for a java gaming job?
    Thanks alot, i look forward to what you think of the game, and your advice!
    SSKenth

    sskenth wrote:
    Thanks for getting back to me with that information, i didnt know you could see that information with just a simple right click!
    But im afraid that doesnt really help me solve the problem, im not sure what all of that information means! :SI have very little experience with applets, but I can tell you what I would do to debug this (forgive me if you already know this stuff).
    Look at the stack trace you get in the Java Console that I posted earlier. Each line contains a method that was called from the method on the previous line. So, java.lang.Thread.run() called sun.applet.AppletPanel.run(), which called Room.init(), etc. Look at the topmost line whose method is something you wrote, not something in the standard Java libraries. In your case it looks like PaintSurface.java (specifically, line 22). Look at what line 22 of PaintSurface.java is doing, it's calling Thread.start(). If you check out the Javadoc for Thread.start(), it says IllegalThreadStateException gets thrown if you call start() on a thread that has already started. So that's your problem. Without looking at your code, I'd assume you want to stop your thread in your applet's destroy() override, and instead of reusing it, create a new one each time init() is called.
    Ill try and look into, thanks again though, it gives me somthing to work with :D
    Btw when you first ran the applet, did all the ghosts(3) load up correctly?Unfortunately, no. The first time I ran it, there was only 1 ghost (or maybe all 3 overlapping each other?) at the top of the screen, and they never moved. Refreshing once made the game play as I think you want it to. Refreshing a third time gave the dreaded red X.
    ...oh and just out of curiosity,,, did u have fun playing the game :DSure did.

  • [Solved]Problem with deskbar-applet

    Hi to all, i'm having  annoying problems with the deskbar-applet in gnome. I've installed it with pacman and no error occurred during installation but I can't perform any search on the web through the search-engine of firefox. They don't appear in action's list at all. And i don't manage to use the deksbar-applet with tracker. I compiled tracker from abs with the option --enable-deskbar-applet=auto. and copied tracker-handler.py and tracker-handler-static.py  in the .gnome2/deskbar-applet/modules-2.20-compatible/ directory. Any advice??
    Thanks
    Solved. I had to copy tracker-module.py in that directory. Bye
    Last edited by oportec (2007-12-14 16:35:28)

    Thank you, headkase, you were right about it! Removing "ck-launch-session" solved my problems. I also removed "dbus-launch" because I didn't have it there originally, I had added "dbus-launch" to exec line just today as I had read somewhere that it might help (it didn't)...
    So, I'm going with "exec gnome-session" and everything works, thanks.
    //Edit: Admin can mark this as "[SOLVED]"
    Last edited by mino.sk (2012-06-22 20:22:39)

  • Problems with Java Applets

    Ever since upgrading to 10.5.2 I have been having trouble with sites with java applets. I like to play bridge on Pogo, but sometimes the game room will not open and at other times I get messages advising me to check the URL or go back to home page. I have tried emptying the cache, repairing permissions and a few other tips I have seen on this forum, but the problem persists.

    I decided to take a look, but the Bridge program requires a signup. Not interested, but the free Poppit game plays fine as a guest on my machine on both Safari 3.1 and FireFox 3.0b4.
    With FireFox I'm running AdBlock Plus, which can create problems with some sites, but the games loaded and played.
    Based on this, I'd check the time of day you are trying to use their site and see if there are more problems with certain times.

  • Changes in security from 7 update 45 to 7 update 51 and problems with Java applet

    Hello,
    After the update (from 7 update 45) to version 7 update 51 we've gotten some problems with a Java Applet as it won't run.
    When changing security settings to "medium" it works, but it would not run under the default "high" setting. This lead me to update the manifest file as follows:
    Manifest-Version: 1.0
    Trusted-Only: true
    Application-Name: MyApplet
    Permissions: all-permissions
    Caller-Allowable-Codebase: www.MySite.com
    In addition to this, I added the <param> tag in the HTML page.
    <applet name="MyApplet" code="MyApplet" archive="MyApplet.jar">
       <param name="permissions" value="all-permissions" />
    </applet>
    The applet is digitally signed with a certificated issued by Verisign.
    It now runs on my system. But I noticed that it also runs if I switch the security setting back to "high", which doesn't make any sense to me.
    I've tried another computer and to the same thing there. Would not run. I switched to "medium" and and the applet worked. Switched back to "high" and it still works.
    I've tried this in both Google Chorme and Internet Explorer 11.
    On a third computer it won't run at all, getting a different error message than on the other two, but still related to permissions/security.
    The console log message is:
            "liveconnect: Security Exception: JavaScript from http://MySite.comn/MyPage.html attempted to access a resource it has no rights to."
    Any ideas what I'm missing or what I need to change to get this beast to run everywhere.

    I tried changing the Caller-Allowable-Codebase to not include "www." and it started giving the the same error message as for the third machine in the test.
    So, I changed Caller-Allowable-Codebase to "*" which made it work on all machines.
    I don't quite understand why it acts differently on different machines, if it's ok with www.MySite.com on one of the the machines, it should be OK on all no?
    I don't see a problem with letting it be "*" but it would be nice to understand what's going on.

  • Repaint problems with an applet under Netscape 4.75

    Hello,
    I'm currently working on an applet created with VisualAge for Java, running under the standard Netscape 4.75 JVM, with Windows NT4.
    I am experiencing problems with AWT components which randomly disappear, especially Labels and sometimes Panels. When I drag a window over the missing label and then drag it back, the label appears.
    I have tried a lot of combinations with the repaint(), paint(), paintAll() and paintComponents() methods, but it has not been efficient for the moment. Introducing lots of repaint() calls on the concerned labels is even worse.
    Is there a known bug in the Netscape 4.75 JVM concerning this problem ? Do you have an idea of what can be done to solve this problem ? Changing the JVM is not an option that can be chosen. Netscape 4.75 has been defined as the only browser for the whole project.
    Thanks for your help !
    Kevin

    Well, I finally solved this problem.
    For your information, the JVM included in Netscape 4.75 running under NT4 does not like having AWT labels with either Background or Foreground not initialised. If any of these 2 properties is not defined, it could sometimes occur that the JVM can't display the label.

  • Problem with running applets

    When I try to run an applet on HTML page i only get a gray screen which shows nothing.
    When i try to use appletviewer it always says:
    I/O exception while reading: D:\ClickMe (The system can
    not find the file specified)
    (ClickMe is an applet)
    When I run an applet on some website it works, but when I upload one and open it through an HTML page it stiil shows a gray screen with nothing on it(maybe I have a problem with my compiler).
    I use "SUN ONE STUDIO 4 update 1" (j2sdk1.4.1 came along with it)
    I'm under WINXP HOME EDITION and I've downloaded the letest "service pack 1" from windows update center.
    Thanks in advance to all the helpers!

    I had the same problem once. Try if it works with Netscape. If it does, then you are having the same problem as I had.
    The solution:
    compile the applet with "javac -target 1.1 *.java"
    I dont know why it work, but it does.

  • Problems with running Applet through HTML

    I am currently having problems with running my file through the HTML. For some reason when I open it in the browser it keeps saying Error. I am programming in NetBeans.
    The code I am using is:
    <html>
    <head>
    <title></title>
    </head>
    <body>
    <applet code=”CarApplet.class” codebase="RedCarApplet.jar" width=690 height=300></applet>
    </body>
    </html>

    Heres the error message, I see that it cannot find the class I have stated above. Any solutions?
    My class is in the 'build' folder but, the HTML file is in the 'src' folder. Now my applet contains a 'jar' file, do I need to add that to the HTML code?
    load: class ‚Ä?TunerApplet.class‚Ä? not found.
    java.lang.ClassNotFoundException: ‚Ä?TunerApplet.class‚Ä?
         at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
         at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
         at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
         at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at sun.plugin2.applet.Plugin2ClassLoader.loadCode(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.io.FileNotFoundException: C:\Users\*****\*******\NetBeansProjects\RadioApplet\src\‚Ä?TunerApplet\class‚Ä?.class (The system cannot find the path specified)
         at java.io.FileInputStream.open(Native Method)
         at java.io.FileInputStream.<init>(Unknown Source)
         at java.io.FileInputStream.<init>(Unknown Source)
         at sun.net.www.protocol.file.FileURLConnection.connect(Unknown Source)
         at sun.net.www.protocol.file.FileURLConnection.getInputStream(Unknown Source)
         at sun.plugin2.applet.Applet2ClassLoader.getBytes(Unknown Source)
         at sun.plugin2.applet.Applet2ClassLoader.access$000(Unknown Source)
         at sun.plugin2.applet.Applet2ClassLoader$1.run(Unknown Source)
         at java.security.AccessController.doPrivileged(Native Method)
         ... 9 more
    Exception: java.lang.ClassNotFoundException: ”TunerApplet.class”

  • Problem with Draggable Applet in JavaFX Samples

    I am looking at JavaFX Samples which run as Draggable Applets - for example, DisplayShelf and EffectsPlayground. I ran into a problem while running these samples from Netbeans 6.5 IDE. It seems that there is a problem with the logic in this line of code in Main.fx:
    var inBrowser = "true".equals(FX.getArgument("isApplet") as String);I found that this expression is evaluating to false because the "isApplet" argument is null, such that the drag and drop installation is not available. When toggling the Properties > Application > Draggable Applet checkbox, I found that the html page generated to launch the applet (e.g. DisplayShelf/dist/DisplayShelf.html) would simply add/remove draggable argument:
    <script>
        javafx(
                  archive: "DisplayShelf.jar",
                  *draggable: true,*
                  width: 600,
                  height: 300,
                  code: "displayshelf.Main",
                  name: "DisplayShelf"
    </script>Given this, shouldn't the Samples actually have logic as follows:
    var inBrowser = "true".equals(FX.getArgument("draggable") as String);

    Thanks, this works and is probably the better solution, as the draggable argument can be set even when not running from browser. Thanks!
    But my concern is that the code in the draggable app Samples which come with Netbeans IDE do not work correctly, because FX.getArgument("isApplet") returns null. Would this be something to file a bug for? Seems like other newbies like me would get confused when the samples don't work....

  • Problem with URL - Applet

    hi, i have a little problem running my applet. it's supposed to get a file from the WWW and display its contents as a string inside a JTextArea. the file on the web is a simple .txt containing little text, say one sentence, its irrelevant here. the file is read in inside a different class that the applet calls. however, there seems to be a problem with that - maybe it has something to do with Applet restrictions. anyway. here goes:
    the applet (i removed all irrelevant applet construction objects like buttons etc) -
    public class Applet1 extends JApplet {
    private JTextArea sisestaJutt;
    private String juttVeebist;
    public void init() {
    URLReader veebist = new URLReader();
    try {
    juttVeebist.equals( veebist.reader());
    catch(Exception e) {
    Container sisu = new Container();
    sisestaJutt = new JTextArea(juttVeebist);
    sisu = getContentPane();
    sisu.setLayout( new BorderLayout() );
    sisestaJutt.setBorder(brdr);
    sisu.add(sisestaJutt, BorderLayout.CENTER);
    the called class (& method) -
    public class URLReader {
    public static String reader()
    throws Exception {
    URL jjstreet = new URL("http://www.anydomain.com/file.txt");
    BufferedReader input = new BufferedReader(
    new InputStreamReader(
    jjstreet.openStream()));
    String inputLine = input.readLine();
    input.close();
    return inputLine;

    thank you everyone for information, it's getting clearer to me already. sounds like signing would do the trick.
    however, i first tried this thing on a localhost - thats the server-program and applet at the same place, even writing in the same dir... but the text ment to be inside the textarea is still from a URL, so i guess applet has trouble getting input from the www then...
    anyway, JFrame is working very good + it has the comfortable command line feel in it =)
    ty all.

  • Problems with java applets freezing.

    Okay, this is an extemely rare java problem (from what I know), and I have worked for months to fix it and nothing has worked so far.
    This is my problem: Whenever I use java applets, the screen freezes (still able to move mouse around) for about 10-20 seconds about twice a minute to once in ten minutes. This can make me very angry if I am in the middle of a game. I am POSITIVE it isn't my internet, I have Cable internet, one of the fastest. And after it is done freezing the applet runs perfectly, until it freezes again.
    PLEASE HELP ME! Thanks in advance, Zach.

    I decided to take a look, but the Bridge program requires a signup. Not interested, but the free Poppit game plays fine as a guest on my machine on both Safari 3.1 and FireFox 3.0b4.
    With FireFox I'm running AdBlock Plus, which can create problems with some sites, but the games loaded and played.
    Based on this, I'd check the time of day you are trying to use their site and see if there are more problems with certain times.

  • Security Problems with Signed Applet

    Hello All,
    I need help with signed applets.
    I have an applet pkged in a jar that uses other jars. I have signed the jar containing applet and all the other jars being used. However, when I try to run the applet in IE 6.0.xx, I get the following error
    java.lang.ExceptionInInitializerError
         at aaa.aaa.somemethod(xxx.java:192)
         at aaa.aaa.aaa.access$000(xxx.java:27)
         at aaa.aaa.aaa.$1.run(xxx.java:467)
    Caused by: java.security.AccessControlException: access denied (java.util.PropertyPermission user.home read)
         at java.security.AccessControlContext.checkPermission(Unknown Source)
         at java.security.AccessController.checkPermission(Unknown Source)
         at java.lang.SecurityManager.checkPermission(Unknown Source)
         at java.lang.SecurityManager.checkPropertyAccess(Unknown Source)
         at java.lang.System.getProperty(Unknown Source)
         ... 3 moreMy application is using Java 1.4.2.xx.
    Any help or pointers would be greatly appreciated.
    Thanks.

    Thanks harmmeijer and mjparme for your responses.
    I made some changes to my application and it does not now require the system property information. But now I am getting another exception related to class loader.
    I made the changes to the console as suggested by harmmeijer, and here is the stack trace. Also, I am not using any JavaScript explicitly.
    Registered modality listener
    Invoking JS method: document
    Invoking JS method: URL
    Referencing classloader: sun.plugin.ClassLoaderInfo@e0a386, refcount=1
    Loading applet ...
    Initializing applet ...
    Starting applet ...
    java.security.AccessControlException: access denied (java.lang.RuntimePermission getClassLoader)
         at java.security.AccessControlContext.checkPermission(Unknown Source)
         at java.security.AccessController.checkPermission(Unknown Source)
         at java.lang.SecurityManager.checkPermission(Unknown Source)
         at java.lang.ClassLoader.getSystemClassLoader(Unknown Source)
         at xxx.xxx.a...<init>(a.java:39)
         at  xxx.xxx.b...<init>(b.java:42)
         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
         at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
         at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
         at java.lang.reflect.Constructor.newInstance(Unknown Source)
         at java.lang.Class.newInstance0(Unknown Source)
         at java.lang.Class.newInstance(Unknown Source)
         at sun.applet.AppletPanel.createApplet(Unknown Source)
         at sun.plugin.AppletViewer.createApplet(Unknown Source)
         at sun.applet.AppletPanel.runLoader(Unknown Source)
         at sun.applet.AppletPanel.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    Exception: java.security.AccessControlException: access denied (java.lang.RuntimePermission getClassLoader)
    java.security.AccessControlException: access denied (java.lang.RuntimePermission getClassLoader)
         at java.security.AccessControlContext.checkPermission(Unknown Source)
         at java.security.AccessController.checkPermission(Unknown Source)
         at java.lang.SecurityManager.checkPermission(Unknown Source)
         at java.lang.ClassLoader.getSystemClassLoader(Unknown Source)
         at xxx.xxx.a...ToolBus.<init>(a.java:39)
         at xxx.xxx.b....<init>(b.java:42)
         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
         at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
         at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
         at java.lang.reflect.Constructor.newInstance(Unknown Source)
         at java.lang.Class.newInstance0(Unknown Source)
         at java.lang.Class.newInstance(Unknown Source)
         at sun.applet.AppletPanel.createApplet(Unknown Source)
         at sun.plugin.AppletViewer.createApplet(Unknown Source)
         at sun.applet.AppletPanel.runLoader(Unknown Source)
         at sun.applet.AppletPanel.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    Modality pushed
    Modality poppedmjparme as to your second point, the action is taking place in the same jar only. No other jar is involved at the stage where I am getting exception.
    Thankyou again and will appreciate your help.
    AC

  • Problems with my Applets

    My Applets keep on failing to open up outside of Netbeans. What layout do I need to just be able to click on the JAR file and it will pop up? Also what layout does IE accept?

    Are you extending Applet or JApplet? What does your HTML look like? Are you getting any error messages? Are you trying to work with files?
    Please in future feel more than free to share helpful information with us about what "not working" actually means.
    Here are some examples:
    - all is see where my applet should be is a red x
    - my browser crashed trying to show the page with the applet on it
    - when i started my applet a rift was torn in the space time continuum and my computer was sucked into the vortex
    You know. Details.

  • Problems with running applet from Java Tutorial

    Hello
    I'd like to compile applet from Lesson Applets, trail: Deployment, title of lesson: A Simple Network Client Applet. But at the beginning of the source code is written that it will work only with: JavaSE 5 version.
    * SwingWorker can be downloaded at:
    * https://swingworker.dev.java.net/
    * SwingWorker must be downloaded for JavaSE 5, but will be included
    * in JavaSE 6.
    Well, does anyone know about applet doing the same thing which would work in older versions of JDK?. Do I necessarily have to install JavaSE6?. I have J2EE 1.4SDK and I run into errors compiling this example.
    Cheers
    Message was edited by:
    macmacmac

    I've got another applet which was written for version 1.1 of Java. It compiles but when I run it, instead of letters of quote I get rectangles, positioned one next to the other. So I can't read the quote. What's wrong with this applet?. Here's the code of it:
    * 1.1 version.
    import java.applet.Applet;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import java.net.*;
    import java.util.*;
    public class QuoteClientApplet3 extends Applet
    implements ActionListener {
    boolean DEBUG = false;
    InetAddress address;
    TextField portField;
    Label display;
    DatagramSocket socket;
    public void init() {
    //Initialize networking stuff.
    String host = getCodeBase().getHost();
    try {
    address = InetAddress.getByName(host);
    } catch (UnknownHostException e) {
    System.out.println("Couldn't get Internet address: Unknown host");
    // What should we do?
    try {
    socket = new DatagramSocket();
    } catch (IOException e) {
    System.out.println("Couldn't create new DatagramSocket");
    return;
    //Set up the UI.
    GridBagLayout gridBag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    setLayout(gridBag);
    Label l1 = new Label("Quote of the Moment:", Label.CENTER);
    c.anchor = GridBagConstraints.SOUTH;
    c.gridwidth = GridBagConstraints.REMAINDER;
    gridBag.setConstraints(l1, c);
    add(l1);
    display = new Label("(no quote received yet)", Label.CENTER);
    c.anchor = GridBagConstraints.NORTH;
    c.weightx = 1.0;
    c.fill = GridBagConstraints.HORIZONTAL;
    gridBag.setConstraints(display, c);
    add(display);
    Label l2 = new Label("Enter the port (on host " + host
    + ") to send the request to:",
    Label.RIGHT);
    c.anchor = GridBagConstraints.SOUTH;
    c.gridwidth = 1;
    c.weightx = 0.0;
    c.weighty = 1.0;
    c.fill = GridBagConstraints.NONE;
    gridBag.setConstraints(l2, c);
    add(l2);
    portField = new TextField(6);
    gridBag.setConstraints(portField, c);
    add(portField);
    Button button = new Button("Send");
    gridBag.setConstraints(button, c);
    add(button);
    portField.addActionListener(this);
    button.addActionListener(this);
    public Insets getInsets() {
    return new Insets(4,4,5,5);
    public void paint(Graphics g) {
    Dimension d = getSize();
    Color bg = getBackground();
    g.setColor(bg);
    g.draw3DRect(0, 0, d.width - 1, d.height - 1, true);
    g.draw3DRect(3, 3, d.width - 7, d.height - 7, false);
    void doIt(int port) {
    DatagramPacket packet;
    byte[] sendBuf = new byte[256];
    packet = new DatagramPacket(sendBuf, 256, address, port);
    try { // send request
    if (DEBUG) {
    System.out.println("Applet about to send packet to address "
    + address + " at port " + port);
    socket.send(packet);
    if (DEBUG) {
    System.out.println("Applet sent packet.");
    } catch (IOException e) {
    System.out.println("Applet socket.send failed:");
    e.printStackTrace();
    return;
    packet = new DatagramPacket(sendBuf, 256);
    try { // get response
    if (DEBUG) {
    System.out.println("Applet about to call socket.receive().");
    socket.receive(packet);
    if (DEBUG) {
    System.out.println("Applet returned from socket.receive().");
    } catch (IOException e) {
    System.out.println("Applet socket.receive failed:");
    e.printStackTrace();
    return;
    String received = new String(packet.getData());
    if (DEBUG) {
    System.out.println("Quote of the Moment: " + received);
    display.setText(received);
    public void actionPerformed(ActionEvent event) {
    int port;
    try {
    port = Integer.parseInt(portField.getText());
    doIt(port);
    } catch (NumberFormatException e) {
    //No integer entered. Should warn the user.
    }

  • Problem with Java applets

    Hi All
    I am very very new to Applets, and i am having a problem. Basically i need to create an applet with a GUI that creates a file and writes to it. I found this web pages and modified the code slightly so that it did what i needed:
    http://www.captain.at/programming/java/
    With the help of a certificate i was able to do it...however, since i have created a GUI that when compiled creates a copy of the class name and puts $1, $2 etc after it. The security manager then throws up an error because these class files arent signed! Does anyone know how to get round this? Are these $ copies created because i am using swing aswell as AWT?
    Any help would be really appreciated

    The "$..." extension is used for inner classes. Where the inner class name is a number, it has been generated from an anonymous class.
    An anonymous class is generated with code such as, for example:
    SwingUtilities.invokeLater(new Runnable() {
            public void run()
                    foo();
    });You should get into the habit of packaging your classpath into a Jar and then signing that, rather than individual files.

  • Problem with signed applet

    HI All,
    I am writing a small applet to draw a line graph by setting the parameters from the html pages .It came up beutifully .There are two problems here .
    1)When i try to print the applet it prints only black coloroued rectangle in place of applet(graph) .I read lot of articles only to find out that the applet need to be signed for printed .I tried all ways and means but could not succedd in printing an applet .
    2)When i try to access the applet from other computer with out copying it says that applet can not be acceessed due to security failure .It throws exception.
    I need your help on how to sign applets to access from other computer and also how to print applet content .
    Can any one help me on this
    Thanks in advance .

    i am not sure of that , but having experience with drawing images ,graphs and the like and with no experience in printing, i can share u my experience.
    using setBackground(Color.white) of the applet/panel wouldnot work since i believe it is something that is got to do with the graphics class .U have to draw a full white rectangle as a background before u start drawing lines.
    like
    g.setColor(color.white);
    g.drawfullrect(0,0,width,height); /// draw a white background
    g.setColot(Color.black);
    g.drawline(0,0);
    etc.....
    Have fun dude.

Maybe you are looking for

  • Scanning into a MacBook Pro

    How can I scan documents into my MacBook Pro. I am using OS X 10.9.2. I need to scan documents to email to someone and I can't find a way to do that. I normally just scan into my Adobe Photoshop Elements and make a jpeg. But there does not seem to be

  • Dynamic table & More No of buttons addition to the form...

    Hi Friends, I have following issues with my form in webdynpro abap. 1. I have created a main node called ZKPS_TEST and under that I have included three nodes and two attributes.     the three nodes are as follows: TIME_DATA With cardinality 1..1 -->

  • Updating my Apple TV Software

    I am frustrated. Unable to update the software on my Apple TV. The progress bar never moves and the little circle goes round and round. I have tried restart several times and it doesn't make a difference.

  • Selecting multiple lines in a sales order

    Hello documentation says we should be able to select multiple lines in a sales order (for example to cancel them or remove them). Yet we cannot select more than one. Shift and Ctrl do not seem to work. Any idea why this does not work ? We are running

  • Managing videos in Aperture

    I've been importing videos from my PAS's and iPhone into Aperture. I'm looking for some feedback as to the benefits of allowing Aperture to manage those videos. It seems as though when I try to upload a video from Aperture to my MobileMe Gallery, the