Professional way to call that frame on button click?

Hi
Nice to get new look and feel for forum :)
Wel my question is I have a frame which has many buttons textfields labels and other components too.
On clicking one of the button I am opening a frame which is like calculator(display is same as calculator)
I am using frame for that calculator.
My question is that what will be the most professional way to call that frame on button click?
All you java professionals your kind attention will be appreciated
Regards

Good question, I've often wondered this myself!
Personally, I don't like to use anonymous inner classes for handling events. I generally handle events two ways:
1. Make the main class implement lots of interfaces and use action commands. eg
public class MyFrame extends JFrame implements ActionListener {
    public static final String CALC_BUTTON = "cb";
    public MyFrame() {
        super();
        JButton cButton = new JButton("Calculator");
        cButton.addActionListener(this);
        cButton.setActionCommand(CALC_BUTTON);
    public void actionPerformed(ActionEvent ae) {
         if (ae.getActionCommand().equals(CALC_BUTTON) {
             //do something
2. Subclass AbstractAction.
public class MyAction extends AbstractAction {
    //create a constructor specific to the goal
    public MyAction(/*Some arguments*/) {
        //set  variables
    public void actionPerformed(ActionEvent ae) {
         //handle the action
//and in the main class
JButton cButton = new JButton("Calculator");
cButton.setAction(new MyAction());I tend to use the first method more often, but if there's some specific kind of action, then I use the second method.
I'm interested to know what other people do though. :)
-Muel

Similar Messages

  • Show image on the form Java WS gets image. Call this WS on button click

    Hi,
    Is there a way to show an image on the form. On the form I have along with the data I have a button that when clicked get and show the image itself on the form. I have a Java WebService that gets the image from the remote location. How can I make the button click event to call this Web Service and show the image on the form itself. Any help is appreciated.
    Thanks

    WHiteSox, are you on client/server or web version.
    which version of forms are you using.
    something i can think of is.
    during the click to call the webservice, copy the image to the local system.
    next step is, using READ_IMAGE_FILE built in which reads the image from the local file system and displayed on the forms image item.

  • Opening a frame with button click

    hi all
    when i am going to click a button which is placed in JTabel it should
    open a JFrame with some component.
    thanks & regards
    daya

    This task can be decomposed in two logically unrelated subtasks:
    1: Adding a button in a table column and listening to it
    2: Showing a frame from some method
    In case you are hesitant how to solve the first task: you need to create your own cell editor (possibly by extending DefaultCellEditor) that returns a button as editor component. Of course this editor must be set to the desired column(that must be editable too). And just listen to that button's actions.
    Another possible solution is to just render the column with a button and listen the table for mouse clicks, then determine the ros/column for the click and act correspondingly.
    The solution of the second task depends entirely on you.
    HTH
    Mike

  • Calling default browser on button click in swings

    Hi all,
    I have built a window with tab page in it having a button on tabpage in java SWING. Now i want that when ever i click on button it calls my default browser i.e. IE6 with a predefined URL. The browser should open with in the tabpage area not beyond that. Please help........ Many people have helped till now because i am very new to this.......
    Again looking for help from experts................

    I feel like I answer this almost everyday
    search the web for JDIC and webbrowser

  • Help in connecting between two frames using button click

    hi all
    am a student doing my final year project work. i would like to know how to redirect from frame to frame. like in the button click i should get redirected to a new frame. please help........
    Message was edited by:
    jayalekshmy.r

    thanks for the reply. in sockets the previous frame wil be there after redirection. i dont want tht frame to be there. i only want the new frame to be displayed after redirection. how can i do the same so. plaese help

  • Calling SAP Tcode on Button click

    Hello All,
    i want to call SAP Tcode on click of button.
    below is the code for the same,
    data l_componentcontroller type ref to ig_componentcontroller .
      data l_api_componentcontroller type ref to if_wd_component.
      data l_sapgui_manager type ref to cl_wdr_sapgui_integration.
      l_componentcontroller =   wd_this->get_componentcontroller_ctr( ).
      l_api_componentcontroller = l_componentcontroller->wd_get_api( ).
      l_sapgui_manager = l_api_componentcontroller->get_sapgui_manager( ).
      if l_sapgui_manager is not initial.
        l_sapgui_manager->fire_start_transaction( transaction = 'SE38' ).
      endif.
    But the object l_sapgui_manager  is not getting instantiated. please let me know if i am calling the right method or  the code is wrong???
    Regrads,
    Chandra

    Hi Chandra,
    You need to Initialise the  l_sapgui_manager before you are accesing. see the folowing code i initialised my select options component.This code can be obtained from Wizard also. I hope this will help you.
    Please do this in the WDDOINIT of component controller. So that it will be inistatiated before you are accessing the component.
    ** initialize select options component for query creation
      lr_cmp_usage = wd_this->wd_cpuse_sel_options( ).
      wd_this->usage_name = lr_cmp_usage->name.
      IF lr_cmp_usage->has_active_component( ) IS INITIAL.
        lr_cmp_usage->create_component( ).
      ENDIF.
      l_ref_interfacecontroller = wd_this->wd_cpifc_sel_options( ).
      wd_this->mr_selopt_helper   = l_ref_interfacecontroller->init_selection_screen( ).
    Warm Regards,
    Vijay.
    Message was edited by:
            Vijaya Bhaskarudu Gangisetty

  • Call smart form on button click

    Hi Experts,
    I have a screen. In screen a button is available. I need when i clicked on button my smartform should be open. Plz provide me ur appreciated solution.
    Regards,
    Swapniks

    Hi Swapnika,
    You forgot a small code in between.
    data: v_formname type tdsfname value 'zmem',
    v_fmname type rs381_fname
    Case sy-ucomm.
    when 'okbut'.
    CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
    FORMNAME = v_formname
    IMPORTING
    FM_NAME = v_fname
    call function v_fname.
    exporting
    pernr = itab-pernr.
    tables
    itab = itab.
    Regards,
    Prakash Pandey

  • How to call function behind the button and update only specific record

    Greetings,
    1 - i wnat to ask few things as i m new to apex, i am using apex 4.1, and created 3 select list and a button in seleting of parameter,
    1 select list : select area
    2 select list: select product
    3- select list - size of the product
    i want to generate Ids for the follwing. for that i created query for INSERTING RECORD FROM ONE TABLE TO ANOTHER , generation the ids when button pressed "Generate" after selecting parameters,
    Now where i call that QUERY on button ? because when i create button its gives me option to submit, defined dynamic action, etc, pls gudie me where i call the function name id_generation when button pressed?.
    2- second thing i creared tabular " select user_id, product_name, product_type from product".
    by defualt check box list are create delete submit button are created, first when i insert record it saves that was fine, e.g i entered 50 records and afterward i want to update only one record, e.g there is a record product name = box, if i change it to box small and click submit then it saves all the page means all 50 records,
    i want to submit only that record that i changed, for that i use the logic that only those records should be updated which are checked but the user. how will i do this ? where to use the preocess , please guide
    Edited by: Omzz on Oct 2, 2012 11:28 PM

    If I understand what you are trying to do is correct you could possibly do this by:
    Creating and AFTER INSERT trigger on the table based on the tabular form which inserts the record into a seperate table after the record is inserted something like:
    CREATE OR REPLACE TRIGGER copy_records
    AFTER INSERT ON table a
    REFERENCING NEW AS NEW OLD AS OLD
    FOR EACH ROW
    DECLARE
    BEGIN
    INSERT INTO table b
    VALUES :NEW.col1, :NEW.col2 etc......
    END;
    There is also a way that you could do it within the form using a cursor on the tabular form with APEX_APPLICATION.G_ ......
    Chris

  • WAD: Add variable to a called javascript function on button group item

    Hi All,
    I need your expertise regarding the following problem:
    To increase performance, I've decided to hide all analysis tables. To set these tables to visible, there is a button to switch the state for each table.
    Because this function is needed for each table, the function has two parameters for the analysis item name and the new state.
    Unfortunately, I get an useless error message after calling the function.
    The function in script item looks like
    function switchTable(itemName, newState)
    The function is started by a button of a button group item as javascript and the following script function
    switchTable('ANALYSIS_ITEM_1', 'VISIBLE')
    If I enter a without parameters, that will call the function with these parameters, it works.
    But if i try this directly from the script function in the button parameters, the function will be called correctly, but an error occurs and the analysis item wasn't displayed or the sendCommand wasn't processed completely.
    I hope there is a way to call javascripts by a button with variables, otherwise I would have to create many functions with only an other item_ref.
    Many thanks in advance and points of course for any help.
    Regards,
    Tobias

    One short note:
    It's possible to trigger the same function by an html input form button with onlick switchTable('ANALYSIS_ITEM_1', 'VISIBLE')
    and this works.
    Has anyone an idea what's the problem with a normal button item of the button group item?
    Another possibility is a menu item. The functions were called, but errors were shown.

  • Call method on servlet by clicking command_button

    To all Jdever's 11g guru's
    i usually use jdev 10g, but now i try to exercise with jdev 11g and i have an question [newbie on 11g]
    i have command_button in browseGoods page and in that button i have a method "onSearch" on "browseGoodsAction.java"
    my onSearch method
    public void onSearch (DataActionContext ctx) throws Exception{
    String nama = ctx.getHttpServletRequest().getParameter("nama");
    String dateStart = ctx.getHttpServletRequest().getParameter("dateStart").toString().toUpperCase();
    String dateEnd = ctx.getHttpServletRequest().getParameter("dateEnd").toString().toUpperCase();
    String status ="A";
    if (nama.length()==0 || nama == null){
    nama = "%%";
    if (nama.equalsIgnoreCase("all")){
    nama = "ALL";
    SimpleDateFormat formater = new SimpleDateFormat("yyyy-MM-dd");
    if (dateStart.length()==0 || dateStart == null){
    and if i double click the command_button the generic method is
    public String Search() {
    // Add event code here...
    return null;
    not
    public void Search(){
    that i was made.
    How to call that method when i click the commnad_button,..and bean that servlet???
    cauze i'm not so understand when i follow the "*cue card*" on OTN
    thanks for all guru's response and help
    Edited by: kang dadang on Jan 5, 2010 8:39 PM

    Hi Frank, thanks for u'r answer and response
    I usual use jdev 10.1.2 UIX & JSP version, and i know that "*DataActionContext*" is depricated on Jdev11g.
    If i have message textInput / inputText on 11g for search input, and inputText parameter name is for ex : goodsName : in properties inputText name field
    how to put inputText parameter name ? is in the Property Inspector, Common section, the Value field ?
    and how to get parameter name in inputText on jdev11g ?
    I usual use this for UIX or JSP on Jdev 10.1.2
    public void onSearch (DataActionContext ctx) throws Exception{
    String nama = ctx.getHttpServletRequest().getParameter("nama");
    String dateStart = ctx.getHttpServletRequest().getParameter("dateStart").toString().toUpperCase();
    String dateEnd = ctx.getHttpServletRequest().getParameter("dateEnd").toString().toUpperCase();
    thanks Frank for your answer

  • Ever since the latest update, my task bar (if it's called that - it's the one with "file,edit,view, etc") will "grey out" and I won't be able to type into any websites I visit. Only way to fix:either restart Firefox or reduce the window and open it again.

    Ever since the latest update, my task bar (if it's called that - it's the one with "file,edit,view, etc") will "grey out" and I won't be able to type into any websites I visit. Only way I can proceed is if either restart Firefox (very annoying) or reduce the window and open it again. Please help!

    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > Appearance/Themes).
    *Don't make any changes on the Safe mode start window.
    *https://support.mozilla.org/kb/Safe+Mode
    See also:
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes
    *http://kb.mozillazine.org/Corrupt_localstore.rdf

  • Is there a way to answer the 5c without swiping? It really is a pain and hard to do at times one handed. Maybe allow favorites to be answered with a click of the home button or possibly all calls with a home button push

    Is there a way to answer the 5c without swiping? It really is a pain and hard to do at times one handed. Maybe allow favorites to be answered with a click of the home button or possibly all calls with a home button push. First smart phone I have owned and the old flip phone was much easier to answer.....just press one button.

    Is there a way to answer the 5c without swiping? It really is a pain and hard to do at times one handed. Maybe allow favorites to be answered with a click of the home button or possibly all calls with a home button push. First smart phone I have owned and the old flip phone was much easier to answer.....just press one button.

  • Is it possible that the home button can show a light when a message or a phone call has beebn missed?!

    Is it possible that the home button can show a light when a message or a phone call has beebn missed?!

    No.
    There is no light there.

  • HT1414 my ipad with retina eye updated to IOs 7 not able to boot ....the normal way of pressing the sleep/wake button and the  home button does'nt work....any ideas i think that IOs 7 is a crap cos form the time i loaded it it was shaky...now my ipad is d

    my ipad with retina eye updated to IOs 7 not able to boot ....the normal way of pressing the sleep/wake button and the  home button does'nt work....any ideas i think that IOs 7 is a crap cos form the time i loaded it it was shaky...now my ipad is dead

    If it is one year old minus one day it is still under warranty. If it is more than a year since you purchased it then yes, the warranty has expired.
    Millions of iPads have been sold. Most continue to function long after their warranty has expired. Check the many requests about updating the iOS on the original iPad on these forums and you'll see that there are many iPads still working after three years. My iPad 2, which I had for over two years is still working well for my son in law who took it over from me when I bought a new one.
    Given that there will always be a few iPads that fail early. Most of those will be covered under warranty. But some will fail after the warranty has expired and before the owner expected it to. I'm sorry to hear that you are in this category. Take your iPad to an Apple store and have it looked at. They will provide you with alternatives, one of which is to purchase a like model to the one that failed at a discount. You can then know your options and make the best choice for you.

  • Yes Verizon has contacted me by phone.  I never scheduled a call time nor did I call them.  They also are not making it easy to contact them through email.  I need to discuss a way to assure that my phone is never called again during work hours without a

    Yes Verizon has contacted me by phone.  I never scheduled a call time nor did I call them.  They also are not making it easy to contact them through email.  I need to discuss a way to assure that my phone is never called again during work hours without a prearranged meeting.  I will not speak on the phone nor use a live chat.  I want email as I want this documented offical and no other means offeres me that assurance.  I'd also like to discuss comensation for being harrassed with phone calls.

    Well if you pay your bill the calls would not happen.
    You need only tell them not to call you during working time.
    The Fair Debt Collections Practices Act states you must tell them it is not convenient.
    Now if marketing calls you can opt out at the Verizon web portal under your My Verizon account.
    You will not get compensation for them to call you. Nice try.
    However they could just shut your phone off and then you will call them.
    Email is not an option.
    Good Luck

Maybe you are looking for