Button events

Hi
Please can anyone help. I put a table button in a GUI and tried to open the table in a separate GUI. The data for this table is stored somewhere but when I click on the table button nothing happens. Some of the other buttons: next exercise, exit are not working either. What am I doing wrong?
Any help will be most appreciated.
Thanks
Sofia
ExerciseGUI - contains tableGUI button and other buttons
TableGUI
TableDBHandler
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.event.*;
import java.awt.Component;
import javax.swing.text.*;
import javax.swing.table.*;
public class ExerciseGUI extends JFrame {
JTable table = new JTable(5,3); JLabel tableLabel = new JLabel ("Customer Table");
JTextField exerciseName = new JTextField(40); JLabel
exerciseNameLabel = new JLabel("Exercise Name");
JTextField questionNum = new JTextField(10); JLabel questionNumLabel = new JLabel("Question Number");
Font font = new Font("times new roman", Font.BOLD, 30);
JTextArea question = new JTextArea(5,36); JLabel questionLabel = new JLabel("Question");
JTextField answer = new JTextField(36); JLabel answerLabel     = new JLabel("Student Answer");
JButton accept          = new JButton();
JButton copy = new JButton(); //JScrollBar scroll = new JScrollBar();
JButton next = new JButton();
JButton close = new JButton();
JButton table = new JButton();
     JPanel questPanel     = new JPanel();
     JPanel answPanel     = new JPanel();
     JPanel mainPanel     = new JPanel();
JScrollPane scrollPane = new JScrollPane(question);
JLabel wordsLabel = new JLabel("Select words");
JTextField wordList = new JTextField();
TableGUI aTableGUI= new TableGUI();
JLabel sortWordsLabel = new JLabel(" Sort these items to form the correct SQL query statement in answer.");
public static final int DISPOSE_ON_CLOSE = 2;
     FlowLayout myLayout = new FlowLayout(FlowLayout.LEFT);
     public ExerciseGUI() {
     try {
setDisplay();
setSize(600,500);
}catch(Exception e) {e.printStackTrace();}
     public static void setNativeLookAndFeel() {
try {
     UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
     catch(Exception e) {
     System.out.println("Error setting native LAF: " + e);
     private void setQuestionPanel() {
          questPanel.setBorder(BorderFactory.createTitledBorder("QUESTION"));
          questPanel.setLayout(myLayout);
          questPanel.setMinimumSize(new Dimension(450,300));
          questPanel.setPreferredSize(new Dimension(450,300));
          questPanel.setMaximumSize(new Dimension(450,300));
questPanel.add(exerciseNameLabel);
     questPanel.add(exerciseName);
questPanel.add(questionNumLabel);
     questPanel.add(questionNum);
questPanel.add(questionLabel);
boolean aWrap = true;
questPanel.add(question);
     questPanel.add(tableLabel);
questPanel.add(table);
JButton aButton = new JButton();
     questPanel.add(aButton, null);
aButton.setText("Table");
aButton.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
aButton_mouseClicked(e);
void aButton_mouseClicked(MouseEvent e) {
tableGUI aTableGUI= new tableGUI();
     private void setAnswerPanel() {
          answPanel.setBorder(BorderFactory.createTitledBorder("ANSWER"));
          answPanel.setLayout(myLayout);
          answPanel.setMinimumSize(new Dimension(400,200));
          answPanel.setPreferredSize(new Dimension(400,200));
          answPanel.setMaximumSize(new Dimension(400,200));
     answPanel.add(sortWordsLabel);
copy.setText("Select");
          copy.setSize(2,30);
answPanel.add(copy);
copy.addMouseListener(new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
     copy_mouseClicked(e);
answPanel.add(answerLabel);
          answPanel.add(answer);
accept.setText("Evaluate Answer");
          accept.setSize(2,30);
accept.addMouseListener(new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
accept_mouseClicked(e);
next.setText("Next Exercise");
next.setSize(2, 20);
next.addMouseListener(new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
next_mouseClicked(e);
close.setText("Exit Tutorial");
close.setSize(2, 20);
close.addMouseListener(new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
close_mouseClicked(e);
     answPanel.add(accept);
answPanel.add(next, null);
answPanel.add(close, null);
     private void setDisplay() throws Exception {
          setNativeLookAndFeel();
          Container content = getContentPane();
          //content.setMiniumSize(new Dimension(400,400));
          //content.setPreferredSize(new dimension(400,400));
          content.setLayout(new GridLayout(0,1));
          content.setFont(font);
          content.setBackground(Color.lightGray);
this.setTitle("Display Exercise");
setQuestionPanel();
          setAnswerPanel();
          content.add(questPanel);
          content.add(answPanel);
          setContentPane(content);
/* exerciseGUI.setDefaultCloseOperation(
WindowConstants.DISPOSE_ON_CLOSE);
exerciseGUI.addWindowListener() {
public void windowClosed(WindowEvent e){
system.exit(20);
String studentAnswer;
void accept_mouseClicked(MouseEvent e) {
String studentAnswer = answer.getText();
DBHandler aDBHandler = new DBHandler(questionNum.getText(), studentAnswer);
void copy_mouseClicked(MouseEvent e) {
wordList.copy();
answer.paste();
answer.append("");
void next_mouseClicked(MouseEvent e) {
System.out.println("Starting Search_GUI...");
          ExerciseSelectorGUI aGUI = new ExerciseSelectorGUI();
aGUI.show();
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.event.*;
import java.awt.Component;
import javax.swing.text.*;
import javax.swing.table.*;
public class TableGUI extends JFrame {
JTable table = new JTable(5,3); JLabel tableLabel = new JLabel("Customer Table");
     Font font          = new Font("times new roman", Font.BOLD, 30);
     JPanel tabPanel     = new JPanel();
     JPanel mainPanel     = new JPanel();
TableDBHandler aTableDBHandler;
     FlowLayout myLayout = new FlowLayout(FlowLayout.LEFT);
     public TableGUI() {
     try {
setDisplay();
setSize(500,400);
}catch(Exception e) {e.printStackTrace();}
     public static void setNativeLookAndFeel() {
try {
     UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
     catch(Exception e) {
     System.out.println("Error setting native LAF: " + e);
     private void setTablePanel() {
          tabPanel.setBorder(BorderFactory.createTitledBorder("TABLE"));
          tabPanel.setLayout(myLayout);
          tabPanel.setMinimumSize(new Dimension(300,200));
          tabPanel.setPreferredSize(new Dimension(300,200));
          tabPanel.setMaximumSize(new Dimension(300,200));
tabPanel.add(tableLabel);
tabPanel.add(table);
/*copy.setText("Select");
          copy.setSize(2,30);
     copy.addMouseListener(new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
copy_mouseClicked(e);
     questPanel.add(copy);*/
     private void setDisplay() throws Exception {
          setNativeLookAndFeel();
          Container content = getContentPane();
          //content.setMiniumSize(new Dimension(400,400));
          //content.setPreferredSize(new dimension(400,400));
          content.setLayout(new GridLayout(0,1));
          content.setFont(font);
          content.setBackground(Color.lightGray);
this.setTitle("Display Table");
setTablePanel();
          content.add(tabPanel);
          setContentPane(content);
import java.awt.*;
import javax.swing.*;
import java.sql.*;
import java.lang.*;
import javax.swing.table.*;
public class TableDBHandler {
TableGUI customTable = new TableGUI ();
public TableDBHandler() {
try {
DriverManager.registerDriver(new sun.jdbc.odbc.JdbcOdbcDriver());
Connection aConnection = DriverManager.getConnection("jdbc:odbc:SQLDatabase", "", "");
Statement aStatement = aConnection.createStatement();
ResultSet aSet = aStatement.executeQuery ("SELECT CustomerNo, Name, Address FROM CustTable"); {
while (aSet.next());
customTable.addItem(aSet.get(setText));
//aGUI.customerNo.setText(k);
//aGUI.name.setText(l);
//set text one under another
//aGUI.address.setText(m);
customTable.show();
aConnection.close();
catch (SQLException e) { System.exit(8);}

Hi,
didn't read all of your code, but one problem is that you use the same name for the JTable and the JButton (both are named table. You should avoid this, personnally I often use the first letter(s) of a variable name to explain wich class it come from... for example, bNew (or JbNew) for a NEW JButton, tNames (or jtUsers) for a USERS JTable.
Hope this helps,
Regards.

Similar Messages

  • Unable to capture button event in pageLayout Controller

    Hi Guys,
    I have the following layout
    pageLayout
    pageLayoutCO (controller)
    ----header (Region)
    ----------messageComponentLayout (Region)
    -----------------MessageLovInpurt
    -----------------MessageChoice(Item)
    -----------------MessageTextInput
    -----------------MessageLayout
    ----------HideShow (Region)
    -----------------MessageLovInpurt(Item)
    -----------------MessageChoice(Item)
    -----------------MessageTextInput(Item)
    -----------MessageComponentLayout (Region)
    -----------------MessageLayout
    ------------------------SubmitButton(ID:SearchBtn)
    ------------------------SubmitButton(ID:ClearBtn, fires partial action named clear)
    -----------header(Region)
    I am not able to capture the event fired by the button ClearBtn in the controller of the pagelayout.....
    The two methods I used as follows aren't worked:
    if ("clear".equals(pageContext.getParameter(OAWebBeanConstants.EVENT_PARAM)))
    if (pageContext.getParameter("ClearBtn") != null) {
    what should i do in order to capture the button event in the pageLayout Controller
    Thanks in advance
    Mandy
    Edited by: user8898100 on 2011-8-2 上午7:49

    Mandy,
    Its really strange that its not able to caputure the event in CO.
    Below is the way in which we handle to Submit action at CO level.
    /Check whether ClearBtn is same in case too.
    if(pageContext.getParameter("ClearBtn")!=null){
    System.out.println("Inside the Clear Btn Action");
    Regards,
    Gyan

  • 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 extended controller

    Hi Gurus,
    I am not able to capture the button event (of seeded controller) in extended controller.
    I have written code in extended controller like below:
    public void processFormRequest(OAPageContext pageContext, OAWebBean webBean){
        String str = pageContext.getParameter("event"); // copied from seeded controller for the button event //
          if ("editLines".equals(str)) {
            //cutom validation
      super.processFormRequest(pageContext, webBean);
    Please help me in resolving the issue.
    Thanks,
    Srinivas
        ///my cutom validateion

    Hi Bm,
    Thanks for your response.
    I have tried the same but no luck.
    Please help in getting this resolved.
    Thanks,
    Srinivas

  • 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                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • 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

  • Custom Button Event Handler

    I'm working on a form that inserts data into my database. The normal Insert PL/SQL just does "doInsert". I want to add in the PL/SQL Button Event Handler a condition statement as follows:
    IF :new.name_id != null THEN
    doInsert;
    ELSE
    "do something else"
    END IF;
    "name_id" is one of the form items. I want to check the value in name_id before I insert it into the database. What is the correct verbage in order for this condition to work -- :new.name_id does not work.
    Thanks
    Susan

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Susan Miller ([email protected]):
    I'm working on a form that inserts data into my database. The normal Insert PL/SQL just does "doInsert". I want to add in the PL/SQL Button Event Handler a condition statement as follows:
    IF :new.name_id != null THEN
    doInsert;
    ELSE
    "do something else"
    END IF;
    "name_id" is one of the form items. I want to check the value in name_id before I insert it into the database. What is the correct verbage in order for this condition to work -- :new.name_id does not work.
    Thanks
    Susan<HR></BLOCKQUOTE>
    null

  • 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"/>

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

  • 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

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

  • Few seconds of processing & button events

    Hi,
    i have a 'theory' question -
    some feature of my app has a bit long processing time, about a few seconds, in which there's an activity indicator running.
    this processing should start after the user pressed some "start process" button.
    my question is -
    is it good or bad or neither to do this large processing issue from within the button's event method (the one connected to "TouchUpInside" event for example, or there's a better way to use events to signal other parts of the application to do that processing.
    the reason i ask this is when i do the processing from within the buttons event method, the button is highlighted and than remains highlighted until all the process is done.it seems that the highlight is there until the button's event method finished.
    i hope i explained myself clearly enough.
    thanks a lot.

    nkobik wrote:
    is it good or bad or neither to do this large processing issue from within the button's event method
    The problem in this case isn't which method starts the long process. No matter where you run that task, it's going to freeze the UI until you get it out of the main thread. Running the process in the action method makes the problem more noticeable since the button's state can't change until the process completes, but freezing the UI is never acceptable even if some users don't notice it. I.e. even if the app has nothing useful to do until the long process completes, the controls should still respond normally, if only to pop up an alert asking the user to be patient. Generally the user should also have the opportunity to cancel a long process, which isn't going to be possible with a frozen UI.
    So it looks like you need to bite the bullet and use some kind of concurrent operation. I think the choice will depend in part on your experience and preference. If you're comfortable with threaded programming, starting a helper thread to run the long process might be the easiest for you. However the SDK supports higher level concurrency management, and if you're not familiar with the NSOperation classes you might want to look over the Concurrency Programming Guide.
    Whatever approach you decide on, let us know if you need help with it, and I'm sure someone around here will be able to advise you.
    \- Ray

  • ALV Button event handling

    I have added a custom button on ALV toolbar of my web dynpro view. Now when user click that button, i want to implement the functionality...like onAction...How to do that...where do i need to write the code and how can i capture the button event...
    pls suggest

    Hi ,
    write following to create button:
    DATA: ui_btn1                     TYPE REF TO cl_salv_wd_fe_button.
      DATA: ui_sepa1                    TYPE REF TO cl_salv_wd_fe_separator.
      DATA: sepa1                       TYPE REF TO cl_salv_wd_function.
      DATA: btn1                        TYPE REF TO cl_salv_wd_function.
      data: lr_disp_button type ref to cl_salv_wd_fe_button.
      data: lv_button_text type string.
      CREATE OBJECT ui_btn1.
      CREATE OBJECT ui_sepa1.
      create object lr_disp_button.
    /to create new buttons...
      lv_button_text = 'Refresh Selection'.
      lr_disp_button->set_text( lv_button_text ).
    lr_disp_button->SET_IMAGE_SOURCE( 'ICON_DISPLAY' ).
      btn1 = l_value->if_salv_wd_function_settings~create_function( id = 'LSBUTTON' ).
      btn1->set_editor( lr_disp_button ).
    IN methods tab of view declare:
    ON_REFRESH     Event Handler     On refresh function pf ALV     ON_FUNCTION     INTERFACECONTROLLER     ALV
    in method ON_REFRESH write below code:
      DATA: temp TYPE string.
      temp = r_param->id.
      IF temp = 'LSBUTTON'.
    custom functional;ity
      endif.
    where :
    R_PARAM      Importing     1     IF_SALV_WD_TABLE_FUNCTION     
    This woudl solve ur purpose.
    Regards,
    Vishal.

Maybe you are looking for