Can we perform two actions with one button with two clicks one after other?

Sir,
can we perform two actions with one button with two clicks one after other?
I want that when I click an Add Button first time it add data to the database and when I click again this button it clear the form data to empty fields.
Regards
Tanvir

In code it should be easy.
The following code adds a button called butman with a text "ADD".
It then registers a listener that will be called if the button is clicked.
This listener then calls the runAddData method if you clicked on butman while it contained the "ADD" text and it will call the runClearData method otherwise.
Therefore it will swap the button's functionality between ADD and CLEAR on every click.
final Button butman = new Button("ADD");
butman.setOnAction(new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent t) {
                    if (butman.getText().equals("ADD")) {
                              butman.setText("CLEAR");
                              runAddData();
                    } else {
                              butman.setText("ADD");
                              runClearData();
                    } // END IF-THEN
          }});I hope this is what you wanted.
Some extra food for thought.
You might want to run the ADD and CLEAR methods in their own threads so that it can run in the back ground, without slowing down your user interface.
I also like to rather reuse one button for multiple functionality in stead of making an application with hundreds of nodes only used rarely with masses of code to show and hide them if needed.

Similar Messages

  • How do I link one button to two slices?

    Hello,
    I need some help please. How do I link one button to two
    slices? or combine two slices to make one slice, or make a true
    polygon shape out of the slices, it will make the polygon shape but
    it leaves the the red guide lines and I cant work under that
    slice... if you understand. Will someone please help. Thank you so
    much.

    heathrowe wrote:
    > Did you Hide Slices?
    >
    > Select the Pointer Tool and click your Object? It should
    get selected.
    >
    > What happens when you mouse over the 'star' object? Do
    you get the 'object
    > selection' bounding area appear? Bounding area should
    appear red when you mouse
    > over it? Yes/No!
    >
    > Also, go to your Layer Panel and make sure that your
    object/Layer is not
    > 'locked'. Look for little 'padlock' icons next to the
    Layers. If you see it,
    > click it, to toggle it to 'off'.
    >
    > h
    >
    Also make sure you are not in PREVIEW mode in the document
    window.
    Jim Babbage - .:Community MX:. & .:Adobe Community
    Expert:.
    http://www.communityMX.com/
    CommunityMX - Free Resources:
    http://www.communitymx.com/free.cfm
    .:Adobe Community Expert for Fireworks:.
    Adobe Community Expert
    http://tinyurl.com/2a7dyp
    See my work on Flickr
    http://www.flickr.com/photos/jim_babbage/

  • How can I stop a program until a button will be clicked

    I have a class that create a JTable and in this class I have two columns, the first culumns has the name of the variables an the second column has a checkbox to select the correponding variable.this JTable is created from a vector originating in other class. I need obtain a vector of integers with the number of the variable selected after the JButton will be clicked. For this i create a method called EspererSeleccion. This is the class
    import javax.swing.table.AbstractTableModel;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.table.TableColumn;
    import javax.swing.border.Border;
    import java.util.*;
    import javax.swing.*;
    import java.lang.Integer;
    public class MiTabla extends JFrame implements ActionListener
    //Variables de Instancia
    private boolean DEBUG = true;
    public boolean TERMINA=false;
    public Vector Valores=new Vector(1,1);
    //Constructor de objetos de la clase MiTabla
    public MiTabla()
    super("Variables");
    Border empty;
    MiModelodeTabla myModel = new MiModelodeTabla();
    JTable table = new JTable(myModel);
    table.setPreferredScrollableViewportSize(new Dimension(300, 200));
    TableColumn column=null;
    column = table.getColumnModel().getColumn(0);
    column.setPreferredWidth(220);
    column = table.getColumnModel().getColumn(1);
    column.setPreferredWidth(80);
    //Crea el scroll pane y agrega la tabla en el.
    JScrollPane scrollPane = new JScrollPane(table);
    empty= BorderFactory.createEmptyBorder();
    JButton boton=new JButton("Aceptar Seleccion");
    boton.setBorder(empty);
    boton.addActionListener(this);
    getContentPane().setLayout(new BorderLayout(100,0));
    getContentPane().add(scrollPane, BorderLayout.CENTER);
    getContentPane().add(boton, BorderLayout.SOUTH);
    addWindowListener(new WindowAdapter()
    public void windowClosing(WindowEvent e)
    setDefaultCloseOperation(HIDE_ON_CLOSE);
    dispose();
    //System.exit(0);
    //clase MiModelodetabla
    class MiModelodeTabla extends AbstractTableModel
    MiVector v=llamaVector();
    int numElementos=v.size();
    private int i,j;
    public final Object[][] data=new Object[numElementos][2];
    final String[] columnNames = {"Variable",
    "Seleccion"};
    public MiModelodeTabla()
    CreaListas();
    public void CreaListas()
    for (i=0; i<numElementos; i++)
    data[0]=v.elementAt(i);
    for (j=0; j<numElementos; j++)
    data[j][1]=new Boolean(false);
    public MiVector llamaVector()
    MiVector V1=new MiVector();
    v=V1.addElementos();
    return(v);
    public int getColumnCount()
    return columnNames.length;
    public int getRowCount()
    return data.length;
    public String getColumnName(int col)
    return columnNames[col];
    public Object getValueAt(int row, int col)
    return data[row][col];
    public Class getColumnClass(int c)
    return getValueAt(0, c).getClass();
    public boolean isCellEditable(int row, int col)
    if (col < 1)
    return false;
    else
    return true;
    public void setValueAt(Object value, int row, int col)
    data[row][col] = value;
    fireTableCellUpdated(row, col);
    if (DEBUG)
    String s=new String("true");
    Integer I=new Integer(row);
    String S=value.toString();
    if(s.equals(S))
    Valores.addElement(I);
    else
    Valores.remove(I);
    value=(Object)value;
    public void EsperarSeleccion()
    while (TERMINA==false)
    int i=0;
    TERMINA=false;
    public void actionPerformed(ActionEvent e)
    TERMINA=true;
    dispose();
    and this is the method that create the JTable but when i call the method EsperarSeleccion the program fail and the JTable is not visible only the frame that contains It.
    How can I do to stop the program or the actions until the JButton will be clicked using and other method diferent from the EsperarSelection method
    Vector leeVariablesRelevantes ()
    System.out.println ("Variables relevantes");
    MiTabla frame = new MiTabla();
    frame.pack();
    frame.setVisible(true);System.out.println("El vector tiene "+frame.Valores.size()+" elementos");
    int i;
    for (i=0; i<frame.Valores.size(); i++)
    System.out.println("El elemento "+i+" de el Vector es: "+frame.Valores.elementAt(i));
    System.out.println();
    return frame.Valores;

    Say,Class A contains JTable and in Class B you wish to acess the vector which contains the things required by you.
    First you have to get the reference of Class B in Class A.
    It can be done in the following way.
    In Class B ,you create a static method like this.
    public static ClassB getObject()
      return this;
    }Now you can get the Class B's object easily via this method.
    Again in Class B , you write a method which will handle your requirment.(Let this method name be doThings( Vector vector))
    Now in Class A's actionPerformed() ,when the buton is pressed ,just call doThings() and pass the vector.

  • Does anyone else have trouble with the button on I pad to access other apps

    Does anyone else have trouble with the button on I pad to access other apps

    Hello, Kevandsheila. 
    Thank you for visiting Apple Support Communities. 
    Here are some troubleshooting steps that I could recommend when experiencing Home button issues.  The article below is labeled for the iPhone, but the steps are the same for your iPad. 
    The Home button is slow to respond
    If the Home button is slow to respond when exiting one application, try another application.
    If the issue exists only in certain applications, try removing and reinstalling those applications. Get further assistance in installing and troubleshooting applications.
    If the issue continues, Try turning iPhone off and then on again. If the iPhone will not restart, try resetting it.
    If the issue is still happening, try to restore the iPhone.
    Seek service is the issue is still occurring.
    The Home button isn't working
    Put the iPhone to sleep.
    Wait a couple of seconds.
    Press the Home button.
    iPhone should wake up.
    If iPhone does not wake up, then iPhone should be serviced.
    If the issue persists after all the steps have been processed see the last section labeled issue not resolved. 
    Hardware troubleshooting
    http://support.apple.com/kb/ts2802
    Cheers,
    Jason H. 

  • How to make email link with a button with AC2 in flash cs3?

    How to make email link with a button with AC2 in flash cs3?
    I wrote this, but it does not work:
    btn_emailinfo.on (release) {
    getURL("mailto:"[email protected]");
    }

    I am guessing you put that on a frame?
    If so, the syntax is as follows:
    btn_emailinfo.onRelease = function(){
    getURL("mailto:[email protected]");
    Though, if you are placing it directly on the button itself,
    the syntax is:
    on(release){
    getURL("mailto:[email protected]");
    }

  • How can I assign a action to a button of the many scripts in the script file.

    How can I assign one action of many actions in a script file.
    I have many actions in a script file and I want to run one of them by clicking a button on the panel. However, loading the script I can not isolate the action that interests me.

    Hello,
    Try System Preferences>Energy Saver>Options tab, uncheck Allow power button to sleep computer.
    Some possible other options...
    Control-Eject
    The dialog box "Are you sure you want to shut down your computer now?" appears with options to Restart, Sleep, Cancel or Shut Down. After the dialog appears, press the R key to Restart, press the S key to Sleep, press the Esc key to Cancel, or press the Return key to Shut Down.
    Control-Command-Eject
    Quits all applications (after giving you a chance to save changes to open documents) and restarts the computer.
    Control-Option-Command-Eject
    Quits all applications (after giving you a chance to save changes to open documents) and shuts the computer down.
    Command-Option-Eject
    Puts the computer to sleep.
    Shift-Control-Eject
    Puts all displays to sleep.
    Power button (if the computer is not responding)
    Press and hold the power button on the computer for six seconds to shut down the computer.
    http://support.apple.com/kb/ht2448

  • I can not perform hardware test on 2011 imac with mavericks

    I unplug all devices from my iMac and held the d key and still can not get to the hardware test. The Mac store was able to perform it with a wired mouse even after I added more ram therefore I know it can be performed. Am I leaving something out?

    Read the instructions in Using Apple Hardware Test.
    If your iMac shipped with discs, you must run AHT while holding the d key while starting the Mac with its grey Applications Install DVD inserted in the optical drive.
    To force the Internet version of AHT to load: with two fingers hold option d while starting your iMac with a third finger.

  • Can not use scroll mouse in html tab when open pdf file in new tab with middle button but will avaliable only after switch to pdf tab and switch back to html

    When I open a "pdf" file in new tab with middle mouse click. After few second my mouse will not able to scroll in page that I read. But it will be able to scroll only after I click to any opened pdf tab and click on pdf document and click back on previous tab to continue reading. It is not only happen on my laptop also on my desktop too. (winxp 4gb/8gb ram core2 duo 2.66)

    There's a Bug filed about that issue.

  • How to get multiple row values in one text box while clicking one row from grid?

    hi friends,
               i am working on flex4 web application i am using  one datagrid ,it have two records(bills),one button and one text box.
    ex:
    customername      salesrepname   receipt no      amount
    venkat                         raj                         1102          10000
    ramu                          ramesh                   1102         20000
    here both receipt no is same.now i want to select one of this receipt and click pay button which is place in outside the grid.
    now my need is after click the pay button in text box i need 10000+20000=30000,after click that button i want both receipts should be invisible...'
    how i will do this,
    any suggession,
    Thanks
    B.venkatesan

    One way with 10g:
    select mgr,
           rtrim(xmlagg(xmlelement(empno,empno||',').extract('//text()')),',')  emps
    from emp
    where mgr is not null
    group by mgr;10g:
    -- define this function:
    create or replace
    function concatenate(c Sys_refcursor, sep varchar2 default null) return varchar2
    as
      val varchar2(100);
      return_value varchar2(4000);
    begin
    --  open c;
      loop
      fetch c into val;
      exit when c%notfound;
      if return_value is null then
        return_value:=val;
      else
        return_value:=return_value||sep||val;
      end if;
      end loop;
      return return_value;
    end;
    select mgr,
           concatenate(cursor(select empno from emp e where e.mgr=emp.mgr order by empno),',')
    from emp
    where mgr is not null
    group by mgr;With 11g:
    select mgr,
           listagg(empno,',') within group (order by empno) emps
    from emp
    where mgr is not null
    group by mgr;

  • Single Form with a button for two seperate form versions.

    Is it possible to create an option to select between two seperate Form Versions. For example. I have a Transfer Form. But there is an internation version and a domestic version. Both have some simple javascript.  I would like to combine these two forms into one document. When the end user opens the form, i would like to have a button for either domestic or internation. Depending on what the end user selects, it loads that version of the form. I have played around for a while and havent gotten anywhere, and i would like to know if there is even a way to acomplish this, or does it have to be two seperate document forms completely?

    With Acrobat or Reader XI one can show or hide a template page. You need Acrobat to create a template page.
    If your users will be using older versions of Reader, then you would need to hide or unhide form fields.

  • Two actions for submit button

    Hi
    I'm new to modifying pdfs so please excuse me.  I have a form with a submit button and the action associated is
    I want to add this script:
    but the form will only do 1 action in the event node.  So how can I make it show the message box and then do the submit? please note that the forum removed the script tags

    Hello,
    You can link your button actionListener to a manageBean method and into this method, call your to ExecuteWithParams binding operation like
    public void actionListener(ActionEvent actionEvent) {
         BindingContext bindingContext = BindingContext.getCurrent();
         BindingContainer bindings = bindingContext.getCurrentBindingsEntry();
         OperationBinding opBinding1 = ((DCBindingContainer)bindings).getOperationBinding("ExecuteWithParams1");
         opBinding1.execute();
         OperationBinding opBinding2 = ((DCBindingContainer)bindings).getOperationBinding("ExecuteWithParams2");
         opBinding2.execute();
    }This also can be included into a valueChangeListener binded to an input component for example
    public void changeListener(ValueChangeEvent valueChangeEvent) {
         BindingContext bindingContext = BindingContext.getCurrent();
         BindingContainer bindings = bindingContext.getCurrentBindingsEntry();
         OperationBinding opBinding1 = ((DCBindingContainer)bindings).getOperationBinding("ExecuteWithParams1");
         opBinding1.execute();
         OperationBinding opBinding2 = ((DCBindingContainer)bindings).getOperationBinding("ExecuteWithParams2");
         opBinding2.execute();
    }Jack

  • Can't assign an action to a button? WTF????

    I created a button, I checked the Properties and it shows as
    button, and is shown as "Track As Button" but when I go into the
    Actions panel, it says no action can be applied to it! WTF? I never
    had this happen in any versions prior to CS3. When did Flash get so
    temperemental and difficult to work with?

    Just as a note of historical interest, the following is an
    extract from a document published by Macromedia (not Adobe)
    entitled "ActionScript Coding Standards":
    "Avoid attaching code to Movie Clips or buttons
    Don't attach code to movie clips and buttons unless it's
    absolutely necessary to do so. When code must be attached to a
    movie clip or button, only use a minimal amount of code. It's
    preferable to employ a function call, as follows:
    myButton.onMouseDown = function() {
    _parent.doMouseDown(this); }
    The use of the function call redirects all the functionality
    into the main timeline of the movie clip."
    This document was published in March 2002! So I'm not sure
    they're asking you to learn an "entirely new way" of doing
    something.
    Here's the link to this ancient document:
    http://download.macromedia.com/pub/devnet/downloads/actionscript_standards.pdf

  • "you can't perform this action on this draft"

    Whats up with this? Suddenly, _all_ of my Websites I administer with CT are throwing this error when trying to publish a draft. In Addition a save Box pops up after this error and CT says I have an unpublished Draft - which is completely empty.
    The Problem affects _all_ Sites as I said, and _all_ Versions of CT (CT CS4 as well as CT CS5, german or english does not matter) on _all_ of my computers. WTF?
    I also tried to delete all Prefs, and on one machine even tried to reinstall CT, which failed according to the installer.
    I am using Mac OS X 10.6.3, maybe the latest update destroyed CT?
    So what now? Please help, I am completely locked right now.
    Thanks,
    Frank

    1. Restart Contribute and click 'Connect' to the site. Create a new
    page and publish. Edit an existing page and publish. Select an existing
    page and publish. If any the same error msg pops up - Delete or discard
    the draft. Reedit the page and check.
    This did not work. I can create a new page, but not publish it (same error)
    2. Remove the connection and
    reconnect and try. Reedit the page and check.
    This also did not help. I don't know how many times I startet a new connection. Also deleted all "_notes", ".lck" and "_mm" Files on the remote site before starting over, but nothing helped.
    3. Remove the
    preferences from both - 'user - Library - Preferences' and also 'user -
    Library - Application Support - Adobe - Contribute CSX' and try again.
    Reedit the page and check.
    Also tried this several times, but does not work.
    If none of the above worked then please provide more details of Website
    and machine.
    Machines: Mac Pro 2008 and Macbook  late 2008, both running OS X 10.6.3
    Websites: _all_ I tried! One example: finkon-hh.de. Nothing special with these sites ....
    What really really bothers me that I have the same Problem on _all_ my machines, on _all_ sites I tested (3 Sites), and also with _both_ CS4 and CS5.

  • How can I create a group of 5x3 buttons with a drop down meny that will slide down the 5 boxes beneath in Muse?

    I am making a porfoliosite in Muse, and want to show 5 x 3 thumbnails of my work that you can click on to see more of the same work. When you click I want a drop down box that will slide down the boxes beneath. Like on this page: http://rajoon.com/. Anyone that know how?

    Have you considered using CSS styled text/list menus instead of image rollovers.  It isn't hard really and it's actually a much better choice for   web accessibility and for search engines to find and follow your links.   Here are some links to several CSS menu systems you can try:
    CSS Express Drop-Down Menus (tutorial)
    http://www.projectseven.com/tutorials/navigation/auto_hide/
    CSS Tab Designer creates 60+ CSS Styled Button and Tab Menus  (download)
    http://www.highdots.com/css-tab-designer/
    List-O-Rama  (DW Extension)
    http://www.dmxzone.com/go?5618
    CSS  Menu Maker (On-Line Menu Generator)
    http://www.cssmenumaker.com/
    Pop-Menu  Magic2 by PVII (DW extension purchase)
    http://www.projectseven.com/products/menusystems/pmm2/index.htm
    Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics | Print | Media  Specialists
    www.alt-web.com/
    www.twitter.com/altweb
    www.alt-web.blogspot.com

  • Problem with back button  with myfaces/jsf

    Hi guys
    i have very strange kind of problem , i have a page where i am shwing tabular data with data scroller , thats work fine , in this tabbular data we are shing user infomration , and a link on user name ti see his details , this link works fine , and take user to user details page ,
    but from that page if user press back button , and reaches back to tabbular data page , in this page if user select any link , page reloads , and stay there , and after reloading page if user select any link then it works
    Any one geting this kind of preoblem , hope i am not alone
    please help me out
    X-preet

    Hi Luisa,
    1 .Create 2 views  View1 and View2
    2. Place buttons on both the views and create actions for both in view1 and view2
    3.Create outboundplug from View1 to View2.(Navigation link also)
    4.Create outboundplug from View2 to View1.(Navigation link also)
    5. In View1 button action fire the outboundplugto View2
    6. In View2 button action fire the outboundplugto View1.
    Regards, Anilkumar

Maybe you are looking for

  • Universal Binary..Once and For All

    I know this topic has been discussed, but I'm still a little confused. I want to put this issue to rest, at least from my perspective. If you install a Universal Application via download or CD/DVD does it install an application that would be able to

  • Server definition goes suddenly wrong with Wordpress site and DW CS5

    Let me explain this simply. I install a worpdress site, normally, on my local server (xampp). After setting up the site with the web-install thingy, I start DW. I set a definition site with the new (not at all improved) site definition dialog-box. //

  • Table for Vendor Master Email ID

    Hello, Can you please tell me the table where Vendor Email ID is stored and also how to connect it from LFA1-ADRNR in ECC 6.0? Thanks, Venu

  • Is there any way to see all the contents of my library in one view?

    I love itunes version 7, but one thing I miss: in the old itunes you could pick the "library" view and see everything you had in one view: music, podcasts, etc. This was useful because I liked to see the "date added" feature to get rid of the old pod

  • Alpha Channel Video Preloader

    We are creating a project that includes a number of alpha channel videos of the course narrator and other characters.  Playback works well however, before each video plays, there is a brief "loading" message and then the video pops onto the screen an