event-handling

How to keep and remove multiple graphic objects in java swing applications?

天大地大妈咪最大 提交于 2019-12-01 12:17:54
I have an image and I use pre-defined positions on it to create graphic objects with colors . With a mouse click I try to create some ovals on it with colors . Actually I couldn't achieve this objective. Because , when I click on a pre-defined position I could create an oval on it but when I click on another pre-defined position first oval has gone. An oval can be removed by click on it twice. Have look at this , public class PrintDialog extends javax.swing.JDialog{ private int count = 0; private int count_1 = 0; /** * Creates new form PrintFeetDialog */ public PrintDialog(java.awt.Frame

Listen to child MenuItem Click

爷,独闯天下 提交于 2019-12-01 12:09:42
Is there a way for a parent MenuItem to be notified when a child MenuItem is pressed. For example, I you have <MenuItem Name='a'> <MenuItem Name='b' Header='...'/> </MenuItem> how can I add an event handler to a to be notified when b is clicked. Ideally, the Click event would be either a tunnel or bubble event but this is not the case. The solution I have in mind is to listen to the Click event on b and forward it to a but this seems pretty heavy handed. Is there a better solution? MenuItem.Click is a routed event (it bubbles up), so you can just subscribe to it on the first MenuItem and be

Listen to child MenuItem Click

戏子无情 提交于 2019-12-01 11:13:57
问题 Is there a way for a parent MenuItem to be notified when a child MenuItem is pressed. For example, I you have <MenuItem Name='a'> <MenuItem Name='b' Header='...'/> </MenuItem> how can I add an event handler to a to be notified when b is clicked. Ideally, the Click event would be either a tunnel or bubble event but this is not the case. The solution I have in mind is to listen to the Click event on b and forward it to a but this seems pretty heavy handed. Is there a better solution? 回答1:

How to keep and remove multiple graphic objects in java swing applications?

假如想象 提交于 2019-12-01 09:47:12
问题 I have an image and I use pre-defined positions on it to create graphic objects with colors . With a mouse click I try to create some ovals on it with colors . Actually I couldn't achieve this objective. Because , when I click on a pre-defined position I could create an oval on it but when I click on another pre-defined position first oval has gone. An oval can be removed by click on it twice. Have look at this , public class PrintDialog extends javax.swing.JDialog{ private int count = 0;

Why doesn't a simple click: function()… work in ExtJS?

大兔子大兔子 提交于 2019-12-01 09:34:10
When the user clicks on this element, I want it to show an alert. However, when I click on the DIV that this Panel generates, nothing happens. How can I make an alert execute when the user clicks on the following panel? var content = new Ext.Panel({ region:'center', margins:'5 0 5 5', cls:'empty', bodyStyle:'background:ivory; font-size: 13pt', html:'<p id="test123">This is where the content goes for each selection.</p>', click: function() { alert('was clicked'); } }); Brian Moeskau You haven't accepted an answer, so I'll assume you're still unclear on this. Here are a few pointers... First, as

How to run a function once when binding to multiple events that all trigger in Javascript?

 ̄綄美尐妖づ 提交于 2019-12-01 09:18:48
I have a search input that listens to keyup and change to trigger an update of a listview via Ajax. Looks like this: input.on('keyup change', function(e) { if (timer) { window.clearTimeout(timer); } timer = window.setTimeout( function() { timer = null; val = input.val(); el = input.closest('ul'); // run a function - triggers Ajax widget[func](dyn, el, lib_template, locale, val, "update"); }, interval ); }); All working nice, except the handling of the timeout and binding, which causes double Ajax requests to be placed instead of a single one (when the keyup has passed, the change event

Catch ESC key press event when editing a QTreeWidgetItem

时间秒杀一切 提交于 2019-12-01 09:16:46
I'm developing a project in Qt. I have a QTreeWidget(filesTreeWidget) whith some file names and a button for creating a file. The Create button adds to the filesTreeWidget a new item(the item's text is "") who is edited for choosing a name. When I press ENTER, the filename is send through a socket to the server. The problem comes when I press ESC because the filename remains "" and is not send to the server. I tried to overwrite the keyPressEvent but is not working. Any ideas? I need to catch the ESC press event when I'm editing the item. You can subclass QTreeWidget, and reimplement QTreeView

Is it safe to replace all standard event handler to WeakEventManager or its varian?

心不动则不痛 提交于 2019-12-01 09:10:24
Standard event handler (with operator += ) is one of the memory leakage cause (if it is not unresgistered/disposed (with -= operator)). And Microsoft solved it with WeakEventManager and its inheritance like: PropertyChangedEventManager, CollectionChangedEventManager, CurrentChangedEventManager, ErrorsChangedEventManager and so on. The simple example code with memory leakage is: public class EventCaller { public static event EventHandler MyEvent; public static void Call() { var handler = MyEvent; if (handler != null) { handler(null, EventArgs.Empty); Debug.WriteLine("============="); } } }

How to update page data after event handling?

大憨熊 提交于 2019-12-01 09:03:42
On Page_Init I create a table of dynamically created controls based on a couple of database tables. One of the controls is an ImageButton for moving an list item up the list. What this event handler does is to update the SortOrder column in the database for the affected items. Now the problem is that since the controls are created in the Page_Init event and the SortOrder is updated later on when the ImageButton command event is fired. What's the best procedure for updating the table with the correct SortOrder. If I recreate the table after the event has fired the ImageButton command event does

Call the same function when clicking the Button and pressing enter

扶醉桌前 提交于 2019-12-01 08:27:32
I have a GUI that has Entry widget and a submit Button . I am basically trying to use get() and print the values that are inside the Entry widget. I wanted to do this by clicking the submit Button or by pressing enter or return on keyboard. I tried to bind the "<Return>" event with the same function that is called when I press the submit Button: self.bind("<Return>", self.enterSubmit) But I got an error: needs 2 arguments But self.enterSubmit function only accepts one, since for the command option of the Button is required just one. To solve this, I tried to create 2 functions with identical