Event-dispatching create'n'showGUI useful for applets?

I want to create and show the GUI in my applet's init method. Do I still need to wrap my code like this:
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
// create and show gui code
(The applet is extends the JApplet class.)

Yes. It is not guaranteed that it is the event dispatch thread that invokes init().
http://java.sun.com/docs/books/tutorial/uiswing/components/applet.html#thread

Similar Messages

  • Exception during event dispatching - Dont want to use Swing.invokeLater()

    I am getting NullpointerException while event dispatching. I am using threads, where each thread executes soem functions and one synchonized method to update graphics (table.updateUI())
    I am using thread.start to invoke the threads and not SwinUtilities.invokelater(). I know this is the problem because threads which update graphics should be invoked by invokelater, so that they are in queue in the awt event thread.
    But the method that updates gui is a synchonized method, so there should not be any collision. Also invokelater runs through all the threads and then invokes each, this reduces performance.
    Any help is very much appreciated.
    Thanks,
    JavaSeems.

    Hi Teka,
    Thanks for the response.
    Ok following is the exception i get :-
    Exception occurred during event dispatching:java.lang.NullPointerException     at sun.awt.RepaintArea.paint(RepaintArea.java:300)     at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:196)     at java.awt.Component.dispatchEventImpl(Component.java:2663)     at java.awt.Container.dispatchEventImpl(Container.java:1213)     at java.awt.Component.dispatchEvent(Component.java:2497)     at java.awt.EventQueue.dispatchEvent(EventQueue.java:339)     at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:131)
    I read soem thread stuff and soem forums, all say that whenever thread updates gui, dont invoke them using start method, use invokelater. But that degrades performance, also all threads dont run simulanouelsy.
    There will be a minimum of 6 threads in my program which will run for the lifetime of the dialog, so i need all of them to run simulatenoussly. But invokelater queues them in the awt evnt thread one after the other, and they dont run together.
    The thread will update gui by methods like tabelmodel.updateRow, Table.updategui. I see exceptions after these statements.
    Does this info help?

  • How to dispatch custom events from an item renderer used for Datagrid Column

    Hi,
    I am using an Item Renderer for a Data Grid Column and in that mxml, I am dispatching a custom event with data.
    But the main mxml which has the DataGrid is not able to resolve the event. How can I solve this?
    Thanks

    Hi,
    This is the constructor for Event.
    public function Event(type:String, bubbles:Boolean  = false, cancelable:Boolean  = false)
    When you created your custom event after extending from Event, for the parent container receives the event, the bubbles property must be set to true.
    Please check if you have done so. That should solve the problem. Let me know if it doesn't.
    Nishad

  • Create the graph using java applet

    Hi friends,
    I have one urgent requirement.I need to create the flowchart by using java code.I have data in database.based on that i need to create the parent child relationchip graph..plase anybody help me .
    Thanks&Regards,
    Yousuf alam.A

    malcolmmc wrote:
    JFreeChart has been the favourite Java graph drawing library but, last time I looked, it didn't do flowcharts. If I were you I'd fire up Google and hunt around for a 3rd party library that does. Of course it's a pain if you have to use such libraries in an Applet. It's generally better to generate an image file on a server and display it as part of your html page.Sorry Malcolm but I don't think JFreeChart is applicable. The OP is asking for Flowcharts which are a graph as in nodes and edges. JGraph (Google) is probably what the OP wants but he is in for a shock when it comes to using it.

  • Create user just use for show running-config

    Dear Cisco support team,
    I want to create a user account on ASA 5520, which just has one function: show running-config.
    How to modify privilege, and set this privilege just excute this command: show running-config.
    Can you help me ?
    Thank you.
    Dang Nguyen,
    Viettel Cambodia Company.

    If the chassis is loaded with line cards, why then CPU utilization for five seconds: 11%/1%; one minute: 9%; five minutes: 9%?
    The configuration of each line cards are stored in each line cards.  There maybe a 40 Gbps backplane line but some commands have "low priority" communicating between the different line cards and up to the supervisor card.
    You'll see similar sort of behaviour too when you stack seven to nine 3750/G/E/X switches together.  

  • Which method is used for event creation

    Dear All,
    My client has more then one Purchase Organization. Workflow for Purchase order release very from pur org to pur org. For example - workflow WS92000030 is trigger when PO is created for India pur org where as workflow WS92000021 is trigger when PO is created for US pur org.  
    I checked and found that same Object Type - BUS2012 & event - RELEASESTEPCREATED is used in all Pur. Org PO release workflow. Also I found in Transaction code - SWETYP that Type linkage activate for  BUS2012, RELEASESTEPCREATED in all the PO workflow - WS92000030 & WS92000021.
    As per my knowledge, event can be created in various way such as Function module, Change document, General status management, Business Transaction Events etc.
    Can some one guide me, how can I found that which method is used for event creation in different pur org?
    How can I fould what is the fuctional module used for event creation if Fuctional module used for event creation. 
    For your information, I can see in T. Code - SWUO that 'Result dependent on a check function module'  for all the workflow - WS92000030, WS92000021 etc.
    Thanks in

    Hi Sahu,
    I dont think they have used the Function module or change document or any other kind of methods to trigger the workflow. This is because RELEASESTEPCREATED method is a standard method and it will be triggered by standard SAP. They can not make changes in standard sap saying RELEASESTEPCREATED should be triggered for this Purchase Org .
    Istead what i think is, they might have given the Event Condition for each workflow.
    In SWDD>> basic settings>> Start Events, we can give condition on triggering the workflow.
    Please check this.
    Regards,
    Gautham

  • Query in changing ide for applets?

    Hi all,
    I am newbie for applet and java as well.I made GUI for my program for applet in netbeans but need to use eclipse.I tried with using same code and that's running fine with that too.
    But unlike traditional html code we use for applet here is showing some different code.How can I make that like mannual code.or that is fine continuing with that?
    Regards,
    Palak Shah
    Message was edited by:
    palak_shah

    I dont understand what you're asking. The IDE you use makes no difference.

  • Looking for proper SIM card for applet development

    Hi,
    I would like to develop some applet on the SIM card. And does anyone know where I can get the proper SIM card?
    I have a bit search for test SIM card and blank SIM card, but I am not sure which one can be used for applet development. It seems that Gemalto provides some development suit that includes some sample cards. But the suit is too expensive and maybe I don't need the tools they provide. I don't want to buy the wrong one, so it would be very helpful if any of you has some provider information or links!!
    Thanks in advance!!
    regards,

    934624 wrote:
    I would like to develop some applet on the SIM card. And does anyone know where I can get the proper SIM card?You should over the internet and should contact different vendors. There are many Chinese companies which can provide you sample cards.
    I have a bit search for test SIM card and blank SIM card, but I am not sure which one can be used for applet development. Any Java SIM card can be used for applet development.
    maybe I don't need the tools they provide. You do as you will need a tool to install your applet on the SIM card
    I don't want to buy the wrong one, so it would be very helpful if any of you has some provider information or links!!Are you just want to write applications or wanna be able to install them too on real cards ? If the purpose is just writing of apps then oracle and ETSI have provided everything, you don't need to buy any additional tool. But yes for dubuging you will need some third party tool or write your own one : -)

  • Binding different events to a form depending if it is used for edit or create new.

    Hi,
    I succesfully have separated presentation from logic (events, etc...) using the code behind article at adobe site. This is pretty nice but now I have a little problem. Think about I have two forms one for edit and the other to add a new user. Usually this forms are allmost the same only some logic change and just few controls if any.
    What I would like to do (don't know if this is best way to do it, for me it does):
    1) Create Add form.
    2) Create a view state to change this add form to edit when needed (I think just few changes if any will be needed)
    3) Now the problem, I need to bind different logic if I'm in edit or add new user form. Is there any way to attach different functionality
    to the form component to let it behave the way I need depending on the mode (edit or new)? I have seen include can be used but can it be used conditionally?
    Example:
        if( in edit mode)
            include ("src/usermanagement_editlogic.as"))
        else( in add mode)
            include ("src/usermanagement_addlogic.as"))
    As I previously said I'm pretty new to flex but I think this is a good way to do things and have everything splitted. If anyone has a better way to do it I would be really happy to hear it  .
    Thanks in advance,
    Aron.

    Using forms for create/edit or login/register are similar scenarios. Usually, you can take care of those by simply changing states.
    Doing different includes is complicating things; you can just include all the code, and just use what you need depending on the state you are in.
    Before you get into conditionally including things, or creating a bunch of different events, look at this little simple tutorial on using states, which happens to use a login/register form as an example: http://www.adobe.com/devnet/flex/quickstart/creating_states/.
    HTH,
    Carlos

  • Using JOptionPane in a non-event dispatching thread

    I am currently working on a screen that will need to called and displayed from a non-event dispatching thread. This dialog will also capture a user's selection and then use that information for later processing. Therefore, the dialog will need to halt the current thread until the user responds.
    To start, I tried using the JOptionPane.showInputDialog() method and set the options to a couple of objects. JOptionPane worked as advertised. It placed the objects into a combobox and allowed the user to select one of them. However, it also gave me something unexpected. It actually paused the non-event handling thread until the user had made a selection. This was done without the JOptionPane code being wrapped in a SwingUtilities.invokeLater() or some other device that would force it to be launched from an Event Handling Thread.
    Encouraged, I proceeded to use JOptionPane.showInputDialog() substituting the "message" Object with a fairly complex panel (JRadioButtons, JLists, JTextFields, etc.) that would display all of the variety of choices for the user. Now, when the screen pops up, it doesn't paint correctly (like what commonly occurs when try to perform a GUI update from a non-event dispatching thread) and the original thread continues without waiting for a user selection (which could be made if the screen painted correctly).
    So, here come the questions:
    1) Is what I am trying to do possible? Is it possible to create a fairly complex GUI panel and use it in one of the static JOptionPane.showXXXDialog() methods?
    2) If I can't use JOptionPane for this, should I be able to use JDialog to perform the same type function?
    3) If I can use JDialog or JFrame and get the threading done properly, how do I get the original thread to wait for the user to make a selection before proceeding?
    I have been working with Java and Swing for about 7-8 years and have done some fairly complex GUIs, but for some reason, I am stumped here. Any help would be appreciated.
    Thanks.

    This seems wierd that it is functioning this way. Generally, this is what is supposed to happen. If you call a JOptionPane.show... from the Event Dispatch Thread, the JOptionPane will actually begin processing events that normally the Event Dispatch Thread would handle. It does this until the user selects on options.
    If you call it from another thread, it uses the standard wait and notify.
    It could be that you are using showInputDialog for this, try showMessageDialog and see if that works. I believe showInputDialog is generally used for a single JTextField and JLabel.

  • How to create many objects listening for one event

    I'm experimenting with the EventDispatcher class and I have a
    test class working. I want to use a loop to create a variety of
    movie clips that all listen for an event that gets dispatched every
    half a second. I have the event dispatching properly. My problem is
    that when creating the objects, the temporary variable I use to
    hold each created object has a life that extends beyond the loop in
    which it is instantiated. Rather than all five created objects
    changing color, only the last one changes color (see the code
    below--it lives on the first frame of an FLA file).
    This is not entirely surprising when I look at the code --
    'this' refers to the global scope and 'square' refers to the last
    created object that it pointed to. Here's the resulting trace:
    handler runing, square name is square 4
    this class name is global
    handler runing, square name is square 4
    this class name is global
    handler runing, square name is square 4
    this class name is global
    handler runing, square name is square 4
    this class name is global
    handler runing, square name is square 4
    this class name is global
    How can I modify this code so that each square object changes
    its own color?

    graphics.clear in the context of that function handler in my
    code would refer not to the squares but to the global scope,
    wouldn't it? In which case you'd be clearing all the graphics from
    your top level movie. I tried changing 'square.graphics' to just
    'graphics' in my handler and my squares just remained the original
    steady black.
    Your code doesn't use a loop and therefore isn't re-using a
    variable. You've escaped my 'logical errors' through brute force.
    (BTW, I think my code would work in AS2 if I used the old-school
    draw methods). Suppose you had to create 100 objects? Would you
    want to manually instantiate each one, typing that function over
    and over again? You'd have 500 lines of highly redundant code!
    Maybe try your example using a loop instead? I think you'll
    find it's pretty tough to sneak any vars like 'i' or 'square' from
    the global scope into the handler--the handler refers to the
    living, breathing variable rather than it's value at the time the
    handler was instantiated. Furthermore, you can't sneak any
    information about the square into your handler via the event object
    because the event object is created in a totally different place.

  • Create Component that Listens for Custom Event

    I've read a lot of tutorials and posts in this forum but still seem to be missing something.
    I want to be able to create an arbitrary number of instances of a custom class (based on Button) that each listen to a custom event dispatched in the application.  Eventually the event will carry data (including information that will let each Button determine whether it should react to the event), but for now I just want them to be able to hear the event.
    What's supposed to happen is
    1) Clicking the button labeled "I Make the Button" creates an instance of EventHearingButton using this.addElement.
    2) Clicking the button labeled "I Send the Event" dispatches the SuperCustomEvent custom event, with the additional information "I heard that" stored in the Information string
    3) The created EventHearingButton hears the event and updates its label to the value in the Information string.
    What actually happens is the EventHearingButton is created OK, but nothing happens when the "I Send the Event" button is clicked.
    Main.mxml
    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                      xmlns:s="library://ns.adobe.com/flex/spark"
                      xmlns:mx="library://ns.adobe.com/flex/halo">
         <fx:Metadata>
              [Event(name="SuperCustomEvent", type="Classes.SuperCustomEvent")]
         </fx:Metadata>
         <fx:Script>
              <![CDATA[
                   import Classes.EventHearingButton;
                   import Classes.SuperCustomEvent;
                   protected function EventDispatcherButton_clickHandler(event:MouseEvent):void
                        var NewEvent:SuperCustomEvent = new SuperCustomEvent("I heard that");
                        this.dispatchEvent(NewEvent);
                   protected function button1_clickHandler(event:MouseEvent):void
                        var NewButton:EventHearingButton = new EventHearingButton();
                        NewButton.x=270;
                        NewButton.y=130;
                        this.addElement(NewButton);
              ]]>
         </fx:Script>
         <s:Button x="270" y="90" label="I Send The Event" id="EventDispatcherButton" click="EventDispatcherButton_clickHandler(event)"/>
         <s:Button x="270" y="50" label="I Make the Button" click="button1_clickHandler(event)"/>
    </s:Application>
    Classes.EventHearingButton.as
    package Classes
         import spark.components.Button;
         import flash.events.Event;
         import Classes.SuperCustomEvent;
         public class EventHearingButton extends Button
              public function EventHearingButton()
                   super();
                   this.label="I haven't heard yet";
                   this.addEventListener(SuperCustomEvent.SUPERCUSTOMEVENT,SuperCustomEventHandler);
              private function SuperCustomEventHandler(event:SuperCustomEvent):void {
                   this.label=event.EventInformation;
    Classes.SuperCustomEvent.as
    package Classes
         import flash.events.Event;
         public class SuperCustomEvent extends Event
              public var EventInformation:String;
              public static const SUPERCUSTOMEVENT:String = "SuperCustomEvent";
              public function SuperCustomEvent(Information:String)
                   super(SuperCustomEvent.SUPERCUSTOMEVENT, true);
                   this.EventInformation=Information;
              override public function clone():Event{
                   return new SuperCustomEvent(EventInformation);

    "nikos101" <[email protected]> wrote in
    message
    news:ga59t5$8nh$[email protected]..
    >I tried something like what AMy described in a custom
    component
    >
    > dispatchEvent(new Event("Cancelled_Form"));
    >
    > I then added the following Listener in my application
    file;
    >
    > this.addEventListener("Cancelled_Form",cancelledForm);
    >
    > but it is never heard. Does anyone know what I have done
    wrong?
    Try attaching the event listener to your component rather
    than the
    application.
    HTH;
    Amy

  • HT3529 Is there a way to create, store and use preset messages for use with "Messages"?

    Is there a way to create, store and use preset messages for use with "Messages". I often have a recurrinig message to send, after a repeating event, and need to enter the same short message each time. It would be nice to have this short message stored and selectable so that I do not need to enter each time.

    found an answer that seems to work:
    https://discussions.apple.com/message/17997300#17997300

  • Which Event Classes i should use for finding good indexs and statistics for queries in SP.

    Dear all,
    I am trying to use pro filer to create a trace,so that it can be used as workload in
    "Database Engine Tuning Advisor" for optimization of one stored procedure.
    Please tel me about the Event classes which i  should use in trace.
    The stored proc contains three insert queries which insert data into a table variable,
    Finally a select query is used on same table variable with one union of the same table variable, to generate a sequence for records based on certain condition of few columns.
    There are three cases where i am using the above structure of the SP, so there are three SPS out of three , i will chose one based on their performance.
    1) There is only one table with three inserts which gets  into a table variable with a final sequence creation block.
    2) There are 15 tables with 45 inserts , which gets into a tabel variable with a final
    sequence creation block.
    3)
    There are 3 tables with 9 inserts , which gets into a table variable with a final
    sequence creation block.
    In all the above case number of record will be around 5 lacks.
    Purpose is optimization of queries in SP
    like which Event Classes i should use for finding good indexs and statistics for queries in SP.
    yours sincerely

    "Database Engine Tuning Advisor" for optimization of one stored procedure.
    Please tel me about the Event classes which i  should use in trace.
    You can use the "Tuning" template to capture the workload to a trace file that can be used by the DETA.  See
    http://technet.microsoft.com/en-us/library/ms190957(v=sql.105).aspx
    If you are capturing the workload of a production server, I suggest you not do that directly from Profiler as that can impact server performance.  Instead, start/stop the Profiler Tuning template against a test server and then script the trace
    definition (File-->Export-->Script Trace Definition).  You can then customize the script (e.g. file name) and run the script against the prod server to capture the workload to the specified file.  Stop and remove the trace after the workload
    is captured with sp_trace_setstatus:
    DECLARE @TraceID int = <trace id returned by the trace create script>
    EXEC sp_trace_setstatus @TraceID, 0; --stop trace
    EXEC sp_trace_setstatus @TraceID, 2; --remove trace definition
    Dan Guzman, SQL Server MVP, http://www.dbdelta.com

  • Creating event dispatching in custom class

    I have been trying to create an event dispatcher in a custom
    data transfer object class. It's a simple class and I don't know
    how to make it dispatch an event. I tried extending the
    EventDispatcher class but that doesn't appear to work either. Any
    help would be greatly appreciated.

    I have attached the code for the application and the custom
    class. This should work from what I have read, but I can not get
    the application to catch the event.
    APPLICATION
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    creationComplete="initThis()" layout="absolute">
    <mx:Script>
    <![CDATA[
    import mx.controls.Alert;
    private var _tester:TestClass = new TestClass();
    private function initThis():void{
    addEventListener(TestClass.TEST_ACTION, onTestHandler);
    private function onTestHandler(event:Event):void{
    Alert.show("Event Dispatched");
    ]]>
    </mx:Script>
    <mx:Button x="312" y="150" label="Button"
    click="{_tester.testEvents()}"/>
    </mx:Application>
    CLASS
    package
    import flash.events.EventDispatcher;
    import flash.events.Event;
    public class TestClass extends EventDispatcher
    public static const TEST_ACTION:String = "test";
    public function testEvents():void{
    dispatchEvent(new Event(TestClass.TEST_ACTION));
    }

Maybe you are looking for

  • Black Screen with Apple Logo?( Why)

    I have had my ipod touch (2nd generation) for 3 months. One day i was at school using my ipod and my battery ran out so i put it in my backpack. After school i plugged my Ipod into my computer and i got the red battery icon. I knew i had to wait 10 m

  • What is the correct Sun Java version for Plus ?

    OK so I am running Version 1.4.2_06 (build 1.4.2_06-b03) for Disco Plus.. Is that the correct version ? I am trying to debug an error (Outstanding Refresh) and I need to eliminate the Java version being the cause: Can anyone confirm ? thanks OBX Orac

  • Broadcast quality output

    I've just spent hours chroma keying and I want to be sure of the quality of my output. As this is going to television, it needs to be broadcast quality. I'm I correct in assuming that I should output it as a quicktime movie and not use quicktime conv

  • Help my Ipod won't restore or reset

    my ipod 60gb w/color display won't reset or restore and is frozen with file and !, what can i do please help...

  • MacBook Pro Late 2013 Bootcamp doenst work HELP!

    Hey, so I'm using a late 2013 MBP with Retina and i want to Boot Camp and do Windows 7 on it. I have a version of Windows 7 Professional 64bit version on my desktop and a 16 GB USB 3.0 USB plugged in my mac. After i start the Bootcamp Assistant and s