event-handling

java action listener: implements vs anonymous class

痴心易碎 提交于 2019-12-05 00:34:26
问题 I am trying to teach myself Java and had a question that I wasn't able to answer so far. In some of my reading online I have found two ways of using action listener that seem to do the same thing. But I am trying to figure out what is the advantage/disadvantage of one over the other. Is it better to use anonymous class like this: public MyClass() { ... myButton.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { //doSomething } }); ... } or is it best to

Why DragHandler exportAsDrag disables my MouseMotionListener?

故事扮演 提交于 2019-12-05 00:28:35
I want to realize a simple JComponent-Drag-and-Drop with a preview from O.Reilly-Swing.Hacks Hack 69. Translucent Drag-and-Drop . My Problem is if the TransferHandler start the Drag the MouseMotionListener stop performing mouseDragged(). Here is a little Sample code: A small Window with a green and a red Side. The green Side do not start a Drag, always mouseDragged() is performed but the exportDone() will never reached. The red Side starts a Drag via exportAsDrag(), but after that the mouseDragged() will not work anymore. public class Drag extends JPanel implements Transferable,

Get current cell column index in DataGridView CurrentCellChanged Event

让人想犯罪 __ 提交于 2019-12-04 23:45:04
I have the CurrentCellChanged event handler of a DataGridView and i want to be able to access the current selected cells column index from the event handler. I used to have the code in the CellClick handler which has DataGridViewCellEventArgs as a parameter so i was able to get the column index from the event args parameter but the CurrentCellChanged event has EventArgs as parameters which i believe is supposed to imply that theres no data for this event. Is there a way to access the new currently selected cells column index? Use DataGridView.CurrentCell property .. http://msdn.microsoft.com

What to do with IObservers being disposed?

♀尐吖头ヾ 提交于 2019-12-04 22:35:31
问题 I'm using Reactive Extensions for easy event handling in my ViewModels (Silverlight and/or Wp7 apps). For sake of simplicity let's say I have a line like this in the ctor of my VM: Observable.FromEvent<PropertyChangedEventArgs>( h => MyObject.PropertyChanged += h, h => MyObject.PropertyChanged -= h) .Where(e=>e.PropertyName == "Title") .Throttle(TimeSpan.FromSeconds(0.5)) .Subscribe(e=>{/*do something*/}); this returns an IDisposable object, which if disposed will unsubscribe. (Am I right in

How to detect when the form is being maximized?

丶灬走出姿态 提交于 2019-12-04 21:42:56
问题 I would like to detect when the form is going to be maximized to save certain settings (not related to the size nor position) and modify the size and position a little bit. Is there an universal way to do it ? I've tried to catch the WM_SYSCOMMAND message like in this article. It works well for maximization from menu, by maximize button, but it's not fired when I press the WIN + UP keystroke. Does anyone know an universal way how to catch the maximization event including the case with WIN +

Is it possible for Global Execution Context to pop off the execution stack?

陌路散爱 提交于 2019-12-04 20:53:33
问题 When JS code starts to run, the Global Execution Context is created and sits at the bottom of the execution stack as to "accomodate" Global Variable Object and 'this' . If it is the case for the execution stack to get empty after the whole JS code is run and there is no Global Execution Context, how are we still able to access the global variables (for example, I am running an html file with its JS code and after its completion, I am still able to see the values of global variables through

How can I bind many event handlers to one event using jQuery?

ε祈祈猫儿з 提交于 2019-12-04 20:18:25
I'm experience strange behaviour with jQuery while trying to attach more than one event handler to a single event. How would I bind two different event handlers, to the same event? $(this).focus(function(){/*...*/}); $(this).focus(function(){/*...*/}); // replaces the previous one? What am I missing? Update Do you know if it affects how event data is routed? It appears that adding a second event handler causes eventObject.data property to return undefined ...? Epilogue The problem was somehow related to the way jQuery normalizes event handling and how the eventObject data property changed

event listeners vs. event handlers [duplicate]

可紊 提交于 2019-12-04 19:37:42
This question already has answers here : Closed 8 years ago . Possible Duplicate: JavaScript Event Listeners vs Event Handlers element.onload vs element.addEventListener(“load”,callbak,false) I've read this question but it's still unclear to what's the difference between <input type="button" onclick="call_function();" /> And $(function() { $("#my_button").click(function() { call_function(); }); }); <input type="button" id="my_button" /> The first one is an event handler and the second one is an event listener, am I right? Is one way better than the other and why? Which one is better at

Dispatch dictionary but pass different parameters to functions

僤鯓⒐⒋嵵緔 提交于 2019-12-04 19:12:42
I'm using the dispatch pattern in python like this.... ok = parse_qsl(urlparse(u).query, keep_blank_values=True) eventType = (ok[9][1]) nName = (ok[10][1]) hName = (ok[11][1]) cName = (ok[12][1]) def newChannel(cName): queue = j.queue(cName) r = queue.add_subscribers(*[subscriberCreateChanTable, subscriberSortScenes]) def newNetwork(hName): queue = j.queue(hName) r = queue.add_subscribers(*[subscriber1a]) def loginError(nName): pass action = {'newChannel': newChannel, 'newNetwork': newNetwork , 'loginError': loginError} handler = action.get(eventType) handler(cname) How do I pass different

Raise custom events in C# WinForms

◇◆丶佛笑我妖孽 提交于 2019-12-04 18:05:19
问题 I have some Events I created on my own and was wondering on how to raise them when I want. Probably my application design is also messed up, might take a look at that if you like. This is the Structure ProgramContext - Form MainWindow + Control TextBox + Control Button + ... In this case, the MainWindow.TextBox holds some information that is updated quite often at runtime. So, I somehow need it to refresh itself when I want to (so it can reload its data from the database, where the it's