Different ways to setup applets... what's best?

Alright. I need some help deciding how to setup an applet. I'm a high school student and I'm going to be in a competition on Saturday that will be using Java applets. I've been trying to get my hands on as much info about it as I can, but I've seen so many different ways of displaying things on an applet that I'm not sure what to do anymore.
So here's the deal. In a book I have, they set up applets like this:
import javax.swing.*;
public class Example extends JApplet
   public void init()
      getContentPane().add(new ExamplePanel ());
      set size (300, 300)
}And the other class:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class ExamplePanel extends JPanel
   private vars
   public ExamplePanel ()
      set up listeners and set background
   public void paintComponent (Graphics page)
      super.paintComponent (page);
      paint stuff
   event methods
}I'm pretty sure this works fine, but while on the Java website, looking for examples, I noticed that sun sets up applets like this:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
public class Example extends JPanel implements listener interfaces
   protected and private vars
   public Example ()
      set up panels, labels, basically any JComponent stuff
      create listeners
      use add(...) to put stuff on applet
   event methods
   private static void createAndShowGUI()
        JFrame frame = new JFrame ("Example");
        frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
        JComponent newContentPane = new Example();
        newContentPane.setOpaque (true);
        frame.setContentPane (newContentPane);
        frame.pack();
        frame.setVisible(true);
    public static void main()
        javax.swing.SwingUtilities.invokeLater(new Runnable()
            public void run()
                createAndShowGUI();
}I don't know which way is better, but we don't have much time so I need something that's easy. The problem with the second one is that I don't know how to draw shapes on the second one and I might need to do that. I tried using paintComponent in it and things just got screwy. If anyone knows of a better way, please let me know. And since that one was developed directly from Sun, I'm guessing it's more efficient, so I would like to use that one if I can just learn how to use it as easily as the first.
Also, if anyone knows a completely different way to do this that's better, please let me know.

The second Example class shows an important issue: swing is not thread safe, and thus all GUI operations, including creating the GUI itself, must be done in the event dispatch thread. Read more about it at http://java.sun.com/docs/books/tutorial/uiswing/misc/threads.html#EDT.
The second class Example does also not seem to be an applet, that is why main() is used instead of init(). But even in init() you are not guaranteed that the current thread is the EDT - it is choosen by the browser you are using - and you should thus use invokeLater() there as well.
Appart from that, a component should not care if it is displayed in an applet or in an application.

