Add action to a button
Hi everybody,
i�m a beginner programming JAVA. So i think the question will be so easy.
How can I add an action to a button created on a container???
i.e. i want that when pressing the button, a word document can be opened.
thank you very much in advance.
hi,
you need to add a listener to the button such as an actionlistener:
JButton button1 = new JButton();
button1.addActionListener(new buttonListener());
// This should be an inner class
class buttonListener implements ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("Event generated!");
}you an use an inner class to handle the event, pass the addActionlistener an object of the inner class, the inner class here should implement the actionlistener interface which has the actionPerformed method. You need a listener, best place to find one is the API.
Similar Messages
-
Not able to call action of a button
Hi All
RIght now i am facing a very strange issue.
In my applictaion if on my page i drop a buttion and add action for that button.
If i add a SOP(System.out.println()) in that action i am able to see that in my back end means action is called. But on one specific page when i add a button and add action its not working.
I am not able to see the SOP on a specific page means action is not called.
Any idea why button on that specifci page is not called ?
Thanks in advance,
VikasWhich page?
Which jdev version?
Which UI technology you are using?
What's the difference to the other pages?
How do you get to the page in question?
Timo -
Can I add Action button on each page of my pdf document
I have created many power point slides with an action button on each slide that allows the user to click to display a video clip. I would like to create a pdf document of this and replace each of my action button in ppt with an action button that works in Acrobat.
I noticed that action buttons can be added to forms, but I want to be able to add an Action Button on each of my ppt slides to start playing a video clip (each slide will have a different video).
I would like to do this using any coding method (i.e. Javascript, VBA, C , etc). I think acrobat uses Javascript.
The reason, is that I want to display my power point slides on an IPad and they don't support hyperlink in power point. I believe IPad does suppport the full acrobat capabilities.
Can this be done ??
Any suggestions where to start ??
Thank You,
GNO problem creating the buttons and then playing this back in Acrobat. Works great.
However, unfortunately, none of the PDF viewers for the iPad support playing movies. So playing it there won't work :(.
From: Adobe Forums <[email protected]<mailto:[email protected]>>
Reply-To: "[email protected]<mailto:[email protected]>" <[email protected]<mailto:[email protected]>>
Date: Sat, 28 Jan 2012 11:00:47 -0800
To: Leonard Rosenthol <[email protected]<mailto:[email protected]>>
Subject: Can I add Action button on each page of my pdf document
Can I add Action button on each page of my pdf document
created by gw70115<http://forums.adobe.com/people/gw70115> in Acrobat SDK - View the full discussion<http://forums.adobe.com/message/4171109#4171109 -
Add advanced action to submit button and setting different objectives score for the same course
Hi, i would like to increase a counter in a quiz slide when the user press the submit button, using advanced actions.
It's like if the submit button is somehow inhibited from certain options, and i cannot find how to add an advanced action to it.
what i need, is to allow unlimited attempt until the user selects the right answer. each time the user click on submit, a counter increases by one. When user finally select the right answer, we read the counter value and assign a different score, depending on the attempt (for example: 1st attempt=20 points, 2nd attempt=10 points, 3rd attempt=0 points)
After that, i need to save all score obtained for a certain group of quiz slide separately from the "main score" (i think the main score is stored in cmi.objectives.0.score) to have partials scores for a course. I examined the "advanced interactions" panel and i noticed that for each quiz slide there is a specific interaction ID and each quiz slide is associated typically to the same Objective ID. What i need is to associate different groups of slides to different Objective ID's.
In Storyline i was able to do this by passing to the lms a cmi.objectives.n.score (where "n" is the place in the objectives array) and i did it by executing a javascript on success for each question slide. (each javascript added the score of previous slides in the same group to obtain the total score of the group to be passed to lms with a specific function).
examining captivate scorm functions in the published scormdriver.js i found the following function
function SCORM_SetObjectiveScore(strObjectiveID,intScore,intMaxScore,intMinScore)
so i think it can be done the same way in captivate executing javascript in the right way.
Is there also an easier solution to write different scores to different obectives in the same course?
many thanks for any help!Have a look at:
Question Question Slides in Captivate - Captivate blog
Question Question Slides - Part 2 - Captivate blog
Indeed, Submit button is part of the Question slide, not a normal button. You can add a custom shape button, but it will never replace what happens when the Submit button is clicked: validation of the answer, showing captions, adding to score etc. Making the score depending on the attempt is not possible with default functionality, it is possible with custom question slides, but then the reporting to LMS is another issue. You should try to do it by JS, or if you only need SWF-output you could use the Master widget by InfoSemantics.
Link score to attempts in Custom questions - Captivate blog
Lilybiri -
Cannot Add Actions to Button or MC
I know this is very basic, but I keep getting a message that
says 'The current selection cannot have actions applied to it' when
every I try to add actions to MovieClips and Buttons, in addition
to images I have placed in the Library. When I select the stage,
however, I can apply actions to it. Anyone know what I'm missing?
Thanks in advance.djdk224,
> Ok, thank you. I'm very new to Flash and I don't have a
clue
> about anything, so I really appreciate the help with
this.
The reason you can't attach code to assets in the Library is
because
assets are reusable. For example, you might create a nice
looking button
and re-use it half a dozen times in the same frame of the
timeline. That
means you have six "instances" of that button on the
timeline, each of which
can be (probably will be!) programmed separately. Makes
sense, right?
What kglad was alluding to is another approach to wiring up
your assets.
I agree with him that non-attached code gives you more
flexibility. Here's
a quick look at both approaches:
http://www.quip.net/blog/2006/flash/museum-pieces-on-and-onclipevent
David Stiller
Co-author, Foundation Flash CS3 for Designers
http://tinyurl.com/2k29mj
"Luck is the residue of good design." -
Can't add action script to my buttons, need help
I'm trying to add action script to my buttons to link them but the script menu has the message "Current selection cannot have actions applied to it" Why is this happening?
see attachedOkay,
I have a page where I have a button that states "PRODUCTS". I need to get
the button to send the user to another page called "products.swf
(products.fla)". What script to I insert in the actions menu?
Thanks
Derrick Young - Graphic Designer, Art Dept.
(d) 403.250.4261 | (f) 403.250.4336 | www.calgarysun.com
(e) [email protected] | (a) 2615 12th Street N.E., Calgary, AB
T2E 7W9 -
How to add a google+ share button to a composition?
I am working on a little app for which I want to add share buttons.
I don't have problems adding Facebook share and Twitter buttons, However I cannot find a way to add a Google+ share button.
For FB I create a rectangle and name it fbBtn. Then on click I add the foolowing code:
FB.ui({
method: 'feed',
name: 'Win designer fashion jewelry from Baloka',
link: ' http://www.mysite.com/',
picture: 'http://www.mysite.com/external-xfbml/share-image.gif',
caption: 'Win designer fashion jewelry from Baloka',
description: 'Baloka is giving away 22 designer fashion jewelry by Maria Mizrahi. Check this out. Do you want to win? You could...',
message: ''
For Twitter I create a rectangle and name it twitterBTN. Then I add this code to document.compositionReady:
var twitter = sym.$("twitterBTN");
var c = '<a href="https://twitter.com/share" class="twitter-share-button" data-url="http://baloka.com/content/socialApp/fb.html" data-text="Win cool trendy designer fashion jewelry - check this out" data-via="BalokaDesign" data-count="none" data-hashtags="BalokaSweepstakes">Tweet</a><script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id =id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(docu ment,"script","twitter-wjs");</script>';
twitter.html(c);
For Google + I found two ways to add a share button:
First:
Adding this snipped to the html document (not in EA):
div class="edgeLoad-EDGE-467457915"><a href="https://plus.google.com/share?url={http:baloka.com}" onclick="javascript:window.open(this.href,
'', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=600,width=600');return false;"><img
src="https://www.gstatic.com/images/icons/gplus-16.png" alt="Share on Google+"/></a></div>
and adding this to the head:
<!-- Add the following three tags inside head. -->
<meta itemprop="name" content="Baloka Sweepstakes">
<meta itemprop="description" content="Win designer fashion jewelry by Maria Mizrahi - Baloka.
There are 22 prizes including earrings, bracelets, necklaces and a couple of $100 gift certificates.
Please share with your friends.">
<meta itemprop="image" content="http://cdn2.bigcommerce.com/server2100/a154e/products/102/images/243/LittleTotemEarrings__ 55527.1355162788.1280.1280.jpg">
This works as expected, but I am having a hard time position the button in the right place on my page. I can see the button in EA, but the position I set it in there is not maintained once the file is published.
Thus, I would like to know how to include the code directly in EA as I am doing with the Twitter and facebook buttons.
Second:
Adding this to the html document (not in EA):
<div id="gplus1" data-action="share" data-annotation="bubble" class="edgeLoad-EDGE-467457915"></div>
<!-- Place this tag after the last share tag. -->
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
</script>
Again, this works, although with this code I don't know how to customize the name, description and image for the info I am sharing.
In this case I was able to include the code on EA adding the following to document.compositionReady:
var googleplus = sym.$('googleplus');
var click = "javascript:window.open(this.href,'', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=600,width=600');";
var g = '<a href="https://plus.google.com/share?url={http://baloka.com/content/socialApp/fb.html}" onclick="click";return false;"><img src="https://www.gstatic.com/images/icons/gplus-16.png" alt="Share on Google+"/></a>';
googleplus.html(g);
The problem here is that instead of opening a window, it replaces the page with the one supposed to be on a different window, which I don't like.
So, in short, I need some help figuring out how to include the code directly in EA for the first method for Google+.I don't have an answer for you, but I do have a question. You said the FB code works. What did you do? What did you put in your html page? I tried the FB code above and it gives me an ID error. Appreciate it if you can elaborate more. I just posted the ff in the forum "Customizing FB Share in Edge Animate"
Thank you! -
Why am I getting this error? How do I add confirm message to button press?
Using Java Studio Creator.
I do not understand why I am getting the following page error:
Description: An unhandled exception occurred during the execution of the web application. Please review the following stack trace for more information regarding the error.
Exception Details: java.lang.IndexOutOfBoundsException
Index: 0, Size: 0
Possible Source of Error:
Class Name: java.util.ArrayList
File Name: ArrayList.java
Method Name: RangeCheck
Line Number: 546
======================================================================
I have a page that works.
It has a button that is created in the session bean code with the following java:
button = (HtmlCommandButton)application.createComponent(HtmlCommandButton.COMPONENT_TYPE);
button.setActionListener( application.createMethodBinding("#{ScheduleEditSessionBean.mainApply}", new Class[]{ActionEvent.class} ));
button.setId( "applyUndates" );
button.setType( "submit" );
button.setTitle( "Apply updates.");
button.setValue( "Apply" );
button.setStyle(style);
children.add(button);
When the button is pushed, it calls the following session bean method:
public void mainApply(ActionEvent actionEvent)
updateScheduleData();
scheduleAdjustFlag = 1;
dataApplied = true;
dataSaved = false;
addControls();
This all works just fine - no errors
====================================================================
I wanted to add confirmation to the button press, so I removed the action listener for this button and added
a javascript function call for the onclick method
button = (HtmlCommandButton)application.createComponent(HtmlCommandButton.COMPONENT_TYPE);
style = "text-align: center; font-family: 'Arial','Helvetica',sans-serif; " + font + " height: 22px; width: 115px";
// Commented out this line button.setActionListener( application.createMethodBinding("#{ScheduleEditSessionBean.mainApply}", new Class[]{ActionEvent.class} ));
button.setOnclick("confirmApply()"); // Added this line.
button.setId( "applyUndates" );
button.setType( "submit" );
button.setTitle( "Apply updates.");
button.setValue( "Apply" );
button.setStyle(style);
children.add(button);
I added a dummy button to the page that has the following call to execute the mainApply method in the sessioon bean.
The button action just calls the mainApply() method in the session bean
public String mainApplyBtn_action() {
seb.mainApply();
return null;
Added the javascript to the page that simply pushes the dummy button if confirmed.
function confirmApply()
if( confirm( 'Are you sure you want to Apply these changes?' ) )
form1["form1:mainApplyBtn"].click();
The session bean method looks like this it is the same method as before, but without the action event argument.
public void mainApply()
lsb.logMsg( "<ScheduleEditBean.mainApply> Main apply pushed" );
updateScheduleData();
scheduleAdjustFlag = 1;
dataApplied = true;
dataSaved = false;
addControls();
==================================================================================
Now, when I push the original 'Apply' button, I get the confirmation box just like I expected.
But when I confirm the question, I get the error at the top of this post.
If I push the 'dummy button' directly, I do not get the error.
I do not understand why I should be gettng this error.
Can anyone give me a clue as to why this change would cause the problem?
The error is related to an ArrayList.
I use several of these on the page, but they should be filled with data in the preRender method of the page.
Can anyone suggest a way that I can add confirmation to a button that is created under program control?
ThanksMake use of the fact that when an onclick event of a button returns 'false', the action will not be taken.
Pseudocode:<h:commandButton value="submit" action="#{myBean.action}" onclick="return confirm('Are you sure?');" /> -
How do I add a functional "submit button" to a pdf form in Adobe Acrobat Pro XI ? I created the pdf form in Adobe Forms Central. It's for an online Diet Questionnaire. After people complete the form I'd like them to click "SUBMIT" and the completed form will be emailed to me.
This can be a bit confusing because Acrobat 11 comes with the desktop app that allows you to create simple PDF forms without having a FormsCentral account. Some people find this helpful, but you need to understand that when you generate the PDF form, it is Reader-enabled by Acrobat. In order to edit the form further in Acrobat, you have to create a non-enabled copy of the form. You do this in Acrobat by opening the form and selecting: File > Save a Copy
and opening the copy. It is not opened automatically.
You can now add a button and set it up to submit by email, either using a "Submit a form" action or the submitForm JavaScript method. You can set it up to include just the form data or the entire PDF, and will want to use a mailto type URL. Submitting the form to the FormsCentral server has a number of important advantages over email (much more reliable, more secure, etc.), so you might want to consider it.
If the form needs to be saved with Reader versions prior to 11, then you will need to Reader-enable the document. In Acrobat 11 you do this by selecting: File > Save As Other > Reader Extended PDF > Enable More Tools -
Creation of UI Element on the action of a button?
Hi,
Can we create some UI Element on the action of some button, i.e. writing code to create UI Element outside the wdDoModifyView() method of the view?
Regards,
Smriti.Hi,
We can create an UI element dynamically, on button click action..Follow the steps given below:
1. Create a static variable say ' myvar ' of type com.sap.tc.webdynpro.progmodel.api.IWDView in last declaration part(ie. inside //@@begin others //@@end.
Eg: static IWDView myview;
2. 2. In wdDoModifyView(), add the following
myview=view;
3. Now add the following code in the "OnAction<Submit>" event to create an UI element dynamically:
IWDTransparentContainer rootContainer = (IWDTransparentContainer)view.getElement("RootUIElementContainer");
IWDLinkToAction Link1 = (IWDLinkToAction) view.createElement(IWDLinkToAction.class, "Link1");
rootContainer.addChild(Link1);
Hope it helps!!!
Regards,
TFG - Kumara Guru -
Windows 8 and PSE7 and PSE11 how to add actions
I changed over to Windows 8. PSE 7 downloaded and opens up just fine. I cannot seem to find any info on how to add actions to PSE7. Windows 8 is not setup like 7. There is no start button. You cannot input programdata to find the hidden files. I downloaded PSE11 trial version thinking it was just PSE 7..........same thing, downloaded no problem, opens up but how do you add actions? I used many actions to resize the file, sharpen, and a few makeover actions by Florabella. I would love to be able to use those again. Thank you.
You probably need to do some study on how Microsoft expect Windows 8 to be used, especially if you don't have a touch screen.
Two thoughts
1. If you don't have a touch screen, Adobe Reader Touch may not be the best choice. It is much more limited than the regular Adobe Reader. Did you pick it for a reason, or just because Microsoft encouraged you into their App Store?
2. Try a right click, sometimes seems to substitute for a touch off the edge. I know you can't just use the mouse as if it were touch. -
Help! Can't add action to anything in flash CS4?
As the title says, i can't seem to add any action to any object,clip or button. Can anyone help me with this?
Sorry I took such a long time to reply. I dont think the problem is with the file because i tried opening a old file which was working fine and then couldnt add actions to anything. I also tried making a new flash project which similarly does not work.
-
Hello,
I want to add custom action when i click on my 'Yes' or 'No'.
This the code i used to create my and add actions to it.
lo_api_component = wd_comp_controller->wd_get_api( ).
lo_window_manager = lo_api_component->get_window_manager( ).
lo_window = lo_window_manager->create_window(
window_name = 'POPUP_WIND'
title = 'Microsoft Internet Explorer'
close_in_any_case = abap_true
message_display_mode = if_wd_window=>co_msg_display_mode_selected
close_button = abap_true
button_kind = if_wd_window=>CO_BUTTONS_YESNO
message_type = if_wd_window=>CO_MSG_TYPE_QUESTION
default_button = if_wd_window=>CO_BUTTON_NO
lr_view_controller = wd_this->wd_get_api( ).
lo_window->subscribe_to_button_event( button = if_wd_window=>CO_BUTTON_YES button_text = 'Yes'
action_name = 'SUBMIT' action_view = lr_view_controller ).
lo_window->subscribe_to_button_event( button = if_wd_window=>CO_BUTTON_NO button_text = 'NO'
action_name = 'Cancel' action_view = lr_view_controller ).
lo_window->open( ).
In my view that calls the popup i have created the action submit and cnacel.
But when i run the WDA i get this message: Action &OBJECT_ID& does not exist
Does any one have a clue?
Thanksaction_name = 'Cancel' action_view = lr_view_controller ).
IT SHOULD BE IN CAPS I.E. CANCEL NOT Cancel
so write it like
action_name = 'CANCEL' action_view = lr_view_controller ). " cancel in caps CANCEL
This will work.
thanks
sarbjeet singh
Edited by: sarbjeet singh on Feb 9, 2011 3:26 PM -
Actions on the main page..do they affect actions on movie buttons?
ON the home page I've created, the buttons I used with the
code in my previous thread ("two questions about HTML publishing
and buttons"), I added an on rollover action to the actions layer
of the main timeline (not the movie button timeline) so that on
rollover, a picture would change according to the button that was
rolled over. I did this for all three buttons. The rollover action
works great, but now the links don't work in either the html OR the
swf version. Would the added action disable the movie-clip button
actions? Here's the added main timeline code, edited for space:
photobtn_mc.onRollOver = function() {
gotoAndStop(2);
photobtn_mc.onRollOut = function() {
gotoAndStop(1); ( Again, help is greatly appreciated!)When you add actions to a movie clip, they will take
precedence to any buttons you have inside the movie.
You can code the button however to control any movie clip as
long as you give every movie name and reference it from the root.
ie.
on (release)
_root.main.speller.nameframe.gotoAndStop(1); -
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
TanvirIn 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.
Maybe you are looking for
-
When I print a photo to my epson printer, it comes out larger than the original photo - so the photo prints beyond the borders. Tried readjusting all sorts of things but nothing helps. I had this same problem with my Canon. any ideas?
-
How can i get rid of the clock on lockscreen without using cydia
how do i remove the clock from the lockscreen as i havent got a jailbroke iphone and cannot use cydia
-
My External hard drive recently died, and I had my "My Music" folder on it with all my music. However, since my "My Music" folder was on the ext. drive, which is now dead, I can't open iTunes in general on my computer. Here's what the error message s
-
Can't get image to "open in" CC Ps6 always opens
When I try to get a jpg file to "open in" Ps CC it opens in Ps6. I have checked the shortcut I use to open CC and it is C:\Program Files\Adobe\Adobe Photoshop CC (64 Bit) But the only EXE file in that folder opens Ps6; even though my shortcut; with t
-
Getting list of nominee(Member) in Collaboration Room
Hi Experts I want to find out the Expert member of the Collaboration room for that based on document rating we selected some member list and nominate some members by other member ( we get some list of member ) Where the list of members stored. the li