Buttons, events and hassle!

This is my first post and I have skimmed the forum search for an answer but got nowhere!
I have a problem with compiling some simple examples I found in a few books - but its not working :-(
Here is the basic code:
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class Buttonadder extends Applet
     private Button button;
     public void init() {
     button = new Button ("push me!");
     button.addActionListener(this);
     add(button);
     public void paint(Graphics g) {
          g.drawString("Welcome to Java!!", 50, 60 );
This tells me that there is a fault with the addActionListener - it doesn't like the . before button.
However, when I add the line - implements ActionListener - after Applet I get the following error!
C:\Program Files\Xinox Software\JCreator LE\MyProjects\buttonadder\Buttonadder.java:17: Buttonadder should be declared abstract; it does not define actionPerformed(java.awt.event.ActionEvent) in Buttonadder
public class Buttonadder extends Applet implements ActionListener
Anyway - my question is, as I am using Java 1.3.1_01 - do I need to upgrade my Java or is that going to make it even harder to find examples which work?
The concept of Java is cool, but its soo frustrating trying to learn it while all the rules keep changing!!!
Oli

ButtonListener is an interface which has a bunch of methods
any class that implements it MUST define. This is what
interfaces do, it is a way of assuring things will provide certain
functionality. To see what methods you need to implement in your
Applet now that you implement ActionListener look at the API to the
left of the screen. Remember that interfaces are contracts that
the implementing class MUST meet. You will have to include
each method from ActionListener into the ButtonAdder class. Any
that you don't plan to use you can stub out with {}. Anything
you want done when the button is pushed should be included in the
actionPerformed(ActionEvent e) method.
Steve

Similar Messages

  • Problems in capturing the button event

    Hi
    I have created a BSP page with some buttons on it.
    I am trying to execute some code on click of the button, I am capturing the button in OnInput processing event using the following code
    event_data = cl_htmlb_manager=>get_event( runtime->server->request ).
    however the event_data is not getting populated with the button event and i am getting a null reference dump...
    can you tell me if i need to anything else apart from adding the above code.
    Thanks
    Bharath Mohan B

    Hi Bharrie,
    the online documentation describes this very clearly. You access it by double-clicking on the BSP Extension element in the Tag Browser.
    A brief snippet from the doco....
      DATA: event TYPE REF TO CL_HTMLB_EVENT.
      event = CL_HTMLB_MANAGER=>get_event( runtime->server->request ).
      IF event->name = 'button' AND event->event_type = 'click'.
          DATA: button_event TYPE REF TO CL_HTMLB_EVENT_BUTTON.
          button_event ?= event.
      ENDIF.
    Cheers
    Graham Robbo

  • I've set up an event and published it, but it won't allow for registrations.  The SUBMIT button is grayed out.  Thoughts?

    I've set up an event and published it, but it won't allow for registrations.  The SUBMIT button is grayed out.  Thoughts?

    The submit button is greyed out in case the registration page is being viewed in preview mode.
    Please check if the following string is present in the event registration URL:
    "preview=true"
    If it is present, please try by removing this string.
    Thanks,
    -Nitin

  • How to Capture Button event on TrainBean navigation

    Hi All
    i m being required to capture a button event in train bean Navigation, i m doing customization in Iexpense Module,here in Create IExpenseReport i need to capture the events of Remove,Return etc.how is it possible any clue would be very helpful.
    Thanx
    Pratap

    try this..
    if (GOTO_PARAM.equals(pageContext.getParameter(EVENT_PARAM))
    "NavBar".equals(pageContext.getParameter(SOURCE_PARAM))
    // This condition checks whether the event is raised from Navigation bar
    // and Next or Back button in navigation bar is invoked.
    int target = Integer.parseInt(pageContext.getParameter(VALUE_PARAM));
    // We use the parameter "value" to tell use the number of
    // the page the user wants to visit.
    String targetPage;
    switch(target)
    case 1: targetPage = "/oracle/apps/dem/employee/webui/EmpDescPG"; break;
    case 2: targetPage = "/oracle/apps/dem/employee/webui/EmpAssignPG"; break;
    case 3: targetPage = "/oracle/apps/dem/employee/webui/EmpReviewPG"; break;
    default: throw new OAException("ICX", "FWK_TBX_T_EMP_FLOW_ERROR");
    HashMap pageParams = new HashMap(2);
    pageParams.put("empStep", new Integer(target));
    pageContext.setForwardURL("OA.jsp?page=" + targetPage,
    null,
    OAWebBeanConstants.KEEP_MENU_CONTEXT,
    null,
    pageParams,
    true, // Retain AM
    OAWebBeanConstants.ADD_BREAD_CRUMB_NO, // Do not display breadcrumbs
    OAWebBeanConstants.IGNORE_MESSAGES);
    --Prasanna                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Not able to capture button event in pageLayout Controller

    Hi Guys,
    I have the following layout
    pageLayout ------------------------ pageLayoutCO (controller)
    ----messageComponentLayout (Region)
    ----------messageComponentText (item)
    ----------messageComponentText (item)
    ----------messageComponentText (item)
    ----------messageLayout (Region)
    ----------------header(Region)
    ----------------------button (item) (say BTN1) (fires partial action)
    I am not able to capture the event fired by the button BTN1 in the controller of the pagelayout..... but if i set a controller at the messageComponentLayout iam able to capture the event.
    what should i do in order to capture the button event in the pageLayout Controller
    Thanks in advance
    Tom.

    Tom,
    Two things:
    1)The button ur using is of type submitbutton or button?.In this scenario it should be button.
    2)The correct coding practice is using:
    if("QUERY".equals(pageContext.getParameter(OAWebBeanConstants.EVENT_PARAM)))
    instead of
    String _event = pageContext.getParameter("event");
    if("QUERY".equals(_event))
    because you never know if Oracle in any upgrade or patch change the value of the constant EVENT_PARAM in class OAWebBeanConstants.
    3)If first point is followed by you, just match the exact event name in code and in property inspector for the button.
    --Mukul
    --Mukul                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Crazy iCal - doesn't show any events and to-dos

    My iCal is going crazy. It all started with an inspector popup not closing. I clicked on "Done", but it just stayed there. I switched to a different week, it stayed at its position. I closed the window, it disappeared, but when I reopened the popup it was here again.
    Then I restarted iCal and it was finally gone. But then even more strange things happened. I was doing some more "intensive" iCal-work. I exported/imported two calendars to merge them with others, I switched some events to different calendars, I edited some events, and did some copy/paste from repeating events (there was a warning message that only a single event will be copied). At some point there was again a strange behavior, I cut/pasted an event, but pasting didn't work. Then I pressd Command-Z to undo the cut, the event reappeared, I copied it and pasted it somewhere else. Then the events started to disappear. First the one I was editing. It was just gone. I switched to the previous week and back, and then no events were there anymore. In the other weeks there were still some (if I remember right), but when I switched to month-view - everything gone. The to-dos were still there. I restarted iCal, nothing, I restarted the Mac, nothing. Now even the to-dos are gone, although I can still see them in Mail.
    It gets even worse: The left and right arrow-buttons to switch to a different day/week/month stay pressed when I click them until I click the day/week/month button. I have never seen anything like that before. I can not check/uncheck any calendar, the "today" button is greyed out. When i switch from month-view to day-view sometimes on the top you can still read half of "June 2009" from month-view.
    I checked the files ~/Library/Calendars. I think the events are still there, I can view all the events (I think) in Quicklook. Also, the to-dos are still visible in Mail. It must be an iCal problem. After restarting iCal a couple of times the to-dos reappeared.
    Any ideas?
    [Update:]
    Some events just reappered magically, among them the automatically imported birthdays from address book, but the dates are wrong. A friend whose birthday is on May 9th (that's a Saturday this year) appears now every week on Saturday!
    Message was edited by: Sebastian300

    :S,
    Sorry, missed that fact. My memory is good, but short.
    Try moving the "Calendar Cache" file to your Desktop. Quit iCal, and find the "Calendar Cache" file in your Macintosh HD/Users/yourusername/Library/Calendars. Move that file to your Desktop. After that, (I remember that I recommended this before), as long as you are moving files to the Desktop, repeat the plist removal procedure once again, log out/in or restart.
    You should also consider removing the "To Do's" from Mail before restarting iCal. When you open iCal turn off "Show Birthdays calendar" in iCal>Preferences...>General.
    Are you syncing any data? If so, what method(s) are you using?
    ;~)

  • How to show a message in a form 'PL/SQL Button Event Handler'

    We need validate the sal of an employee, and if it is bigger the value musts
    not be inserted.
    We trying a code like the one shown in the note 134312.1 'HOW TO PASS A
    PARAMETER FROM A PORTAL FORM TO A STORED PROCEDURE' and it works in the insert event of the insert button (using 'PL/SQL Button Event Handler') and it works, but we need to show a message that says the data wasn't inserted. How can we do this?
    The code we used is:
    declare
    v_deptno scott.emp.deptno%type;
    v_empno scott.emp.empno%type;
    v_sal scott.emp.sal%type;
    mySal scott.emp.sal%type;
    v_string varchar2(256);
    blk varchar2(10):='DEFAULT';
    begin
    select sal into mySal from scott.emp where empno=7369;
    v_deptno:=p_session.get_value_as_number(p_block_name=>blk,
    p_attribute_name=>'A_DEPTNO');
    v_empno:=p_session.get_value_as_number(p_block_name=>blk,
    p_attribute_name=>'A_EMPNO');
    v_sal:=p_session.get_value_as_number(p_block_name=>blk,
    p_attribute_name=>'A_SAL');
    v_string:='You just inserted empno: '||to_char(v_empno) ||'to deptno ->
    '||to_char(v_deptno);
    if mySal < v_sal then
    doInsert;
    else
    -- We want to display a message here, when mySal > v_sal
    end if;
    end;
    ----------------------------------

    I did something similar but wasn't using a stored procedure. Couldn't you set a flag variable once you know you're not doing the insert and in the "before displaying the form" section put an IF to check if your flag was set, and if so do an HTP.Print('You are overpaid buddy!');
    Then just reset your flag.

  • How to get a form field valud in delete PL/SQL Button Event Handler

    Hi Friend,
    I have a form. when user clicks delete button. we want to remove system dodelete function
    and add a delete script
    Under delete-top category,
    how can I get value of form EVENT_NUMBER field in form at delete PL/SQL Button Event Handler?
    DELETE FROM PTEAPP.PTE_EVENTS WHERE eventnumber = EVENT_number
    But when I try to save this form and get message as
    1721/15 PLS-00201: identifier 'EVENT_NUMBER' must be declared
    Thanks for any help!
    newuser

    I did something similar but wasn't using a stored procedure. Couldn't you set a flag variable once you know you're not doing the insert and in the "before displaying the form" section put an IF to check if your flag was set, and if so do an HTP.Print('You are overpaid buddy!');
    Then just reset your flag.

  • Where did access to button events on page 0 go?

    Hello.
    I have a simple menu system established for my applications where a select list item and a button are created on page 0.
    If I choose to "Create a button in a region position" when I establish the button (let's call it "GO_MENU", I am given the option of choosing the button event for branches on the other pages in the Conditions for the branch under "When Button Pressed". So far so good.
    However, if I choose "Create a button displayed among this region's items" when I establish the button, the button does not appear in the LOV for the "When Button Pressed" condition in the branches for any of the other application pages. What's magical about this choice that suppresses the availability of the button event from the other pages?
    Thanks,
    Vini

    Vini,
    For your branch,
    use condition type: "Request = Expression 1"
    expression 1 = P0_GO_MENU
    Why it doesn't show your page item button in the LOV? Because it's not a standard button anymore...
    I don't have other information... someone from the ApEx dev team should be able to give more technical explanation.
    Louis-Guillaume
    Homepage : http://www.insum.ca
    Blog : http://insum-apex.blogspot.com

  • Htp.p doesn't work from the custom button event handler ...

    Hi,
    I am trying to pop up an alert from the custom button event handler. I created a button and put the following code.
    htp.p('<script language='JavaScript1.3">
    alert ("Test Message");
    </script>;
    But alter doesn't show up after clicking the button.
    Thanks

    OK i've attached them and copy/pasted the relevent parts. The parent window is the SFLB file.
    -----------------------------------------here's the code in the parent window
    private function editServerPool():
    void
    serverPoolPUW = PopUpManager.createPopUp(
    this,popups.ServerPoolPopup,true);PopUpManager.centerPopUp(serverPoolPUW
    as IFlexDisplayObject); 
    if (newServerPool.SecondarySPAlgorithm != null){
    serverPoolPUW.enableSSCheckBox.selected =true;serverPoolPUW.DisplaySecondaryServerPool();
    serverPoolPUW.bigResize.play();// serverPoolPUW.height = 602; //yes...i know i need to move thisserverPoolPUW.switchoverPolicyCB.selectedItem = newServerPool.SwitchOverPolicy;
    serverPoolPUW.switchoverThresholdTI.text = newServerPool.SwitchOverThreshold;
    ----------------------here's the code in teh popup window (popups.ServerPoolPopup.mxml)
    <mx:Resize id = "bigResize" heightFrom="506" heightTo="602" target="{this}" /> 
    <mx:Resize id = "littleResize" heightFrom="602" heightTo="506" target="{this}"/>
     public function DisplaySecondaryServerPool():void{
    //make the screen large if the secondary server checkbox is selected; otherwise small.  
    if (enableSSCheckBox.selected){
    //display secondary server pool tab, expand the screen 
    //note that we cannot attach a data provider to the data grid until the grid creation is  
    //completed. This is done in an event handler.secondaryPanel.enabled =
    true; switchoverPolicyCB.visible =
    true;switchoverThresholdTI.visible =
    true;thresholdFI.visible =
    true;policyFI.visible =
    true;bigResize.play();
    else
     <mx:CheckBox label="Enable a Secondary Server Pool" width="264" fontWeight="bold" click="DisplaySecondaryServerPool()" id="
    enableSSCheckBox" fontSize="12" x="83" y="40"/>

  • Questions about buttons: onRelease and on(release)

    I have been experimenting with buttons lately and am trying to use a function that uses the release mouse event. I was a little confused at first, since I found some tutorials that used onRelease() and some that used on(release) {...can somebody explain the differences to these and how to use either of them?

    if you're using as2, both onRelease and on(release) can be used.  on(release) is attached to the button or movieclip (highly undesirable) and onRelease is attached to a frame using the button/movieclip's instance name:
    // if your objects instance name is your_btn:
    your_btn.onRelease=function(){
    // code here
    if you're using as3, neither will work.

  • [JClient 9.0.3] Trapping events and canceling actions

    Subject: [JClient 9.0.3] Trapping events and canceling actions
    I'd like to be able to, based on some condition, abort certain
    actions (navigate, delete, insert, etc, etc) when the appropriate
    events have been fired.
    E.g., in case the Transaction is dirty and when I navigate to a
    certain row in a certain ViewObject instance, I would like to
    intercept this action and let the user decide what to do:
    Commit/Rollback/Cancel. Of cource when 'Cancel' is selected, the
    navigation-action should be aborted at all.
    I have realised this functionality by subclassing JUNavigationBar
    and either calling super's actionPerformed() or not. This works
    perfectly, but of course there are other means to navigate (a
    JComboBox + NavigationBinding, a JTable or programmatically), so
    I would need to implement similar functionality for each of these
    component types.
    So, what I need to do is to intercept these actions on a lower
    level. It appears that I need to register RowSetListeners to
    ViewObject instances, but as far as I can tell, this way there
    isn't a real way to abort these actions once they are started.
    Am I pherhaps overlooking something? Any help and/or suggestions
    would be greatly appreciated.
    Arno

    Subject: [JClient 9.0.3] Trapping events and canceling actions
    I'd like to be able to, based on some condition, abort certain
    actions (navigate, delete, insert, etc, etc) when the appropriate
    events have been fired.
    E.g., in case the Transaction is dirty and when I navigate to a
    certain row in a certain ViewObject instance, I would like to
    intercept this action and let the user decide what to do:
    Commit/Rollback/Cancel. Of cource when 'Cancel' is selected, the
    navigation-action should be aborted at all.
    I have realised this functionality by subclassing JUNavigationBar
    and either calling super's actionPerformed() or not. This works
    perfectly, but of course there are other means to navigate (a
    JComboBox + NavigationBinding, a JTable or programmatically), so
    I would need to implement similar functionality for each of these
    component types.
    So, what I need to do is to intercept these actions on a lower
    level. It appears that I need to register RowSetListeners to
    ViewObject instances, but as far as I can tell, this way there
    isn't a real way to abort these actions once they are started.
    Am I pherhaps overlooking something? Any help and/or suggestions
    would be greatly appreciated.Yes you're right in saying that there are many ways one could perform navigate - by other controls, by calling next() on the VO or even on the RowSetIterator. Also BC4J does not generate 'events' before navigation to preempt navigation unless a row is 'modified' in which case RowValidation events are generated for the Entities modified in that row.
    The most generic way you may fix this is by 'listening' to rowsetiterator's navigation events and get the PreviousRow from the navigation events and set focus back to it if user presses cancel, or get the current RowKey and let the user commit/rollback and then restore the currency to a row with that rowkey (just in case the MT is set to clear all caches on commit/rollback transaction boundaries). Note that insert/delete events should not be handled this way as those event points are usually generated due to a button action and it's easier to preempt these actions rather than 'let the actions' complete and then perform a rollback-to-a-particular-point.
    Arno

  • Execute procedure in pl/sql button event handler

    i have a demo application which consists of text boxes
    eg : when i enter department no in first text box and click proc
    it should display dname and loc in the below text boxes.
    my proc is working fine in sql*plus but its showing errors in pl/sql button event handler.
    any ideas
    my proc is create or replace procedure proc1 (no number)
    as
    DNAME1 dept.dname%type;
    LOC1 dept.loc%type;
    begin
    select DNAME,LOC into DNAME1,LOC1 from scott.dept where deptno = no;
    DBMS_OUTPUT.PUT_LINE (DNAME1);
    DBMS_OUTPUT.PUT_LINE (LOC1);
         Exception When No_Data_Found then
    dbms_output.put_line('Entred name is not found');
    When Others then
    Null;
    End;
    /

    Hi,
    you have to use
    htp.p('<SCRIPT LANGUAGE="Javascript1.1">
    document.all("FORMNAME.DEFAULT.ATTRIBUTENAME.01").value="'||DNAME1||'";
    document.all("FORMNAME.DEFAULT.ATTRIBUTENAME.01").value="'||LOC1||'";
    </SCRIPT>
    instead of
    DBMS_OUTPUT.PUT_LINE (DNAME1);
    DBMS_OUTPUT.PUT_LINE (LOC1);
    where formname is your form name and attribute name is the field name on the page.

  • Custom Event and Custom Expression Deletion in PCW

    Hi Sap Gurus,
    How can i delete the custom event and custom expression created by me in process controlled workflow... I have observed the deletion button grayed out... Is there any other option to delete the custom event and expression.
    Thanks in advance

    Hello Sanjay,
    check below thread:
    BRF - Can not delete expression
    Regards.
    Laurent.

  • Handling Button Event

    Hi all,
    i am using a 'When-Validate-item' trigger in this i am doing a validation,
    when user try to enter amount greater than the given amount(This is needed validation)
    and also i am regenerating new lines(Creating new records when button pressed)
    when i am regenerating i should not validate.
    How to handle button event
    Thnx
    Raj

    Hi...
    The WHEN-VALIDATE-ITEM Trigger fires once you updated a field. Be sure you raise
    form_trigger_failure when amount is invalid. So, the cursor stays in field amount. You cant
    leave this field until the amount is not valid.

Maybe you are looking for

  • DW8 - Need help with Flash Mirror Gallery by Flashdevelopment24

    I just purchased an image viewer called Flash Mirror Gallery by Flashdevelopment24: http://www.flashdevelopment24.com/extensions/flash_photo_gallery_06.aspx I use DW8. Unfortunately the wizard and the instructions are WAY beyond me. I can insert the

  • Answers - Columns and aggregation of measures

    Can I bring in data at a line item (Order_ID) level in Answers do some calculations around a metric returned, then be able to hide/remove this column in a table and have the metrics be aggregated up to the other level - say if I bought in Region? I h

  • Apps freeze during update in iOS 8.02

    After updating to 8.02 I am having my ipad freeze during the app update process.  I get the circle but the ring fails to show any download progress. If I touch the circle it returns to the update button?  This on a new iPad air

  • Remove graphic symbol in IW28/IW29

    Hi experts, is there a way to remove the graphic symbol on the top in IW28/IW29 without a modification? Thanks in advance! Regards, Tobi

  • Where can i find Bios Update for K450e

    Hi can anyone direct me where i can find the BIOS update for a K450e thanks.... a link would be great....