Similar Messages

  • 2 different ways to setup IPSec ?

    Hello,
    I am currently trying to setup IPSec tunnel between a pfSense router and a Windows Server 2008R2 (The windows server is located behind a router with NAT enable).
    First of all, I found two different ways to configure IPsec on Windows :
    1) Through Windows Firewall with advanced Security
    2) Through IPSec snap-in into MMC.
    Which one should I use ?
    Well, anyhow I got some troubles to negotiate  phase1. By analyzing packets, it turns out that Windows server always return a NO_PROPOSAL_CHOSEN error code.
    My settings for phase1 (on both sides):
    Authentication  method: PSK
    Negotiation mode: main
    Encryption: 3DES
    Hash: SHA1
    DH Key group : 2 (1024)
    Lifetime: 28800
    (NAT-T Enabled on pfSense)
    Finally, I noticed that it is possible to define peer identifiers on pfSense. Is it possible to do the same on the windows server or does it automatically use the IP addresses as peer identifiers ?
    Any help would be greatly appreciated.
    Best regards,

    Hi bibibubu1,
    The 2008r2 can’t establish an IPsec tunnel behind NAT-T have a known issue, please confirm the following KB meet your environment then install the hotfix. Another possible
    is you have select the matching Encryption schemes.
    You cannot establish an IPsec tunnel to a computer that is running Windows 7 or Windows Server 2008 R2 through a NAT device
    http://support.microsoft.com/kb/2523881
    I’m glad to be of help to you!
    We
    are trying to better understand customer views on social support experience, so your participation in this
    interview project would be greatly appreciated if you have time.
    Thanks for helping make community forums a great place.

  • Different way to aggregate Essbase: Cannot aggregate to parent level

    Hi,
    I used to use the following statement in BR to aggregate dimensions:
    FIX("Segment Allocation Base")
    FIX(@IDESCENDANTS("YearTotal"))
    @IDESCENDANTS("Total Company"); /*Total Company is member of spare dimension: Market Segments */
    ENDFIX
    ENDFIX
    The tree structure is like this:
    Market Segments (Never Share)
    |__ No Market Segments (Never Share)
    |__ Total Company (Never Share)
    |__Total Market Segments (Dynamic Calc)
    |__SC (Store) -> Level 0
    |__SE (Store) -> Level 0
    1. However, I found that the parent level cannot be aggregated. After I enter a value for Total Company (I think I am creating a block for Total Company), the above BR works.
    2. If I change the BR to the following statement, it works. I don't need to create the block first.
    FIX("Segment Allocation Base")
    FIX(@IDESCENDANTS("YearTotal"))
    AGG("Market Segments");
    ENDFIX
    ENDFIX
    Any gurus knows the difference about the above 2 different ways to aggregate? What's wrong with the first one?
    Thank you in advance.
    Casper

    Unless you wrote the first statement wrong. The reason the first one doesn't calculate is because it does absolutely nothing
    @idescendant is a declaration not a calculation
    Definition of @idescendant is: Returns the specified member and either (1) all descendants of the specified member or (2) all descendants down to a specified generation or level. You can use this member set function as a parameter of another function, where that parameter is a list of members.
    AGG is a calculation.
    So unless I'm reading it wrong you declare the children of Total Company and then do absolutely nothing. Therefore it has nothing to do with dense/sparse or blocks existing or not.

  • What's the best way to setup a media server/central storage for all of my?

    I was wondering what the best way to achieve a central media server for all my iTunes content + iPhoto's, calendar syncing and contact sharing is? This is what I currently have:
    iMac 20" Aluminum + External HD Backup (kids)
    Macbook Black (wife)
    Macbook Pro 15" (me)
    Airport Extreme 802.11n (obvious)
    TimeCapsule 1TB (wifi backup for wife/me)
    I would like to replace my PC in my office with a brand new Mac Pro Nehalem 8-Core, 8GB Ram, and 4TB, and replace my PC laptop in my living room attached to my tv, with an Apple TV.
    I want to centralize all our Photos from vacations, etc. Music, videos, movies, that are currently split up over wife's macbook, kids imac and my macbook pro onto my soon to be purchased Mac Pro.
    I want to be able to stream everything from my living room via Apple TV for when guests come over, dinner parties, etc. (plus I love apple and it keeps things clean)
    I'm currently using MobileMe to sync all of our Calendars and Contacts with my main account, which is great, but MobileMe doesn't sync to family members accounts =
    What would I need to do to centralize all this onto my future Mac Pro so that everyone has access all the time when they are home and the key here is, modify/update/change from their machines and sync it back/update it on the Mac Pro.
    Also, I'm hoping Snow Leopard has some changes to iTunes to make this a little more possible, since we're right around the corner from this release. I don't really want to spend an additional $900+ on Snow Leopard Server to have to achieve these results, but if it makes it easier, and does the job, then I guess I might. This is all speculation though, since it's not out yet. I'd like to get this all sorted and setup within the next month.
    I was considering a Drobo, they say they can throw up iTunes Server but, I appreciate everyone for reading this, and taking the time to respond!
    Thanks!
    Message was edited

    I'm in the process of setting up a smaller (and cheaper) but somewhat similar setup to what you want to do, so maybe one example might help point you in the right direction. My needs consist of a centralized location for data storage, which will include iPhoto libraries (I keep two separate ones), iTunes (which I also want served to the home theater system), something other than my laptop to play internet videos and downloaded content on my TV, all with ideally the lowest cost and energy use possible.
    My solution was the new Mini with a FW800 external drive as the server/media hub and Airport gigabit as the network hub (it also handles the backup drive).
    FW800 is fast enough to saturate a gigabit ethernet link, so I don't consider that much of a bottleneck. The Mini then has iTunes running at all times with its centralized library on it; it is hooked to the home theater via HDMI-DVI video and optical audio, so it can play music and also handle videos when desired; Front Row with the Apple remote is close enough to an AppleTV that I think it handles that well, and it's more full-featured than an AppleTV. It can further be used to display photos/slideshows/whatever on the TV for guests or such, or to surf from the couch with a wireless mouse/keyboard. You can also toss in an EyeTV for $150 and use that as a DVR if you feel like it.
    When I want to edit photos or such on my desktop, the gigabit link is fast enough that I can run iPhoto without noticing any significant slowdown. Its also usable over wireless, though I have a dangling extra network cable to plug into a laptop for full gigabit speed if need be. iTunes, of course, shares its library, which can be played from any of the computers in the house if so desired (iPhoto can do that too if you just want to display).
    If I REALLY wanted top speed (though I've even done video editing in iMovie via ethernet without issue), I could use a third party synch app (I like Sync) to mirror any of the content from the mini server to a local drive; this works fine with anything but multi-way synching, such as address books being modified in different locations. I'd probably try to set up one of those Mobile Me clone systems or use a 3rd party app if I needed to do that.
    Again, maybe this isn't powerful enough or "synched" enough in terms of local storage for your taste, but the advantage is that a Mini uses a minute fraction of the power of a Mac Pro, so you're saving a lot on electricity if the computer will be powered up at all times as a server, and it's also a lot more full-featured as a home theater media hub than an AppleTV. And, heck, the thing is about as well equipped as my old top-of-the-line G5 tower for a 5th the cost and 1/15th the power and noise.

  • What is the best way to setup premiere sequence for export when mixing 24fps and 23.976fps for final

    What is the best way to setup a premiere sequence for export when mixing 24fps (CG) and 23.976fps (live action) for final output at 23.976 (vimeo and such).
    Right now my sequence is at 24fps, and when I export to 23.976, my dialogues seem to shift.
    Should I set my sequence at 23.976fps instead of 24fps?
    Thanks in advance for the help, and sincere apologies if this is a noob question.
    David

    That makes it easy.  Remove the CGs from the project.  Go to Edit>Preferences>Media... and set the Indeterminate Media Timebase to 23.976.  Then when you import the image sequence, PP will assign it the correct frame rate.
    Edit in a 23.976 sequence.

  • Best way for an applet to contact EJB ?

    Which is the best way for an applet to connect EJB?
    1) Applet --> servlet --> EJB
    2) Applet --> EJB
    What is the pros and cons of both approach?
    Thanks

    Hi there,
    This is a tricky question and it would be interesting to hear what others think.
    Probably the key factor is what is available to you in terms of communications between the EJB and the applet. If you are on an intranet then having the applet talk directly to the EJB looks favourable as you will almost certainly be able to use RMI/IIOP for communications between the applet and the EJB. If you are forced to use HTTP as the communications protocol then you can't talk directly from the applet to the EJB but there again talking to a Servlet from an applet throws up complications of it's own. In this case you should consider not using an applet at all and instead use a JSP page or pages to handle the presentation.
    There is another issue that you need to consider when the applet talks directly to the EJB. If the App server that contains the EJB is on a different system to the one that runs the Web Server you'll have to address some security issues and will have to either have local policy files for the systems running the applet or you'll have to sign the applet and have the clients trust it.
    Hope this helps
    Amanda
    Developer Technical Support
    Sun Microsystems
    http://www.sun.com/developers

  • Advice on best way to setup Disaster Recovery for SOA Suite 10.1.3.4

    Hi Everyone,
    I need some advice on the best way to setup Disaster Recovery for a SOA Suite 10.1.3.4 install deploying JSF/ADF OC4J applications.
    The way we are trying to do it at the moment is manually copy the "applications" and "applications-deployments" folders for the OC4J application on the production server, then compress and ship the files across to the DR application server nightly. (We don't require high availability).
    In the event of a disaster we then extract the files and copy to the OC4J instance (pre-created and configured) on the DR server. Unfortunately to date we haven't been able to reliably setup a DR application (seem to mostly get 404 errors etc), even though the OC4J application has its connection pool resolved to the DR database and is showing as "up" in the ASConsole.
    My question is, is there a more "native" way to do what we are trying to do. We do not have Enterprise version of SOA Suite or 11g database so any advanced recovery features are not an option. The setup is also stand alone, i.e. we are not using clustering or RAC etc.
    Any ideas would be really helpful.
    Thanks,
    Leigh.
    PS we are also running the production apps server with Oracle Application server 10g 10.1.2.3.0 as the HTTP apache server (with Forms, Reports and Discoverer deployed) and the SOA Suite 10.1.3 applications use the 10.1.2 HTTP server via the HTTP to AJP bridge. So the 10.1.3 OC4J instance is configured to use AJP on port range 12501 - 12600.

    For enterprise solutions, AS Guard would work.
    http://download.oracle.com/docs/cd/B25221_04/core.1013/b15977/disasrecov.htm#sthref303
    However, since advanced recovery options are not available (as you said), then what you are doing should not be too bad.
    AMN

  • What are the different ways to upload file data to SAP? Please help

    Hi Experts,
       I have to transfer huge file data (few lakhs records) to SAP business transaction. What are the different ways to do the same? I have heard of BDC and LSMW. But are there any more options?
    Which option is best suited for huge file data?
    Is LSMW an old technology and SAP will not support it any more?
    Kindly answer my queries at the earliest.
    I will be greatful to you if you can help me.
    Thanks
    Gopal

    for uplodig data to non sap we have 2 methodes
    i) if u know bapi u will use lasm
    2) bdc
    but u mentioned so many records isthere
    best thing is u will uplode all record sto al11 using XI interface
    then u have to write bdc / lsmw  program
    beter to go for lsmw before that u will find bapi
    if u will unable to find bapi
    u have to create bapi and use it in lasmw
    ofter that u have schedule the lsmw program as a bockground
    then u have to create a job for it
    and release from sm 37
    then u have to moniter through bd87
    if u want to go through i will help u.
    if it is usefull to u pls give points
    Saimedha

  • Wipe my hard drive clean except for the OS whats the best way?

    I need to wipe my hard drive clean except for the OS whats the best way?

    From Kappy (note: with this method, you will need to update to the present OS version using the appropriate Combo Update from Apple Downloads.)
    Boot from the OS X Installer Disc One that came with the computer. After the installer loads select your language and click on the Continue button. When the menu bar appears select Disk Utility from the Utilities (Installer menu if using Panther or Jaguar) menu. After DU loads select the startup volume from the left side list then click on the Erase tab. Set the format type to Mac OS Extended (Journaled) then click on the Options button. Select the one pass Zero Data option and click on the OK button. Then click on the Erase button.
    Note: You can skip the Zero Data option if you are not concerned about removing sensitive personal data from the hard drive. If you choose to skip this part of the process then it is possible for others to recover data from the hard drive. The Zero Data procedure will prevent others from getting access to your personal information.
    This process will take 30 minutes to several hours depending upon the size of the hard drive. After formatting has completed quit DU and return to the installer. Now complete the OS X installation. At the completion of the installation do not restart the computer. Instead just shut it off. The next user will be presented with the Setup Assistant when they turn on the computer just as it would if new out of the box.
    https://discussions.apple.com/message/12364050?messageID=12364050#12364050

  • I burned a playlist to a data CD using itunes 11 but what is best way to get it import it into another computer with itunes running?

    I burned a playlist to a data CD using itunes 11 but what is best way to get it import it into another computer with itunes running?  I get an "X" when trying to copy to the "automatically add to itunes" folder on the 2nd computer.

    ok... so i i just made sure all my music is all together in 1 folder and i am going to trash my old music folder that is in the itunes folder... and follow your directions - let itunes start w/new library and bring my music in. Well, last little hurdle/question. I noticed that the place where my itunes library is - on an external drive doesnt have much space left on it. The place where i gathered all my music together in order to start fresh - is a different external drive and has LOTS of free space on it.
    SO... i now would like to just keep all that freshly compiled clean music right where it is but in advanced preferences I want to point to that new folder on the drive that has so much more space. So... should i delete the old music then go into itunes with a blank library and change the folder in preferences - quit and go back in and then follow your steps to loading my music? If i change the setting of where itunes looks for the music - that doesn't wipe out the old stuff... it just mixes it all up together right? I dont want that!!
    i promise this is the last question - i would love to fix this problem tonight and just be DONE!
    Thanks in advance for your patience and knowledge!!
    Lisa

  • What are different ways to pass variables in a c# program?

    What are different ways to pass variables in a c# program?
    I was wondering if :
    var numbers = textBox1.Text.Split('
    .Select(int.Parse).ToArray();
    var min = numbers.Min();
    var max = numbers.Max();
    textBox2.Text = string.Format("min:
    {0} max: {1}", min, max);
    and
    private
    int[] numbers =
    new
    int[10];
     were considered passing variables and I am also interested in learning new ways.

    Hi Billst3r,
    Your examples would be considered creating variables or "instantiating" them, which basically means creating them in memory.  To pass variables, here is a brief example.
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    namespace ConsoleApplication1
    class Program
    static void Main(string[] args)
    // Declaring variables
    int num1 = 1;
    int num2 = 5;
    // Pass created variables to private method
    int answer1 = ComputeSum(num1, num2);
    // Print results
    Console.WriteLine(answer1);
    Console.ReadLine();
    private static int ComputeSum(int param1, int param2)
    // Return sum of 2 provided parameters
    return (param1 + param2);
    Best of luck.

  • What are the different ways of retrieving data from Oracle8i

    What are the different ways of retrieving data from Oracle8i
    into my HTML page ?
    Is it JDBC and ODBC ?
    Is there any other way ?
    null

    Methods I tried,
    Applet using SQLJ/JDBC with JDBC drivers thin or Oci8,
    Oracle Web Publishing Assistant,
    HTP/HTF PL/SQL packages (if you have OAS 4.0)
    Webserver Generator of Designer 2000 (if you have OAS 4.0)
    Arun (guest) wrote:
    : What are the different ways of retrieving data from Oracle8i
    : into my HTML page ?
    : Is it JDBC and ODBC ?
    : Is there any other way ?
    null

  • Best Way to setup a disaster Recovery site for a logical standby database

    I have a logical standby DB (L1DB) as a reporting db on the same machine as the primary (P1DB). We are planning on building a disaster recovery site with similar hardware and potentially have disk mirroring of atleast the redo log files.
    The DR site can hold an additional physical standby (S1DB) for the primary (P1DB). I am trying to understand what would be the best way to setup the Disaster Recovery site for the L1DB logical stdby. Ideally, when the disaster happens, and I no longer have P1DB and L1DB, I should be able to switch to S1DB as the new primary. But how do I setup to have a L2DB that takes the place of L1DB and has its contents and can be setup as a logical standby of S1DB?

    If you already setup one logical standby, then you know how it works, so not sure what question you are asking ?
    Personally I would setup L2DB as a standby of the original primary P1DB. Having downstream standby databases complicates things, and adds additional lag between primary transaction time and L2DB apply.

  • Best way to setup my AirPort Express

    HI - I have just purchased a Airport Express. There seems to be different setup options depending on whether you want to create a new network or use in client mode. I am not sure what the best option for me is......I am going to connect it to my Bang & Oulfsen system and just want to be able to stream music to it  using AirPlay on my iPad / iPhone. Will client mode achieve this?
    Many thanks

    Yes, as you are going to use the express to link as a client to existing network and connect to play music. Not as a main router or WAP.

  • Just bought macbook air; had macbook macbook with Tiger software. What is best way to upload photos to icloud on old computer without upgrading it's software? thanks.

    just bought a macbook air upgrading from old macbook with Tiger software; what is best way to take photos from old backbook to icloud so I can see them or download on the new air; Have an external harddrive backup. photo library is too large to transfer directly.thanks.

    Memory size has nothing to do with it. I can open my 60GB iPhoto library with only 8GB RAM. Perhaps you have an incompatible version of iPhoto under Tiger with iPhoto under ML.
    As to downloading different photos from iCloud, you would do the same if you ...
    * open iPhoto under Tiger
    * dump the photos individually in to a folder on your external hard drive
    * shut down everything on the old MacBook
    * connect the external hard drive to new MacBook
    * open iPhoto on new MacBook
    * import the photos in the folder on the external hard drive directly in to the new iPhoto
    IOW, you need not use iCloud (even if you could, which you cannot) to swap photos as you propose.
    If you are at a loss for space on your external hard drive for whatever reason (perhaps that external hard drive is a full Time Machine partition), I recommend that you buy another external hard drive just for your photos.
    JJW

Maybe you are looking for

  • Installed extensions, Safari now crashes

    I recently installed two Apple-approved extensions for Safari -- AdBlock Plus (an update -- I'd had this previously installed without problem) and Safari Restore. The next time I tried to open Safari, it instantly crashed, and now it consistently cra

  • Gnome-gmail-notifier [libsoup problem]

    Hi, I am trying to orphan the package gnome-gmail-notifier, but i ran into this problem. I only edited the PKGBUILD to match the new version and edited the download link. Now i am having some problems running ./configure No package 'libsoup-2.2' foun

  • HT4906 Photo Stream not working

    I have iphoto 9.  Suddenly Photo Stream is not working...no photos taken are coming to my desktop from iPhone 4 or iPad 2.  In system preferences, iCloud, it says I need to update, but software update says everything is up to date.  I am confused.  D

  • Can we customize iviews?

    Is there a way to customize the standard iviews that come with the MDM business package?  I don't see any source code in the par files. Thanks in advance.

  • AutoComplete:iexplorer.exe-Application Error

    Error reads: "The instruction at 0x6b8z641c referenced memory at 0x00000000. The memory could not be read." Unsing Samsung laptop working with Windows 8.  This error pops up whenever trying to print. Blank screen pops up then this Auto Complete appli