Handling Buttons

There are multiple buttons (JButton) with the same label on a frame. In the actionlistener how do i recognise which was the button pressed. Please help me out.
regards,
amar

Options
1. Have one listener per button. This makes even more sense if the buttons are unrelated -- why use the same listener
for "find" and "redo"? When doing this, using Action can be a useful for encapsulation.
2. If listening to more than one button, use the ActionEvents getActionCommand to distinguish them. This is the button's
text by default, but you can set this property for the button if needed.

Similar Messages

  • 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.

  • Handling button events in large app

    I'm currently examining a large swing app, and have observed the following with regard to action events.
    A number of listeners (for buttons, menu items, JLists etc.) are defined at the top of the app. These variously extend MouseAdapter or implement ActionListener, depending on the type of component whose actions they listen for.
    The ButtonListener definition is as follows :
    private class ButtonListener implements ActionListener
    public void actionPerformed(ActionEvent event)
    Object object = event.getSource();
    if (object == button1)
    // button1 actions
    else
    if (object == button2)
    // button2 actions
    .....etc
    One instance of this listener is created in the app, and is used as the actionlistener for each button. This means that the buttonlistener is quite large (as it contains the code for each button in the app).
    Is this the proper way to handle button events for an app with a large number of buttons?

    Thanks for the responses.
    In response to theDude : I agree that defining the action listener for each button can be useful when you can see the button definition and button action in one place; one could counter that by saying that grouping all the button actions makes it easier to examine all button actions in one place.
    Setting the action command isn't really an option because the application creates panels of buttons on the fly, e.g. when notification of a new customer is received, a new panel is created with a JTextPane (customer description) and a row of buttons for "Modify", "Delete" and "Print".
    Several customer panels could be in existence at the same time, so setting an action command of "Modify" would not enable one to uniquely identify which "Modify" button was pressed.
    This problem is currently handled by associating the panel instance with a "Customer" class instance in a hashtable. The "Customer" class consists of a JTextPane field, and a JButton for each function. When a button is pressed, the button listener traverses up the component's parents until it reaches the panel (i.e. it loops until the parent is a key on the hashtable, at which point it can retrieve the Customer instance and check which button was pressed).
    In response to KPSeal : If I understand you, I would define "ApplicationAction" separately from the main app and define extensions of it in the main app for each type of action. Would this add much value over merely defining a method for each type of action in the main app and just calling this method when the relevant button/menu item was pressed/selected?
    There doesn't seem to be a universal approach to event handling, but I thought there might have been one accepted strategy when an app has large numbers of buttons (some created on the fly, ruling out action commands).

  • Handling button events for dialog boxes of a used component

    Hello,
    After I call a dialog box/window for the view of the used component, how can I handle the button events of the window that I called?
    I create the window using the method CREATE_WINDOW_FOR_CMP_USAGE of the interface IF_WD_WINDOW_MANAGER. This method returns window reference of type IF_WD_WINDOW.
    Thanks & Regards,
    Reena

    It's very easy.
    Have a look to the document: https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/9e242bf5-0901-0010-c99c-83c180163c73
    You will find the SUBSCRIBE_TO_BUTTON_EVENT on page 6.
    Sergio

  • Best Way to Handle Buttons

    I have a complex button graphic that I use for all the
    buttons in my Flash project. Currently, for every different button
    function I need, I've duplicated the button and linked it to a
    separate class. So if I need buttons that link to rules, credits,
    playgame, and the main menu, I've got 4 separate button symbols and
    4 separate classes.
    Is there a better way handle this?
    And one other thing. All of my classes are in the "game"
    package. I tried putting the buttons in a "game.buttons" package,
    but then I could not access the classes in the "game" package, so I
    could not go:
    (parent as Main).gotoAndStop('Credits");
    because it didn't know what "Main" was. (Main is a class in
    the "game" package.) What do I need to do to fix this.?
    Thank you.

    I would create a hidden page item on Page 14 (P14_CALLING_PAGE) and set it via the URL to the appropriate calling page (8 or 12). In other words, when Page 8 navigates to Page 14, it would set P14_CALLING_PAGE to 8 and when Page 12 navigates to Page 14, it would set P14_CALLING_PAGE to 12
    Now, you can create your Cancel button with a URL Redirect of &P14_CALLING_PAGE.
    This way, when Page 14 is rendered, the Cancel button will be configured to go the appropriate "calling page"
    Hope this helps.

  • [iphone] Handling button touch events

    I have a view controller which contains a view which in turn manages 2 subviews that take up the entire scree, think like a playing card, where the 2 subviews simulate the front and back of the same card. When the user taps anywhere on the card, the card flips to show the other side. I have added a button to the card but when I tap within the button, it still triggers the main event to flip the card, not the action associated to the button. How do I make this happen? Thanks

    Wups, hit Enter too fast:
    Here's what I am doing:
    1. Create UIViewController
    2. Add a UIVew subclass instance to it. Can override touchesBegan in this object.
    3. Add a UIWebView subclass instance to UIView as a subview.
    The UIWebView seems to be eating all events silently. I override touchesBegan inside of it, and my printf statement doesn't ever get called, so I am suspecting that touch events are not handled by this class, even though it does inherit from UIView.
    Anyone have any ideas?
    Thanks!
    RC

  • Unable to handle button click

    Hi,
    I am trying to handle a spelVO on the click of a button by using
    pageContext.getParameter("itemname") != null
    However this condition is always being true
    Edited by: 951298 on Aug 7, 2012 10:04 AM
    Hello,
    Thank you for the response, I was able to solve my problem I was using the code in processRequest instead of processFormRequest
    Edited by: 951298 on Aug 8, 2012 11:45 AM

    Hi,
    Can you provide the exact code that u r using.
    Are u using PPR on this button?
    --Sushant                                                                                                                                                                                                       

  • How to handle Button pressed event

    Hi,
    I need some help in button presing handle event. I have Button B1 and L_1 (it is LOV). I want realize next: When I press button B1 List of value L1 shows, but the value in list is selected it hides. Any help plz.
    Thanks.
    Edited by: go0ze on 2011.13.6 23:30

    Hi,
    I need some help in button presing handle event. I have Button B1 and L_1 (it is LOV). I want realize next: When I press button B1 List of value L1 shows, but the value in list is selected it hides. Any help plz.
    Thanks.
    Edited by: go0ze on 2011.13.6 23:30

  • Click handler button function to control symbols

    Hi,
    I have a remote control image which has 2 buttons (Slide button & Bar Graph button).  Thanks to help from resdesign the first button controlling a slideshow of 15 images works.  In the slideshow there are question slides that need to launch an animated bar graph symbol showing the results.  I'm able to launch the first bar graph for slide 3.  I'm using the container method to place the bar graph on the stage.  The bar graph symbol can be closed using a click event from within the symbol.   Here are my questions:
    How to toggle the bar graph off OR delete the bar graph symbol when the Bar Graph button is clicked again.
    How to prevent multiple instances of the bar graph from launching in the container?
    How to close the bar graph if the user advances to the next slide? 
    Here's the code to control the Bar Graph button on compositionReady:
    var bgOn = false;
    sym.$("buttonbg").click(function(){
                        if (bgOn == false) {
                        sym.createChildSymbol("bg1", "bargraph_container3");
                        var container =  sym.getSymbol("bargraph_container3");
                        sym.container("bg1").play();
                        bgOn = true;
                        else {
          sym.deletesymbol();  //If bar graph symbol is already on, when buttonbg is clicked again then delete "bg1"
          bgOn = false;  // reset to false, click will relaunch "bg1"
    Here's the project file.
    http://dl.dropbox.com/u/10647145/necc_viewer_nov2012.zip
    Thanks for your time,
    -Robert

    ==> file attached.
    1) Symbol "stage", compositionReady:
    sym.bgOn = false;
    sym.$("buttonbg").click(function(){
    if (!sym.bgOn) {
    sym.bg1 = sym.createChildSymbol("bg1", "bargraph_container3").play();
    //var container =  sym.getSymbol("bargraph_container3");
    //container("bg1").play();
    sym.bgOn = true;
    } else {
    sym.bg1.deleteSymbol();  //If bar graph symbol is already on, when buttonbg is clicked again then delete "bg1"
    sym.bgOn = false;  // reset to false, click will relaunch "bg1"
    2) Symbol "bg1", close.click:
    sym.getParentSymbol("bargraph_container3").getParentSymbol("Stage").bgOn = false;
    sym.deleteSymbol();

  • Help needed to handle buttons in the screen

    hi
    i have two buttons in my screen say button1 and button2
    by default when i display this screen as per my requirement only button1 should be visible and button2 should be invisible
    button2 should only be visible when i click on my first button i.e. button1.
    where and how to code this
    vamsi

    Hi
    You can use Modification groups while declaring the buttons. Assume we assign group1 as B1 for button1 and B2 for button 2.
    fcode for button1 as BUT1 and fcode for button2 as BUT2.
    at pbo
    if sy-ucomm = 'BUT1'.
    loop at screen.
    case screen-group1.
      when 'B1'.
         screen-active = '0'.
         modify screen.
    when 'B2'.
         screen-active = '1'.
         modify screen.
    endcase.
    endloop.
    else.
    loop at screen.
    case screen-group1.
      when 'B2'.
         screen-active = '0'.
         modify screen.
    when 'B1'.
         screen-active = '1'.
         modify screen.
    endcase.
    endloop.
    endif.
    Regards,
    Navneet

  • Handle button event of popup created from component controller

    Hi all,
    I have created a method for created popup in the component controller with button kind 'yes-no'.Now i use it in the view.
    Till here all is working fine.
    Now i want to use the events which triggers on the popup (yes, no).Any idea how to trigger these buttons action.
    The problem i am facing here is: When i use <b>subscribe_to_button_event</b> method it does not working.
    Any ideas how to use this.
    Points will be sured.
    Sanket sethi

    hi sanket.........
    here is a code snippet... check this out.
    data: l_cmp_api          type ref to if_wd_component,
            l_window_manager   type ref to if_wd_window_manager,
            l_popup            type ref to if_wd_window,
            l_text             type string_table,
            l_api              type ref to if_wd_view_controller.
      l_cmp_api        = wd_comp_controller->wd_get_api( ).
      l_window_manager = l_cmp_api->get_window_manager( ).
      insert `Data where changed` into table l_text.   
      insert `Do you want to save?`        into table l_text.   
      l_popup = l_window_manager->create_popup_to_confirm(
                    text            = l_text
                    button_kind     = if_wd_window=>co_buttons_yesnocancel
                    message_type    = if_wd_window=>co_msg_type_question
                    window_title    = 'Test: Popup to confirm'
                    window_position = if_wd_window=>co_center ).
      l_api = wd_this->wd_get_api( ).
      l_popup->subscribe_to_button_event(
                   button            = if_wd_window=>co_button_yes
                   action_name       = 'YES'
                   action_view       = l_api
                   is_default_button = abap_true ).
      l_popup->subscribe_to_button_event(
                   button            = if_wd_window=>co_button_no
                   action_name       = 'NO'
                   action_view       = l_api
                   is_default_button = abap_false ).
      l_popup->subscribe_to_button_event(
                   button            = if_wd_window=>co_button_cancel
                   action_name       = 'CANCEL'
                   action_view       = l_api
                   is_default_button = abap_false ).
      l_popup->open( ).
    --regards,
      alex b justin

  • Not handling button event?

    //package com.ociweb.preferencestest;
    import java.awt.event.*;
    import java.util.prefs.*;
    import javax.swing.*;
    * A frame to test some basic functionality
    * in the Preferences API
    * @author Object Computing Inc.
    public class PreferenceTestFrame extends JFrame implements ActionListener {
    // A reference to a Preferences object
    private Preferences myPreferences = null;
    // Default values for this frame's preferences
    public static final int DEFAULT_WINDOW_X = 50;
    public static final int DEFAULT_WINDOW_Y = 50;
    public static final int DEFAULT_WINDOW_WIDTH = 300;
    public static final int DEFAULT_WINDOW_HEIGHT = 100;
    // Keys for this frame's preferences
    public static final String WINDOW_X_KEY = "TEST_WINDOW_X";
    public static final String WINDOW_Y_KEY = "TEST_WINDOW_Y";
    public static final String WINDOW_WIDTH_KEY = "TEST_WINDOW_WIDTH";
    public static final String WINDOW_HEIGHT_KEY = "TEST_WINDOW_HEIGHT";
    public PreferenceTestFrame() {
    setTitle("Preferences Test Window");
    // Obtain a references to a Preferences object
    myPreferences = Preferences.userNodeForPackage(PreferenceTestFrame.class);
    // Retrieve the location of the frame from the Preferences object
    int windowX = myPreferences.getInt(WINDOW_X_KEY, DEFAULT_WINDOW_X);
    int windowY = myPreferences.getInt(WINDOW_Y_KEY, DEFAULT_WINDOW_Y);
    // Retrieve the size of the frame from the Preferences object
    int windowWidth =
    myPreferences.getInt(WINDOW_WIDTH_KEY, DEFAULT_WINDOW_WIDTH);
    int windowHeight =
    myPreferences.getInt(WINDOW_HEIGHT_KEY, DEFAULT_WINDOW_HEIGHT);
    // Set the size and location of the frame
    setBounds(windowX, windowY, windowWidth, windowHeight);
    JButton but=new JButton("Click me");
    add(but);
    but.addActionListener(this);
    setVisible(true);
    addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent we) {
    exitApp();
    public void actionPerformed(ActionEvent e) {
         if(e.getActionCommand == "Click me" )
         setbackground(Color.blue);
    private void exitApp() {
    // Save the state of the window as preferences
    myPreferences.putInt(WINDOW_WIDTH_KEY, getWidth());
    myPreferences.putInt(WINDOW_HEIGHT_KEY, getHeight());
    myPreferences.putInt(WINDOW_X_KEY, getX());
    myPreferences.putInt(WINDOW_Y_KEY, getY());
    System.exit(0);
    public static void main(String[] args) {
    new PreferenceTestFrame();
    On compliation I get the following error:
    ---------- javac ----------
    PreferenceTestFrame.java:59: illegal start of expression
    public void actionPerformed(ActionEvent e) {
    ^
    PreferenceTestFrame.java:76: ';' expected
    ^
    PreferenceTestFrame.java:76: '}' expected
    ^
    3 errors
    Output completed (0 sec consumed) - Normal Termination
    Wheres the problem?

    sorry, the missing braces (}) should be placed below:
    addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent we) {
    exitApp();
    } //missing
    public void actionPerformed(ActionEvent e) {
         if(e.getActionCommand == "Click me" )
         setbackground(Color.blue);
    }and some other changes that u need:
    import java.awt.Color;
    e.getActionCommand should be e.getActionCommand()
    setbackground() should be setBackground()
    hth.

  • Linking Editing TextArea with Button Handler

    Java newbie here,i am trying to create a program to display a keyboard on screen and display the the letter in a text area when the character letter is pressed. And the complete sentence when return is pressed.
    I have the GUI up, the problem is the letters are dispayed in a JOptionPane and i want them to be written to the TextArea.
    Any help would be appreaciated
    Here is the code in full so far.
    import java.awt.event.*;
    import java.awt.*;
    import javax.swing.*;
    * Alphabet is a program that will display a text pad and 27 buttons of the 25
    * Letters of the Alphabet and display them when pressed and display all buttons
    * when Return button is pressed..
    * version (V 0.1)
    public class Alphabet extends JFrame
        private JPanel buttonPanel  ;
        private JButton buttons[];
        private JButton SpaceButton;
        private JButton ReturnButton;
        //setup GUI
        public Alphabet()
        super("Alphabet");
        //get content pane
        Container container = getContentPane();
        //create button array
        buttons = new JButton[122];
        //intialize buttons
        SpaceButton = new JButton ("Space");
        ReturnButton = new JButton ("Return");
        //setup panel and set its layout
        buttonPanel = new JPanel();
        buttonPanel.setLayout(new GridLayout (7,buttons.length));
        //create text area
        JTextArea TextArea = new JTextArea ();
       TextArea.setEditable(false);
       container.add(TextArea, BorderLayout.CENTER);
       // set a nice titled border around the TextArea
        TextArea.setBorder(
          BorderFactory.createTitledBorder("Your Text is Displayed Here"));
      //create and add buttons
        for (int count = 96; count <buttons.length; count++ ) {
        buttons[count] = new JButton( ""+ (char)(count +1 ));
        buttonPanel.add(buttons [count]);
        ButtonHandler handler = new ButtonHandler();
        buttons[count].addActionListener(handler);
        buttonPanel.add(SpaceButton);
       buttonPanel.add(ReturnButton);
       ReturnButton.setToolTipText( "Press to Display Sentence" ); 
         container.add(buttonPanel, BorderLayout.SOUTH);
        // set a nice titled border around the ButtonPanel
        buttonPanel.setBorder(
          BorderFactory.createTitledBorder("Click inside this Panel"));
            // create an instance of inner class ButtonHandler
              // to use for button event handling              
              ButtonHandler handler = new ButtonHandler(); 
              ReturnButton.addActionListener(handler);
            setSize (625,550);
            setVisible(true);
    }// end constructor Alphabet
    public static void main (String args[])
        Alphabet application = new Alphabet();
        application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    // inner class for button event handling
         private class ButtonHandler implements ActionListener {
              // handle button event
             public void actionPerformed( ActionEvent event )
                 JOptionPane.showMessageDialog( Alphabet.this,
                    "You pressed: " + event.getActionCommand() );
    }//END CLASS ALPHABET

    import java.awt.event.*;
    import java.awt.*;
    import javax.swing.*;
    public class Alphabet extends JFrame
    private JPanel buttonPanel ;
    private JButton buttons[];
    private JButton SpaceButton;
    private JButton ReturnButton;
    JTextArea TextArea;
    String str="";String stt="";
    //setup GUI
    public Alphabet()
    super("Alphabet");
    //get content pane
    Container container = getContentPane();
    //create button array
    buttons = new JButton[122];
    //intialize buttons
    SpaceButton = new JButton ("Space");
    ReturnButton = new JButton ("Return");
    //setup panel and set its layout
    buttonPanel = new JPanel();
    buttonPanel.setLayout(new GridLayout (7,buttons.length));
    //create text area
    TextArea = new JTextArea ();
    TextArea.setEditable(false);
    container.add(TextArea, BorderLayout.CENTER);
    // set a nice titled border around the TextArea
    TextArea.setBorder(
    BorderFactory.createTitledBorder("Your Text is Displayed Here"));
    //create and add buttons
    for (int count = 96; count <buttons.length; count++ ) {
    buttons[count] = new JButton( ""+ (char)(count +1 ));
    buttonPanel.add(buttons [count]);
    ButtonHandler handler = new ButtonHandler();
    buttons[count].addActionListener(handler);
    buttonPanel.add(SpaceButton);
    buttonPanel.add(ReturnButton);
    ReturnButton.setToolTipText( "Press to Display Sentence" );
    container.add(buttonPanel, BorderLayout.SOUTH);
    // set a nice titled border around the ButtonPanel
    buttonPanel.setBorder(
    BorderFactory.createTitledBorder("Click inside this Panel"));
    // create an instance of inner class ButtonHandler
    // to use for button event handling
    ButtonHandler handler = new ButtonHandler();
    ReturnButton.addActionListener(handler);
    SpaceButton.addActionListener(handler);
    setSize (625,550);
    setVisible(true);
    }// end constructor Alphabet
    public static void main (String args[])
    Alphabet application = new Alphabet();
    application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    // inner class for button event handling
    private class ButtonHandler implements ActionListener {
    // handle button event
    public void actionPerformed( ActionEvent event )
              if((event.getActionCommand()).equals("Space")){
                   TextArea.setText(event.getActionCommand());
                   str+=" ";
                   //TextArea.append(" ");
              else if((event.getActionCommand()).equals("Return")){
                   stt+=str;
                   stt+="\n";
                   str="";
                   TextArea.setText(stt);
                   //TextArea.append(str);
                   //TextArea.append("\n");
              else {
                   TextArea.setText(event.getActionCommand());
                   str+=event.getActionCommand();
                   //TextArea.append(event.getActionCommand());
    }//END CLASS ALPHABET
    Ok?

  • Dynamically Changing Labels for Multi Row Block Buttons

    Forms [32 Bit] Version 9.0.4.1.0 (Production)
    Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production
    On my local: Windows 7 OS
    I am having a difficult time in doing the following in forms, and not sure if it can be done?
    I have a multi row block,based on DB table, which displays filename and another column from the table.
    It also has a push button on each row, which opens and displays the physical file from its source, when clicked. The filename thus can have 3 diff statuses depending on its sources and accordingly corresponding button should display appropriate label:
    a) View Image (its is in content server and successfully imaged. In this case I display the file in the browser, from the content server, when the button is clicked)
    b) View File (Display the file from file system)
    c) View Error (Display imaging error message from the table, as file failed to make it to the imaging server)
    I have this logic currently coded in the post query trigger, at the block level, and tried using set_item_property(button_id, label, <button_lable>), where I programmatically set the button lable, based on the file status (imaged, not imaged or has error) in that row. This wroks well, only if all the files in the multi row block have the same status. If each of them have diff statuses, then only last processed files's status gets reflected into the button label. For eg: The file in the first row of the block is imaged, and one in the second row has an imaging error. The button label for the first row should say 'View Image' and button for the second row should say 'View Error'. But now buttons for both the rows display 'View Error', as thats what got processed last!
    I __can not use set_item_instance property for 'label'__ (which lets us dynamically change the label on the push buttons).
    Is there any way to do this for ORacle forms? I am now playing with having 3 diff button items in that block, laying them on top of each other and showing only those that are appropriate and hiding the others... But I am not sure it is going to give me what I need? I think I am going to end up facing the same issues as in above case!!
    Any expert advice is highly appreciated.
    Thanks in advance for your time:
    Libran_Girl
    Edited by: libran on Aug 30, 2011 8:04 AM
    Edited by: libran on Aug 30, 2011 8:05 AM

    <p>I have just updated this existing PJC, that was originally constructed to handle Text Fields. You can, now, also handle buttons with it.
    Set the Button's Implementation Class property to : oracle.forms.fd.MultiButton.
    </p>
    This is the code you have to put one triggers of your based block:
    When-New-Record-Instance trigger: (based on the EMP table)
    declare
         LN$Pos  pls_integer ;
         LN$Rec  pls_integer := Get_Block_Property('EMP', CURRENT_RECORD) ;
         LN$Max  pls_integer := Get_Block_Property('EMP', RECORDS_DISPLAYED) ;
         LC$C    Varchar2(15) ;
    Begin     
         LN$Pos :=  LN$Rec - (trunc(LN$Rec/LN$Max) * LN$Max) ;
         If LN$Pos = 0 Then LN$Pos := LN$Max ; End if ;
         If LN$Pos > 0 Then
              Set_Custom_Property('EMP.BT', LN$Pos, 'SET_LOG', 'true' );
              -- Add the new item --
              Set_Custom_Property('EMP.BT', LN$Pos, 'SET_NEW_REC', to_char(LN$Rec) );
              -- Set some properties --
              Set_Custom_Property('EMP.BT', LN$Pos, 'SET_LABEL', to_char(LN$Rec) || ',' || :EMP.ENAME );
              If :EMP.JOB = 'MANAGER' Then
                Set_Custom_Property('EMP.BT', LN$Pos, 'SET_FONT', to_char(LN$Rec) || ',Arial,bold,14' );
                Set_Custom_Property('EMP.BT', LN$Pos, 'SET_FGCOLOR', to_char(LN$Rec) || ',0,0,255' );
              End if ;
              If :GLOBAL.I > 250 Then :GLOBAL.I := 5 ;
              Else  :GLOBAL.I := :GLOBAL.I + 5 ;
              End if ;     
              LC$C := To_Char(LN$Rec) || ','
                   || To_Char(255) || ','
                   || To_Char(255-:GLOBAL.I) || ','
                   || To_Char(255-:GLOBAL.I) ;    
              Set_Custom_Property('EMP.BT', LN$Pos, 'SET_BGCOLOR', LC$C );
              Synchronize;
         End if ;
    end;When-Create-Record trigger:
    declare
         LN$N    pls_integer ;
         LN$Rec  pls_integer := :system.cursor_record ;
         LC$C    Varchar2(15) ;
    Begin     
         if get_block_property('EMP',TOP_RECORD) > 1 Then
              LN$n := :system.cursor_record - get_block_property('EMP',TOP_RECORD) + 1 ;
         else
              LN$N := :system.cursor_record ;
         end if;
         If LN$N > 0 Then
              Set_Custom_Property('EMP.BT', LN$n, 'SET_LOG', 'true' );
              -- Add the new item --
              Set_Custom_Property('EMP.BT', LN$n, 'SET_NEW_REC', to_char(LN$Rec) );
         End if ;
    end;Post-Query trigger:
    declare
         LN$Pos  pls_integer ;
         LN$Rec  pls_integer := Get_Block_Property('EMP', CURRENT_RECORD) ;
         LN$Max  pls_integer := Get_Block_Property('EMP', RECORDS_DISPLAYED) ;
         LC$C    Varchar2(15) ;
    Begin     
         LN$Pos :=  LN$Rec - (trunc(LN$Rec/LN$Max) * LN$Max) ;
         If LN$Pos = 0 Then LN$Pos := LN$Max ; End if ;
         If LN$Pos > 0 Then
              Set_Custom_Property('EMP.BT', LN$Pos, 'SET_LOG', 'true' );
              -- Add the new item --
              Set_Custom_Property('EMP.BT', LN$Pos, 'SET_NEW_REC', to_char(LN$Rec) );
              -- Set some properties --
              Set_Custom_Property('EMP.BT', LN$Pos, 'SET_LABEL', to_char(LN$Rec) || ',' || :EMP.ENAME );
              If :EMP.JOB = 'MANAGER' Then
                Set_Custom_Property('EMP.BT', LN$Pos, 'SET_FONT', to_char(LN$Rec) || ',Arial,bold,14' );
                Set_Custom_Property('EMP.BT', LN$Pos, 'SET_FGCOLOR', to_char(LN$Rec) || ',0,0,255' );
              End if ;
              If :GLOBAL.I > 250 Then :GLOBAL.I := 5 ;
              Else  :GLOBAL.I := :GLOBAL.I + 5 ;
              End if ;     
              LC$C := To_Char(LN$Rec) || ','
                   || To_Char(255) || ','
                   || To_Char(255-:GLOBAL.I) || ','
                   || To_Char(255-:GLOBAL.I) ;    
              Set_Custom_Property('EMP.BT', LN$Pos, 'SET_BGCOLOR', LC$C );
              Synchronize;
         End if ;
    end;Don't forget to copy the multirecord.jar file in your /forms/java folder, then add it to the archive and archive_jini tags of your /forms/server/formsweb.cfg file.
    Enjoy it,
    Francois

  • Push button using abap objects

    Hi experts,
    can u paste any sample code for creating and handling push button on a screen using ABAP objects.
    thanks in advance.
    santhosh

    Hi Santhosh,
       Check the following code.
    * create a custom area on the screen
    DATA : gref_ver_toolbar      TYPE REF TO cl_gui_toolbar,
           gref_custom_container TYPE REF TO cl_gui_custom_container.
    * initializing toolbar
    * Creating toolbar container............................................
      create object gref_custom_container
      exporting
      container_name              = iv_ccarea   " control area on screen
    exceptions
       cntl_error                  = 1
       cntl_system_error           = 2
       create_error                = 3
       lifetime_error              = 4
       lifetime_dynpro_dynpro_link = 5
       others                      = 6
    * creating reference to toolbar........................................
      create object gref_ver_toolbar
      exporting
       parent         = gref_custom_container
       display_mode       = 1
    exceptions
       cntl_install_error = 1
       cntl_error         = 2
       cntb_wrong_version = 3
       others             = 4
    * subroutine to create buttons
    * Local data............................................................
      data: lv_fcode       type ui_func,
            lv_icon        type iconname,
            lv_is_disabled type c,
            lv_quickinfo   type iconquick.
    * delete node  button...................................................
      lv_fcode            = 'DELETE'.
      lv_icon             = '@11@'.
      lv_is_disabled      = space.
      lv_quickinfo        = test(001).
    * adding button to toolbar
      call method gref_toolbar->add_button
       exporting
        fcode            = lv_fcode
        icon             = lv_icon
        is_disabled      = lv_is_disabled
        butn_type        = cntb_btype_button
        quickinfo        = lv_quickinfo
       exceptions
        cntl_error       = 1
        cntb_btype_error = 2
        cntb_error_fcode = 3
        others           = 4
    * registering toolbar
    * Local data............................................................
      data: ls_event type cntl_simple_event,
            lt_event type cntl_simple_events.
      ls_event-eventid    = cl_gui_toolbar=>m_id_function_selected.
      ls_event-appl_event = space.
      append ls_event to lt_event.
    * Method for Registering Events for Toolbar.............................
      call method gref_toolbar->set_registered_events
        exporting
          events                    = lt_event[]
        exceptions
          cntl_error                = 1
          cntl_system_error         = 2
          illegal_event_combination = 3
          others                    = 4.
    * Setting handler for the Toolbar Buttons..............................
      set handler  gref_application->handle_function_selected
              for  gref_toolbar.
    just copy paste the above code in the PBO of the screen also you need to create a method handle_function_selected which will take care of the function on the button
    * Method to handle button on toolbar....................................
         handle_function_selected
                        FOR EVENT function_selected
                               OF cl_gui_toolbar
                        IMPORTING fcode.
    method handle_function_selected.
          case fcode.
            when 'DELETE'.
    *          code...
         endcase.         
    endmethod.
    Hope the above code snippet help you.
    Regards,
    Kinshuk

Maybe you are looking for

  • Import not allowed on nodes of type element declaration

    I have 2 very simple transformation processes, consisting of: 1. hit a web service 2. filter the output 3. transform into a variable of type defined by a schema document 4. get the variable as a string 5. call another web service and pass the string

  • I can get Safari homepage up but it won't do searches.  Both upper left arrows are gray instead of black.

    I can get Safari home page up but it will not do any searches.  I am connected to internet.  The top left hand arrows on page are gray instead of black.  I can type something in on "search google" line but it doesn't respond.

  • Using images with transparent backgrounds

    Hello. I'm trying to design several forms using a large background graphic along with several other overlays (defined by the form user) that contain transparent backgrounds. Unfortunately, everytime I go to change the graphic, the program won't recog

  • Can I back up if my iphone 4s has frozen in recovery mode?

    This might be a dumb question but before I restore factory settings is there anyway i can back up my data ? At the moment my phone is frozen on the itunes screen and itunes (on my PC) is saying 'detected iphone in recovery mode. You must restore this

  • Changing the Database Home

    I just changed the home of an existing Oracle database. OEM still shows it in the old location. I seem to remember that I was able to type the new home name in OEM. However, I can't remember the page. Anyone remember how to do this. Thanks, John