Adding actionListener to a button

pls i want to create an applet with buttons rectangle,circle,and polygon and having a textArea.when someone clicks on the rectangle buttons it draws a rectangle,on the circle buttons it draws a circle and on the polygon button it draws a polygon.pls i have already created the user interface how do i add the actionListeners to the respective buttons and reggister them.

Hi,
try something like this:
JButton jButton1 = new JButton("yourbutton");
jButton1.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent evt) {
                someMethodThatDoesWhatYouNeed();
});this is just a way to do it, there are other ways, just look around in the forum to discover them.
JoY?TiCk

Similar Messages

  • User exit/ BADI in f-32 / f-28 for adding application tool bar button

    Hi Experts,
    There is a requirement, for adding application tool bar button in the Transaction codes F-32 / F-28 / Feba_lockbox. So that while clearing documents with reference document, they can upload the data(Reference Documents) from local file and after the data is fetched for clearing, they need to download the data to local file for verification. If the data is verified to be okay, then they can go ahead with simulation and posting. They need this verification to be done in excel sheet, so need to download the data into local file.
    I found a BADI in that screen is BADI_LAYER but I don't think it is relevant.         
    Any help is apreciated!
    Is there any EXIT ? Because I can not find it too.
    Regards,
    Nitin

    where you did the enhancement?
    I have to create the IDOC once Clear docuemnt is created.. It may help me.

  • ALV Grid default values for new rows added with Add/Insert buttons

    Hi!
    Help, please,  to find a way how to set default values for new rows added with Add/Insert buttons in
    ALV Grid.

    I have found salution:
    ALV Grid u2013 Insert row function
    Sometimes we need to assign some default values when we create a new row in a grid using standard ALV Append row button. In our scenario we will see how to assign default values to Airline Code (CARRID), Flight Connection Number (CONNID) and Flight date (FLDATE) when a new row is created. To do that we need to handle DATA_CHANGED event in the program like mentioned below.
    Definition of a class:
    Code:
          CLASS lcl_event_receiver DEFINITION
    CLASS LCL_EVENT_RECEIVER DEFINITION.
      PUBLIC SECTION.
    METHODS:
         handle_data_changed
         FOR EVENT data_changed OF cl_gui_alv_grid
         IMPORTING er_data_changed
                           e_ucomm.
    ENDCLASS.                    "lcl_event_receiver DEFINITION
    Implementation of a class:
    Code:
    CLASS LCL_EVENT_RECEIVER IMPLEMENTATION.
      METHOD HANDLE_DATA_CHANGED.
        DATA: dl_ins_row TYPE lvc_s_moce.   " Insert Row
          FIELD-SYMBOLS: <fs> TYPE table.    " Output table
    Loop at the inserted rows table and assign default values
        LOOP AT er_data_changed->mt_inserted_rows INTO dl_ins_row.
          ASSIGN er_data_changed->mp_mod_rows->* TO <fs>.
          loop at <fs> into ls_outtab.
            ls_outtab-carrid  = 'LH'.
            ls_outtab-connid  = '400'.
            ls_outtab-fldate  = sy-datum.
            MODIFY <fs> FROM ls_outtab INDEX sy-tabix.
          endloop.
        endloop.
      ENDMETHOD.                    "handle_data_changed
    ENDCLASS.                    "lcl_event_receiver IMPLEMENTATION
    Register the events to trigger DATA_CHANGED event when a new row is created.
    Code:
        CALL METHOD OBJ_GRID->REGISTER_EDIT_EVENT
          EXPORTING
            I_EVENT_ID = CL_GUI_ALV_GRID=>MC_EVT_ENTER.
        CALL METHOD OBJ_GRID->REGISTER_EDIT_EVENT
          EXPORTING
            I_EVENT_ID = CL_GUI_ALV_GRID=>MC_EVT_MODIFIED.

  • Added actionListener, then GUI broke

    Hi,
    1. first i ran my menu GUI, it worked fine
    2. then i added the actionListener code... now she no workie...
    what did i do wrong???
    ERROR MSG:
    C:\jLotto\LotFrame.java:34: cannot resolve symbol
    symbol : class ActionListener
    location: class LottoFrame
              new ActionListener(){
    ^
    1 error
    Tool completed with exit code 1
    import javax.swing.JFrame;
    import javax.swing.JMenuBar;
    import javax.swing.JMenu;
    import javax.swing.JMenuItem;
    import javax.swing.KeyStroke;
    import java.awt.Event;
    import javax.swing.JOptionPane; //print menu trial run
    public class LotFrame extends JFrame
      // Constructor
      public LotFrame(String title)
        setTitle(title);                             // Set the window title
        setDefaultCloseOperation(EXIT_ON_CLOSE);     // handle exit operation
        setJMenuBar(menuBar);                        // Add the menu bar to the window
        //MAIN MENU
        JMenu fileMenu    = new JMenu("File");          // Create File menu
        JMenu findMenu    = new JMenu("Find");
        // Construct the file pull down menu
        newItem   = fileMenu.add("New");             // Add New item
        openItem  = fileMenu.add("Open");            // Add Open item
        closeItem = fileMenu.add("Close");           // Add Close item
        fileMenu.addSeparator();                      // Add separator
        saveItem  = fileMenu.add("Save");            // Add Save item
        saveAsItem= fileMenu.add("Save As...");      // Add Save As item
        fileMenu.addSeparator();                      // Add separator
        printItem.addActionListener(
               new ActionListener(){
                    public void actionPerformed( ActionEvent e )
                         JOptionPane.showMessageDialog( LotFrame.this,
                         "adding actionListener at end of GUI setup",
                         "action at end", JOptionPane.PLAIN_MESSAGE);
                    }//end of actionPerformed
              }//end of actionLinstener
         );//endof .addActionListener
       printItem = fileMenu.add("Print");           // Add Print item
        menuBar.add(fileMenu);                       // Add the file menu
        menuBar.add(findMenu);
      }//end of constructor
      private JMenuBar menuBar = new JMenuBar();     // Window menu bar
      // File menu items
      private JMenuItem newItem, openItem, closeItem, saveItem, saveAsItem, printItem;
    }//end of class LotFrame

    java.awt.event.*;
    import java.awt.Event;

  • Adding text to a button.

    Can anyone tell me how to add text to a button I created? If it changes anything, it is a sub-menu button

    Hi:
    Sorry if it sounds like a RT_M answer, but look in the User Manual for the topic Adding Text to a Button and you'll get the step by step procedure.
    If it don't answer your question or you mean something different come back please !
      Alberto

  • Adding actionListener to JComboBox

    Hi there
    I have added actionListener to a JComboBox. I only want the actionPerformed() get called when the user choose the item in the JComboBox, however, it also get called whenever I change the items in the JComboBox.
    I have tried to call the ActionEvent.getID() method to identify the action, however, changing the items and choosing the item give me the same ID - 1001.
    Has anyone got this problem before? How did you solve it?
    Should I use other Listener for listening only the choosing event?
    In advance thanks!
    From
    Edmond

    I had many problems using actionListeners with JComboBox because it gets called all the time, I have had much better luck using mouseListener and the events getClickCount() method for single and double click selections, this avoided many of the problems for me.

  • Ideas for Adding a Quick Print Button to VA01 Overview Screen

    Problem Statement:
    Our users would like a "quick print" button on the VA01/VA02 application toolbar that immediately spools the Order Confirmation output to the printer.  Our users want to print the output on demand, i.e., they do not want the output to automatically be printed when the order is created because a printout is not always needed.  We already have condition records created with Dispatch Time set to 3 - Send with application own transaction.  However, it takes 7 or more clicks to print the output on demand by navigating the menu (Extras > Output > Edit...Further Data...etc.) and changing the Dispatch Time to 4 - Send immediately when saving.  This is a big ergonomic issue and a time killer.
    Although the number of clicks to print are less when printing the output from the VA02 initial screen (via menu Sales document > Issue Output To), this is not acceptable when creating new orders.  Really need an on-demand, quick print button on the VA01 screen.  As an aside, we have a totally custom transaction for preparing sales order data (shopping cart-like way of finding materials and entering required data) that then calls VA01 and fills in all of the information.  When saving in VA01, the user is returned to our Z-transaction so asking the user to subsequently run VA02 to print is not practical.
    Current Output Determination:
    We have custom output type ZBS0 (copy of BS0).  Condition records for print medium are set to Dispatch Time = 3.
    Questions:
    1.  Searching these forums, it appears custom code (extension or user exit?) can be written to call RSNAST00, or something similar, to automatically send output having a Dispatch Time = 3.  Where can I find more information on exactly how to do this?
    2.  Do transactions VA01 and VA02 (Overview screens) have extensions that allow a print button to be added to the application toolbar?  We would want to call the custom printing code from the button to send the output.
    Any feedback on how others have solved this problem would be greatly appreciated.
    Warm Regards,
    Rob
    P.S.  Using GuiXT is not an option for us.

    HI
    We had similar issues with printing packing list and picking list by the warehouse people.
    We created a new ztransaction with input fields of delivery number, output type, number of copies and a check box for repeat output(in case if the output was already printed).
    You can also create a new Z-transaction with input fields of Sales order number(mandatory field), output type (Default it with value of ZBS0), number of copies (default it with 1) and a check box. On executing the transaction You can provide a message if the output was already printed so that the user can select the check box to repeat the output and execute. You can also print multiple SO by giving a range value if required.
    If you do not want the user to enter the new ztransaction every time, try providing a menu path to the new z-transaction from the existing z-transaction which you are using for order entry.
    Hope this helps you.
    Thanks,
    Arun.S

  • Adding text to a button, and related button fun

    Ok, I'm new to AS3 (only been doing it for a couple weeks
    now, never really learned AS2), so help would be great, especially
    as the deadline was more then a week ago (not all my fault there)
    I put a text field inside a button and tried to put text in
    that button's text field via the following:
    hmm.. I'm new to the forum I guess... don't know if it added
    the code, the code is: instancenameofbutton.textfieldinstance.text
    = "play";
    Well that seems not to work... so how do I make it obey my
    auth-or-a-tah?
    Am I perhaps just slash dot syntax impaired?
    Trouble seem to be that putting text over the button blocks
    the event.. Is there another way to skin this cat?
    A related problem I haven't been able to fix is.. I have a
    text field with dynamic text.. numbers, and I want it to be bold.
    Where I'm at in trying to figure out the solution is that bold
    dynamic text needs to be specially embedded.. Well, I follow what
    the help system tells me to do.. and nothing seems to actually
    work. Is there a bug here or something?
    Ok, one last related thing.. I'm following the book on
    "things thou shalt not do" in that I have a good amount of moving
    transparent gradients... well 2 of them actually.. but then other
    transparent stuff all over the place that.. could be pushing things
    a little far. The frame rate's about 14 fps, screen size is only
    about 600x450, I am on an 8 core mac pro with a better then
    standard graphics card... seems to me that I've been able to get
    away with worse on older version of Flash on a G3 power mac bad in
    the day....
    Well when I tried to dynamically load mp3s, that's when
    things started going down hill! now buttons blink, sometimes aren't
    responsive at all.. I'm thinking maybe its that I've over laded the
    player and ought to think pulling back...
    I have on gradient spinning shape thing that I was
    controlling by actionscript using the enter frame thing.. when I
    disabled the code.. well things worked fine again... accept that
    one of my buttons stopped working.. which is mysterious... cause as
    far as I know the code wasn't touching that at all.. so I went back
    to buggy vill, cause at least then my buttons work! (most of the
    time).
    So the only thing I can think to try and do is to try and
    optimize stuff... the projects a bit of a rush job.. so it's "a
    little hack-e" ( well I confess that at my best things are probably
    "a little" hack-e, so this is really bad)
    So I'm thinking of just changing the code over to a timer
    thing, will that make it all groovy? I mean do you think? I seem to
    remember hearing something, somewhere, about the enter frame thing
    as having some issues somewhere...
    What's also kind of strange is that stuff gets strange when
    the mp3s are loaded.. There's only 4 of them, small little
    snippets.. which probably total only about 1MB or so.. so why
    should that make it trouble? Admittedly there's not a lot of
    compression on them, and there stereo but?
    Anyway.. I guess I'm just wondering if any of this sets of
    any red flags for anyone who actually knows what they are doing..
    probably not describing things well enough.. but you know, any help
    is appreciated :)

    same questions, same answers
    I'm new to AS3 too. I know the kind of frustration you face,
    especially when it comes to finding out the how's. So I'm giving
    answers rather than telling people where to look for them (for
    now).

  • Adding a new toolbar button in IC to Save the transaction

    Hi,
    I want to add a new custom button to my IC Toolbar which would do save. I have gone through some blogs( http://it.toolbox.com/blogs/sap-crm/how-to-add-buttons-to-the-ic-webclient-toolbar-46764 ) and able to get a new button and subscribe an event to that button but the now which APIs to use to save the current transaction. Currently in the standard IC web UI , End button does the save and ends the call but my requirement is to only save.
    Please help on the save. I am on SAP CRM 5.2
    Thanks,
    Saurav.

    Closing this thread as I have raised same Question in other forum which is IC specific.
    Re: Adding new button in IC Toolbar to SAVE current transaction

  • Actionlistener - for multiple buttons with similar functionality

    Hi, all:
    I'm working on a calculator program and want to know how to go about making a generic ActionListener for all the functions (i.e. +,-,*,/) so that I don't have to write separate inner classes for each function (i.e. + button, - button, etc.).
    I think this generic class should be created within a method that takes parameters. The parameters are then used within the inner class.
    What I need to know specifically is whether it's possible to pass a string operator symbol (e.g. "+" or "-") as a parameter in the following context:
    class buttonListener implements ActionListener
    public void actionPerformed(ActionEvent e)
    intField1Val + intFieldVal2;
    in this case, the "+" would be the parameter that would change depending on the values provided to the method.
    Can this be done??
    I'd also appreciate any other feedback you can give m,e on this problem (i.e. how to set up the method...basic structure??)
    Thanks!!

    Hi there,
    One way to do this is as follows:
    Button plus = new Button("+");
    Button minus = new Button("-");
    public void actionPerformed(ActionEvent e) {
    String componentHit = e.getActionCommand();
    if (componentHit == "+") {
    doAddMeth(); // implemented elsewhere
    else
    if (componentHit == "-") {
    doSubMeth(); // implemented elsewhere
    ~Bill

  • Adding actionlistener to JTextArea

    I'm trying to add an actionListener to my JTextArea, so that when the user hits 'enter', the action occurs.
    sort of like this:
    JTextArea.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent ??????) {
    doSomethingToTextArea();
    but I'm having problems (e.g. how to make enter the action event, and some problem that says JTextArea can't use actionlisteners???)
    any ideas?
    thanks,
    n00bProgrammer

    Like serveral of the more complex swing gadgets the JTextarea uses model/view architecture. In this case the model behind the textarea is a Document, and the text change listener needs to be added to the Document, not the gadget itself. i.e. area.getModel().addDocumentListener();
    However JTextArea still inherits the methods of java.awt.Component including addKeyListener();

  • ActionListener in ADF button

    Hi,
    I have a button with actionlistener property as "#{bindings.CreateInsert3.execute}". How can i call the same from backingbean? i need this becausei want to set some values before this operation when someone clicks the button.Can someone give me code snippet please..
    my bean method {
    -- need to
    -- execute createinsert
    Thanks,
    Lakshmi.

           public BindingContainer getBindings() {
            return BindingContext.getCurrent().getCurrentBindingsEntry();
        public String createInsert() {
            BindingContainer bindings = getBindings();
            OperationBinding operationBinding =
                bindings.getOperationBinding("CreateInsert3");
            Object result = operationBinding.execute();
            if (!operationBinding.getErrors().isEmpty()) {
                return null;
            return null;
        }

  • Problems adding  url link to buttons in action Script 3

    each time I added it link 1 to the button on file i get these error messages-  
    1046: Type was not found or was not a compile-time constant: link1.
    1180: Call to a possibly undefined method link1.
    Warning: 3594: exec is not a recognized method of the dynamic class RegExp. var r:Object = p.exec(s);  
    This is the code I am using:   import flash.net.navigateToURL; import flash.net.URLRequest;  var link_one:link1;  link_one = new link1(); stage.addChild(link_one);  link_one.addEventListener(MouseEvent.CLICK, buttonClickHandler);  function buttonClickHandler(event:MouseEvent):void { var url:String = "http://www.masterpiececorp.com/ARMREF.htm"; var request:URLRequest = new URLRequest(url); navigateToURL(request); }    I have no other problems with link 3 or 4, just link 1  I still cannot get my urls link to movie clips on the flash  
    Can you upload flash here? if not I have a image capture I can use to have you look at my buttons  and action script code. i have been to every forum I know and not any have been helpful at all. This is my last hope.
    Very frustrated newbie  Gina T
    Message was edited by: gtaylor0406

    The way you had your code originally would be correct...
    var link_one:link1;
    link_one = new link1();
    addChild(link_one);
    The 1046 error is indicating it doesn't recognize the link1 class.  So the first thing you need to make sure of is that you have assigned the link1 class designation to whatever symbol that is in the library.

  • Adding actionscript to a button?

    For some reason, my actionscript on my button is not working.
    I did a button in Photoshop, imported into the library, dragged it
    onto the stage and what it does is fade in and then stays normal,
    which I have converted into a button. But now when I click that
    button and add actionscript:
    "on (release) {
    getURL("
    http://www.google.com");
    It doesn't work for some reason. =/
    my problem:
    http://mu.thesixthdesign.com/banner_backupExact.html
    Try clicking 'free trial' or demo'; I haven't added any
    actionscript to most of the other buttons yet, since it's not
    working. >_<
    Any help is super appreciated.

    Adriennee wrote:
    > For some reason, my actionscript on my button is not
    working. I did a button in
    > Photoshop, imported into the library, dragged it onto
    the stage and what it
    > does is fade in and then stays normal, which I have
    converted into a button.
    > But now when I click that button and add actionscript:
    >
    > "on (release) {
    > getURL("
    http://www.google.com");
    > }"
    >
    > It doesn't work for some reason. =/
    Action looks a OK.
    Perhaps you apply it after you apply the tween ?
    If you add action after you add the tween, the action only
    appear
    on first or last frame of the tween, not throughout.
    Try to add an action first than apply the tween.
    Other than that... not sure, it all looks ok.
    Perhaps you could upload it somewhere so we can check out the
    source
    file.
    Best Regards
    Urami
    !!!!!!! Merry Christmas !!!!!!!
    Happy New Year
    <urami>
    If you want to mail me - DO NOT LAUGH AT MY ADDRESS
    </urami>

  • Adding Script to a Button?

    Is there a way to add JavaScript to a button when creating an Interactive PDF in InDesign (CS6)? This Interactive PDF is being turned over to other developers, who need to tack on a Certificate/Completion process, which is called to from a script that I need to place in the document somewhere.
    Other issues: I know this is probably doable by opening the interactive PDF in Acrobat and adding the script from there - but I have to save the Interactive PDF as a SWF (the developers' process eliminates interactivity from a PDF.)
    Any ideas? Help?

    Perhaps the definition of windows is the issue. Flash swf
    movies are self
    contained in a web browser window web page. So opening an
    external image in
    a MovieClip is simply redrawing the Flash swf.
    If you are thinking of windows within the Flash movie, they
    will have to be
    within the confines of the Flash movie that is first
    launched. You can have
    MovieClips with externally loaded content appear as windows
    and even be
    draggable, but they will not be a separate web browser
    window.
    If you need the web browser to open another window and then
    load another
    Flash movie in it that does the loading, then you need to use
    getURL("
    http://www.domain.com/pagewithotherflashmoviecontainingloadjpg.html/",
    "_blank");
    However it seems it would be less files to simply use html in
    the other
    window page to show the jpg without the Flash movie doing the
    loading unless
    you are using Flash to animate the jpg in some fashion like a
    fade in or
    out.
    Lon Hosford
    www.lonhosford.com
    Flash, Actionscript and Flash Media Server examples:
    http://flashexamples.hosfordusa.com
    May many happy bits flow your way!
    "Chicca81" <[email protected]> wrote in
    message
    news:e92am7$58n$[email protected]..
    >I need some help to understand and find a way to script
    the loading of
    >pictures
    > on different window. I already tryed to use behaviours:
    adding the
    > following
    > script to a button:
    >
    > on (release) {
    >
    > //load Graphic Behavior
    > _root.Contenitore.loadMovie("Cornice 10.jpg");
    > //End Behavior
    >
    > }
    >
    > When I do test the movie though I realised that it
    doesn't work as I
    > expected.
    > The picture "Cornice 10" loads on a what I think to be a
    new window: the
    > Movie
    > Clip "Contenitore" but it doesn't appear to a different
    window. How should
    > I
    > procede then?
    >

Maybe you are looking for

  • FF805 Error tax statement item missing for tax code

    I am getting the above error when am trying to release an invoice to accounting in VF02. We are using a pricing procedure that contains US tax conditions and Europe tax conditions and the European condition has got determined according to the access

  • Switch conditionals

    Hello all i'm working on a homework assignment in where we created a match game.  It's up to me to figure out how to tell the action script which difficulty the user play the game at.  There are 3 buttons easy, mediym, hard.  Each one lays out an inc

  • Cost assignment check in IT 0015

    Hi all, I have to do additional cost assignment check in IT 0015. There are only few allowed combinations of fund, fund area and WBS element. Allowed combinations are stored in table FMBASOBJNR. After click on "Maintain cost assignment" is called FM

  • Can I use Oracle SQL Developer to "Move" data?

    Hello, I'm new to Oracle and I'm trying to use Oracle SQL Developer to export data from one table (on server A) to another table (on sever B). I'm able to create a .ldr file but I don't know how to use the .ldr file in Oracle SQL Developer? I would a

  • Iphoto error message

    Help! I've spent weeks scanning and uploading photographs to iphoto, now to find that half of the thumbnails can't be expanded, edited or exported. When I double click on them I get this grey exclamation point in a triangle. What gives? I'm running o