Best event handling way making the code simple

Hi all,
I want to develop a JFrame thats all the componets inside the JFrame have methods (that are owned by JFrame the class) like "compNameClicked", "compNameChanged", "compNameArranged". The JFrame would be like this below...
class MyFrame extends JFrame
      //Datamembers
      comp1Name declaration
      comp2Name declaration
      comp3Name declaration
      //Methods
      comp1NameClicked() {...}
      comp1NameChanged() {...}
      comp1NameArranged() {...}
      comp2NameChanged() {...}
      comp3NameClicked() {...}
How will i register this "event handling" methods to the componets? I want to use this techique to retain the simplicity of the code. If there is a more simple way for event hadling, please let me know about it.
thank you for advance, kostas

There cannot be a single approach which will apply to all the Programs or application.
You can try and refere to :
http://www-106.ibm.com/developerworks/edu/j-dw-javadeliv-i.html
This tutorial explains all the available approaches you can find out what best suits your need.

Similar Messages

  • Can  DISABLE preProcess Event Handler add to the Orchestration parameters?

    I have a DISABLE pre-process event handler defined on the User object. I need to set the current date on a USR UDF attribute whenever the user is disabled or enabled or created. The CREATE handler works and the date value shows up on the user profile. However, when I try to set this attribute on the pre-process DISABLE or ENABLE event handlers, the new date does not show up. Here is the code I am using in my DISABLE/ENABLE event handler:
    Date currentTime = new Date(System.currentTimeMillis());
    orchestration.addParameter(USER_STATUS_DATETIME_ATTR_NAME, currentTime);
    Where the orchestration object is from the execute() parameter list.
    Any ideas as to why this is not working? Is adding to the orchestration not allowed for DISABLE or ENABLE event handlers? I know my handler is getting calls as I am logging the orchestration.getOperation() value.
    Thanks for any suggestions.
    -Dave
    Edited by: user552098 on Nov 12, 2012 1:56 PM

    When you update the field, make sure you are using the field label name, and not the UDF value.
    -Kevin

  • Can File Based events Handle wildcards in the filename

    The question was can file events handle wildcards in the filename? That way, the object scheduled to handle the event can query the file event specifics and process accordingly. The impact is that we will have to create a file event for every event type for every pathway/state. Therefore, in a worst case scenario, if there are 3 event types for every state, i.e., end of day, end of week, and end of month, and there are 50 pathways/states, then there would be 50 *3 or 150 total file events that would have to be entered. If BOE can handle file event wildcarding, then we need only one event.can we do that ???
    Edited by: sanfrancisco on Nov 18, 2010 5:20 PM

    Hi
    As per my knowledge events will not Handle wildcards in the filename
    Regards
    Ashwini

  • Problem in event handling using oo abap code

    Hi,
    My requirement is i need to disply 3 blocks in ALV format.I have done that.Now my problem is if i double click on aufnr of the first block, it should call the transaction code. I have written the code in oo abap but i have used function modules for ALV.Now my doubt is 'How to write an event  once the user double click on the particular field of the first block, it should call the tcode " using object oriented code.
    How to populate the heading for each block using oo abap code.
    Thanks & Regards
    Anus

    hi.....
    Use Double_click event handler method of class cl_gui_alv_grid of first block....
    if not solved .
    Send me Your program lines ...........
    Best Regards
    Prabhakar

  • Execute an event several time in the code

    Hi I would like to execute a piece of code several time in the VI without the need to sub vi calling.
    I found a weird reaction from labview as it is executing the event but without respecting the delay.
    I realized that when I highlighted the execution.
    Cheers,
    Zied
    Attachments:
    signal value Folder.zip ‏9 KB

    Thank you guys, but is it possible to use the event structure but without waiting for the next loop iteration.
    I did that, is it a good way to code.
    Attachments:
    signal value Folder.zip ‏18 KB

  • Event handling while changing the value or clicking the button

    Hi All,
    I am working on Jdeveloper 11.1.1.5.
    I have a must requirement where i have a textbox and a button.
    Now if a user changes the value of the textbox then i need to show a dialog to the user for the confirmation that whether he wants to continue or not.
    And on click of button i execute my business logic and commit in the database.
    NOTE :- I am opening that dialog on the valueChangeEvent of the textbox.
    Case 1 :-
    User enter a value in the textbox and tab out the field , value change occurs and dialog displayed onto the page. -> CORRECT
    Case 2 :-
    User enter a value in the textbox and does not tab out the field and directly click on the button.In that case , actually valueChange and button code both executes at the same time.I mean to say , the user click on the button , i get the dialog , but my business logic also gets executed. -> INCORRECT(ISSUE)
    How should i restrict the button logic to be executed till the dialog has been shown and user has confirmed.
    Kindly suggest!!!
    Regards,
    Shah

    Hi Shah,
    You can try something like this:
    <af:inputText autoSubmit="true" id="it1" ...>
      <af:setPropertyListener from="true" to="#{viewScope.uncommittedData}" type="valueChange"/>
    </af:inputText>
    <af:commandButton partialTriggers="it1" disabled="#{viewScope.uncommittedData ne 'true'}" .../>AP

  • My ipad requires a 4 digit code to use it. It refuses to acceptmy code which I have used before and I have no way change the code.

    What can I do since my ipad now refuses to accept my four digit code. I have no idea what my ipad operating system is

    Force iPad into Recovery Mode. Follow step 1 to 6 very closely.
    http://support.apple.com/kb/HT1808
    Note: You may have to repeat the above a few times.

  • Making a cutsom event handler for nodes

    hi i was wondering how to go about making a custom eventhandler class for nodes
    for eg. if a have a circle (c1) in the main.fx file
    and i want to assign it Mouse and Key events(using onMousePressed etc)
    but i dont want to write it in "c1"'s definiton directly coz i want the event handling code to be useful for another circle i may create later(call it c2)
    can some tell me how to go about it ?
    Appreciated. :-)
    UPDATE:
    ok i just realized that i could simply write a modified Circle class extending the Circle class.
    So i can just create a new modified Circle object when needed.But how do i exactly write the class.The fixed variables i can simply override.But what about the event handling properties of the circle,how do i make sure they are initialzed for that object when the modified Circle object is created? what is the syntax??
    Edited by: apratim_pranay on Apr 22, 2010 6:16 AM

    hey i tried making a circle class like the above..
    drag works fine..
    thing is.. i've nested some effects..which "SHOULD" toggle on on keypresses ,but even though the key press is detected..effects dont appear..
    public class modCircle extends Circle{
    var c1e2:Glow;
    var c1e4:Reflection=Reflection {bottomOpacity:0.0 topOpacity:0.5
                                 fraction: 0.75 topOffset: 0.0};
         override var centerX=40;
         override var centerY=199;
         override var radius=40 ;
         override var fill= Color.BLACK;
         override var effect=c1e2=Glow {level:0.1 input:c1e4};
    override def onMouseEntered= function( e: MouseEvent )
                              {requestFocus();}
    override def onKeyPressed= function (e: KeyEvent): Void
                               if(e.code==KeyCode.VK_G)
                                   if(c1e2.level==0.1)
                                    {c1e2.level=0.9}
                                   else
                                    {c1e2.level=0.1}
                                 if(e.code==KeyCode.VK_M)
                                   if(c1e4.topOpacity==0.5)
                                     c1e4.fraction= 0.75;c1e4.topOffset= 0.0;
                                     c1e4.topOpacity= 0.5;c1e4.bottomOpacity= 0.0;
                                   else
                                     c1e4.fraction= 0.75;c1e4.topOffset= 0.0;
                                     c1e4.topOpacity= 0.5;c1e4.bottomOpacity= 0.0;
    }why is this happening??

  • Does Retry events handle the multi-value field correctly.

    Hi ,
    Just curious if the retry event task handle the multi-value event correctly. Let say we have five values a1, a2, a3, a4, a5 in a child table and while provisioning a2 and a4 get failed. Now when the retry task will run how will it be sure that it will pick up a2 and a4 value in the retry task. My understanding is we need to handle it in the code but just want to make sure if there is any configuration that will make it easy to achieve and we don't need to iterate the values in java code.
    Thanks.

    Hi Kevin,
    Thanks for the reply. Does that mean that in case of retry the code will only execute for a2 and a4 (in the example in mentioned in my initial post) as i couldn't see maintain the key in the task retry schedule task or sch table. Am i missing anything.
    In our case sometimes retry will send the value a1 (as example) while the failure is for a2. Do i need to put some additional config?

  • OID resource goes to Disabled Status after running the post process event handler

    Hi,
    We have an event handler on post update operation. The event handler using the user manager API to do some modification. We are using the "Lock()" function of User Manager API to lock the user based on attribute value. After running the event handler though the user gets locked as expected, it also disables the OID resource after that. We have other resources along with OID but they are not affected with event handler. Only the OID user is triggering the disable operation on locking the user on event handler. We have used the OID 11g Connector for implementation.
    If you manually lock the user in user interface it's not going to disable status.
    How we can stop to disable the OID User Account.
    Thanks

    No.If you lock the user in Console it's not going disable status.
    Thanks

  • I pasted a line of code in my muse site google9cd204871dd4e782.html, is there any way to see the code so i can remove it?

    Hi, I pasted a line of code in my muse site, Is there any way to look at the code on my home page so i can remove this code? It is visible on my page when i view my site in browser, but i can't see it in muse.

    How did you paste the code? Did you insert HTML elerment? Or just paste it on the page? What's the site address?
    By the way. The code you have tried to add for Google webmaster tools should of been saved as a separate HTML file and upload it to your server to be verified, not put on the page, I think there are other methods that you put in the code to get  verified.
    thanks
    jason

  • How to trigger navigation to a portal iView from server side event handler

    Hi,
    I am modifying the workset map application. I have created custom URL links under each iView which should navigate to different iViews depending on some business logic. So I had to provide a custom event handler for these iVIew links and the path to the next iview is dynamically created by the code in the event handler. Once the new PCD path is generated, the event handler should trigger a navigation to that PCD object. Which APIs can I use to trigger this navigation from the server side event handler? I have done this before in webdynpro where we used WDPortalNavigation (.absoluteNavigation or .relativeNavigation). Is there something similar that i can use in this case (i.e. when developing a simple Portal Application from an AbstractPortalComponent)?

    Hi,
    On my understanding of your requirement.
    the best solution what i think is use Object Based Navigation(OBN).
    Is much suitable to your requirement.
    Moreover you can use
    1.Relative navigation
    2.Absolute navigation.
    In the same way how you used in web dynpro.
    Same thing can be done in abstract portal component also.
    Try using that.
    Thanks & Regards,
    Lokesh
    Edited by: lokesh kamana on Aug 11, 2008 7:23 AM

  • Teaching Event Handling

    Hi,
    I need to tech to a small group of students Java Event Handling.
    I do not want to go deep. Their level is not high. Maybe some custom events and event listeners (mainly ActionListeners, ItemListeners and WindowListeners).
    I need to find a good teaching example. A simple application that will let them understand how Event Handling is done, the right way.
    The tutorial consists of 2 parts.
    I do not ask for code (although it is welcome). I ask for some ideas on how to do it and one exercise that can be taught in 2 steps (courses).
    Any ideas would be appreciated!
    Chris

    Hi,
    You can give 2 basic exmples of even handling
    1. Click on button: 'Action Performed', which will give idea of about how controls are handled.
    2. Tree Example: Expansion & Collapse all of children nodes, which will give overview of delegation of events and calling some events programmatically.
    I think this will give students a rough but good idea about events, though they need not dig up in deep.
    Best Regards,
    Yashodhan

  • Javascript embedded in button pl/sql event handler not being executed

    Javascript calls not working from pl/sql button event handler. What am I missing? Are specific settings needed to execute javascript from pl/sql proceedures?
    Example: Want to toggle target='_blank' off and on in a button pl/sql event handler to open url call in new window & then reset when processing submit is done & the app returns to the form.
    portal form button's pl/sql submit handler:
    begin
    htp.p('<script language=JavaScript>') ;
    htp.p('this.form.target="_blank"') ;
    htp.p('</script>') ;
    PORTAL.wwa_app_module.set_target('http://www.oracle.com') ;
    htp.p('<script language=JavaScript>') ;
    htp.p('this.form.target="_blank"') ;
    htp.p('</script>') ;
    end ;
    Putting the following in the button's javascript on_click event handler works great:
    this.form.target='_blank'
    to force opening new window with a call in the button's submit pl/sql code via:
    PORTAL.wwa_app_module.set_target('http://www.oracle.com') ;
    but then the target='_blank' is left on when the submit is done & we return to the form.
    putting the above javascript as a function (called fcn_newpage) elsewhere (e.g., after form opens) & calling in the submit pl/sql with
    htp.p('fcn_newpage') ;
    also doesn't work.
    Metalink thought this was an application issue instead of a bug, so thought I'd see if anyone knows what's going wrong here. (Portal 9.0.4.1)

    thanks for your discussion of my post.
    Please clarify:
    "htp.p('fcn_newwindow') sends a string":
    What would you suggest the proper syntax for a function fcn_newwindow() call from a pl/sql javascript block that differs from
    htp.p('<script language="Javascript">') ;
    htp.p('fcn_newwindow');
    htp.p('</script>');
    or more simply
    htp.p('fcn_newwindow') ;
    More generally, what I'm trying to figure out is under what conditions javascript is executed, if ever, in the pl/sql of a button (either the submit or custom event handler, depending on the button).
    I've seen lots of posts asking how to do a simple htp.p('alert("THIS IS TROUBLE")') ; in a pl/sql event handler for a button on a form, but no description of how this can be done successfully.
    In addition to alerts, in my case, I'd like to call a javascript fcn from a pl/sql event handle that would pass a URL (e.g., http://www.oracle.com) where the javascript fcn executed
    window.open(URL). The API call to set_target(URL) in pl/sql has no ability to open in a new window, so calling that is inadequate to my needs and I must resort to javascript.
    Its clear in the PL/SQL of a button, you can effect form components since p_session..set_target & p_session.get_target set or get the contents of form components.
    So to see if javascript ever works, I tried to focus on something simple that only had to set what amounts to an enviromental variable when we returned to the form after a post. I chose to try to change the html value of TARGET from javascript in the PL/SQL button because it doesn't need to be implemented until we finish the post and return to the form.
    So I focused on a hack, setting this.form.TARGET='_blank' in the on_click event handler that forced every subsequent URL call or refresh of the form to be a new window. I then wanted to turn off opening new windows once I'd opened the URL call in a new window by setting TARGET='' in the portal form. I can achieve what I want by coding this.form.TARGET='' in the javascript (on_focus, on_change, or on_mousedown, ...) of every form component that might refresh the form. However, that is a ridiculous hack when a simple htp.p('<script>') ; htp.p('this.form.target=""') ; htp.p('</script>') ; at the end of the button's pl/sql event handle should do the same thing reliably if javascript ever works in the pl/sql event handler.
    If we didn't have access to form components through p_session calls, I'd assume it was a scope issue (what is available from the pl/sql event handler). But unless my syntax is just off, when, if ever, can javascript be used in a portal form's pl/sql event handler for a button?
    if I code a javascript funtion in the forms' pl/sql before displaying form:
    htp.p('<script language="JavaScript">') ;
    htp.p('function fcn_new_window(URL)') ;
    htp.p('window.open(URL)' ) ;
    htp.p('</script>') ;
    the function can be called from a button's on_click javascript event handler:
    fcn_new_window('http://www.oracle.com')
    but from the same button's pl/sql submit event handler this call doesn't work: htp.p('fcn_new_window("http://www.oracle.com")')
    So my questions remain: Is there other syntax I need, or does javascript ever work properly from the pl/sql of a form button's event handler? If it doesn't work, isn't this a bug that should be fixed by Oracle?
    I can probably figure out hacks to make things work the way I need, but executing javascript from pl/sql event handlers seems to be the expected way to affect portal html pages (forms, reports, ...) and it seems not to work as expected. I don't feel I should have to implement hacks for something as simple as calling a javascript function from pl/sql when almost every example I've found in metalink or the forums or Oracle Press's "portal bible" suggests using javascript from pl/sql via the utility htp.p() to effect web page components in portal.
    My TAR on the subject, while still open, returned the result basically: "We can reproduce your situation. Everything looks okay to us, but we can't explain how to use javascript where you want or point you to any documentation that would solve your problem or expain why it should not work the way you want it to. We don't feel its a technical issue. Why don't you post the problem on the portal applications forum."
    I'm hoping I'm just missing something fundamental and everything will work if I implement it a little differently. So if anyone sees my error, please let me know.
    by the way, not sure this is germain, but in reference to your comment:
    "redirections in pl/sql procedures give a peculiar result. in a pl/sql procedure, usually, portals give the last redirection statement and ignore anything else coming after it."
    if I try to raise an alert:
    htp.p('alert("you screwed up")');
    return;
    in a pl/sql event handler, it still doesn't raise the alert, even though its the last thing implemented in the event handler. But if I set the value of a text box using p_session..set_value_as_string() at the same spot, it correctly sets the text box value when I return to the form.

  • Delicate ProgressMonitor/ event handling problem

    Hi,
    I have a delicate ProgressMonitor / event handling problem.
    There exists some solution on similiar problems here in the forums, but no solution to my special problem, hope anybody can help me out.
    I have a rather big project, an applet, that I've written a separate JarLoader class that will load specific jar's if the ClassLoader encounter a unloaded class, all ok so far.
    But, during loading, I would like to display a ProgressBar. And here is the problem. If my custom ClassLoader intercepts a findClass -request that needs to load the class from a jar from a normal thread, this is no problem, but if the ClassLoader intercepts a findClass that needs loading a jar when inside the EventQueue -thread, this is becomming tricky!
    The catch is that an event posted on the EventQueue finally needs a class that needs to be loaded, but I cannot dispatch a thread to do this and end that particular event before the class itself is loaded.
    So how do I hold the current EventQueue -event needing a jar -load, Pop up a ProgressBar, then process events in the EventQueue to display the ProgressBar and update repaints in it? then return from the event that now have loaded needed class-files.
    I've tried a tip described earlier in the forums by trying to handle events with this code when loading the Jar:
        /** process any waiting events - use during long operations
         * to update UI */
        static public void doEvents() {
            // need to derive from EventQueue otherwise
            // don't have access to protected method dispatchEvent()
            class EvtQueue extends java.awt.EventQueue {
                public void doEvents() {
                    Toolkit toolKit = Toolkit.getDefaultToolkit();
                    EventQueue evtQueue = toolKit.getSystemEventQueue();
                    // loop whilst there are events to process
                    while (evtQueue.peekEvent() != null) {
                        try {
                            // if there are then get the event
                            AWTEvent evt = evtQueue.getNextEvent();
                            // and dispatch it
                            super.dispatchEvent(evt);
                        catch (java.lang.InterruptedException e) {
                            // if we get an exception in getNextEvent()
                            // do nothing
            // create an instance of our new class
            EvtQueue evtQueue = new EvtQueue();
            // and call the doEvents method to process the events.
            evtQueue.doEvents();       
        }Then, the loader checks
    java.awt.EventQueue.isDispatchThread()to see if its' inside the eventqueue, and runs doEvents after updating the ProgressMonitor with new setProgress and setNote values.
    More precise;
    The loader is loading the jar like this:
    (this is pseudo code, not really usable, but outlines the vital parts)
    public void load() {
      monitor = new ProgressMonitor(null, "Loading " + jarName, ""+jarSize + " bytes", 0, jarSize);
      monitor.setMillisToDecideToPopup(0);
      monitor.setMillisToPopup(0);
      // reading jar info code here ...
      JarEntry zip = input.getNextJarEntry();
      for (;zip != null;) {
         // misc file handling here... total = current bytes read
         monitor.setProgress(total);
         monitor.setNote(note);
         if (java.awt.EventQueue.isDispatchThread()) {
            doEvents();
         zip = input.getNextJarEntry();
      monitor.close();
    }When debugging doEvents(), there is never any events pending in peekEvents(), even if I tries to put a invokeLater() to run the setProgress on the monitor, why? If it had worked, the doEvents() code would have saved my day...
    So, this is where I'm totally stuck...

    Just want to describe how I did this using spin from http://spin.sourceforge.net
    This example is not pretty, but it can probably help others understanding spin. Cancelling the ProgressMonitor is not implemented, but can easily be done by checking on ProgressMonitor.isCanceled() in
    the implementation code.
    First, I create a bean for displaying and run a ProgressMonitor:
    Spin requires an Interface and an Implementation, but that's just nice programming practice :-)
    import java.util.*;
    public interface ProgressMonitorBean {
        public void start(); // start spinning
        public void cancel(); // cancel
        public int getProgress(); // get the current progress value 
        public void setProgress(int progress); // set progress value
        public void addObserver(Observer observer); // observer on the progressValue
    }Then, I created the implementation:
    import java.util.*;
    import javax.swing.ProgressMonitor;
    import java.awt.*;
    public class ProgressMonitorBeanImpl extends Observable implements ProgressMonitorBean {
        private ProgressMonitor monitor;
        private boolean cancelled;
        private int  progress = 0;
        private int  currentprogress = 0;
        public ProgressMonitorBeanImpl(Component parent, Object message, String note, int min, int max) {
            monitor = new ProgressMonitor(parent, message, note, min, max);
            monitor.setMillisToDecideToPopup(0);
            monitor.setMillisToPopup(0);       
        public void cancel() {
            monitor.close();
        public void start() {
            cancelled = false;
            progress = 0;
            currentprogress = 0;
            while (progress < m_cMonitor.getMaximum()) {
                try {
                    synchronized (this) {
                        wait(50); // Spinning with 50 ms delay
                    if (progress != currentprogress) { // change only when different from previous value
                        setChanged();
                        notifyObservers(new Integer(progress));
                        monitor.setProgress(progress);
                        currentprogress = progress;
                } catch (InterruptedException ex) {
                    // ignore
                if (cancelled) {
                    break;
        public int getProgress() {
            return progress;
        public void setProgress(int progress) {
            this.progress = progress;
    }in my class/jarloader code, something like this is done:
    public void load() {
      ProgressMonitorBean monitor = (ProgressMonitorBean)Spin.off(new ProgressMonitorBeanImpl(null, "Loading " + url,"", 0, jarSize));
      Thread t = new Thread() {
        public void run() {
          JarEntry zip = input.getNextJarEntry();
          for (;zip != null;) {
            // misc file handling here... progress = current bytes read
         monitor.setProgress(progress);
      t.start(); // fire off loadin into own thread to do time consuming work
      monitor.start(); // this will spin events on monitor and block until progress = max
      monitor.cancel(); // Just make sure ProgressMonitor is closed
    }The beautiful thing here is that Spin is taking care of weither the load() is inside the dispatch thread or not, making the code much simpler and cleaner to understand.
    The ProgressMonitorBeanImplementation could been made much nicer and more complete, but I was in a hurry to check if it worked out. And it did! This will be applied on a lot of gui -components that blocks the event-queue in our project, making it much more responsive.
    Hope this will help others in similiar situations! Thanks again svenmeier for pointing me to the spin -project.

Maybe you are looking for