Search Results

Search found 437 results on 18 pages for 'listeners'.

Page 1/18 | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Adding Listeners at runtime? - Java MVC

    - by Halo
    My model in my MVC pattern, generates components at runtime and gives them to the View to be displayed on the screen through update() method (you know, model is the observable and the view is the observer). But I also need to add listeners to these components, and the controller has the listener methods (because they say the MVC pattern is like this) and it's not involved in this update process. So I can't add the listeners at runtime, but only in the controller's constructor at startup. I've got an idea, that is making the controller the observer and then giving the data to the view, as well as adding the listeners. Do you think this would be OK?

    Read the article

  • flash as3 document class and event listeners

    - by Lee
    I think i have this document class concept entirly wrong now, i was wondering if someone mind explaining it.. I assumed that the above class would be instantiated within the first frame on scene one of a movie. I also assumed that when changing scenes the state of the class would remain constant so any event listeners would still be running.. Scene 1: I have a movieclip named ui_mc, that has a button in for muting sound. Scene 2: I have the same movie clip with the same button. Now the eventListener picks it up in the first scene, however it does not in the second. I am wondering for every scene do the event listeners need to be resetup? If that is the case if their an event listener to listen for the change in scene, so i can set them back up again lol.. Thanks in advance.. package { import flash.display.MovieClip; import flash.events.MouseEvent; import flash.media.Sound; import flash.media.SoundChannel; public class game extends MovieClip { public var snd_state:Boolean = true; public function game() { ui_setup(); } public function ui_setup():void { ui_mc.toggleMute_mc.addEventListener(MouseEvent.CLICK, snd_toggle); } private function snd_toggle(event:MouseEvent):void { // 0 = No Sound, 1 = Full Sound trace("Toggle"); } } }

    Read the article

  • Why use event listeners over function calls?

    - by Organiccat
    I've been studying event listeners lately and I think I've finally gotten them down. Basically, they are functions that are called on another object's method. My question is, why create an event listener when calling the function will work just fine? Example, I want to call player.display_health(), and when this is fired, the method player.get_health() should be fired and stored so that display_health() has access to it. Why should I use an event listener over simply calling the function? Even if display_health() were in another object, this still doesn't appear to be a problem to me. If you have another example that fits the usage better, please let me know. Perhaps particular languages don't benefit from it as much? (Javascript, PHP, ASP?)

    Read the article

  • New MAF Episode on Listeners and Events.

    - by Grant Ronald
    We've sneaked in an extra episode into the UI Development playlist of the MAF online training.  You can access the new episode on Listeners and Events here. Note, that we've renumbered all of the subsequent episodes (just incase you were referring back to the episodes by number.  This is a new episode 16). If you have any other ideas for new episodes, please let me know via a comment.

    Read the article

  • New MAF Episode on Listeners and Events.

    - by Grant Ronald
    We've sneaked in an extra episode into the UI Development playlist of the MAF online training.  You can access the new episode on Listeners and Events here. Note, that we're renumbered all of the subsequent episodes (just incase you were referring back to the episodes by number.  This is a new episode 16). If you have any other ideas for new episodes, please let me know via a comment.

    Read the article

  • User "oracle" unable to start or stop listeners

    - by user12620111
    Recently ran into a problem where user "oracle" was unable to start or stop listeners: oracle$ srvctl stop listener PRCR-1065 : Failed to stop resource ora.LISTENER.lsnr CRS-0245:  User doesn't have enough privilege to perform the operation CRS-0245:  User doesn't have enough privilege to perform the operation PRCR-1065 : Failed to stop resource ora.LISTENER_IB.lsnr CRS-0245:  User doesn't have enough privilege to perform the operation CRS-0245:  User doesn't have enough privilege to perform the operation The system is currently "fixed":oracle$ srvctl start listeneroracle$ srvctl status listenerListener LISTENER is enabledListener LISTENER is running on node(s): etc9cn02,etc9cn01Listener LISTENER_IB is enabledListener LISTENER_IB is running on node(s): etc9cn02,etc9cn01oracle$ srvctl stop listeneroracle$ srvctl status listenerListener LISTENER is enabledListener LISTENER is not runningListener LISTENER_IB is enabledListener LISTENER_IB is not runningoracle$ srvctl start listenerHow it was "fixed":Before:# crsctl status resource ora.LISTENER.lsnr -p | grep ACL=ACL=owner:root:rwx,pgrp:root:r-x,other::r--# crsctl status resource ora.LISTENER_IB.lsnr -p | grep ACL=ACL=owner:root:rwx,pgrp:root:r-x,other::r--"Fix":# crsctl setperm resource ora.LISTENER.lsnr -o oracle# crsctl setperm resource ora.LISTENER.lsnr -g oinstall# crsctl setperm resource ora.LISTENER_IB.lsnr -g oinstall# crsctl setperm resource ora.LISTENER_IB.lsnr -o oracleAfter:# crsctl status resource ora.LISTENER.lsnr -p | grep ACL=ACL=owner:oracle:rwx,pgrp:oinstall:r-x,other::r--# crsctl status resource ora.LISTENER_IB.lsnr -p | grep ACL=ACL=owner:oracle:rwx,pgrp:oinstall:r-x,other::r--I may never know how the system got into this state.

    Read the article

  • JPanel.addComponentListener does not work when the listener is a class variable

    - by Coder
    I have a public class which has the following method and instance variable: public void setImagePanel(JPanel value) { imagePanel = value; if (imagePanel != null) { //method 1 : works imagePanel.addComponentListener(new ComponentAdapter() { public void componentResized(ComponentEvent evt) { System.out.println("Here 1"); } }); //method 2 : does not work panelResizeListener = new ResizeListener(); imagePanel.addComponentListener(panelResizeListener); //method 3 : works //ResizeListener listener = new ResizeListener(); //imagePanel.addComponentListener(listener); //method 4 : works //imagePanel.addComponentListener(new ResizeListener()); //method 5 : does not work -- THIS IS THE DESIRED CODE I WANT TO USE imagePanel.addComponentListener(panelResizeListener); } } public class ResizeListener extends ComponentAdapter { @Override public void componentResized(ComponentEvent evt) { System.out.println("RESIZE 3"); } } private ResizeListener panelResizeListener = new ResizeListener(); Each of the methods above correspond the to code immediately below until the next //method comment. What i don't understand is why i can't use the class instance variable and add that to the JPanel as a component listener. What happens in the cases above where i say that the method does not work is that i don't get the "RESIZE 3" log messages. In all cases where i list that it works, then i get the "RESIZE 3" messages. The outer class is public with no other modification except that it implements an interface that i created (which has no methods or variables in common with the methods and variables listed above). If anyone can help me i would greatly appreciate it. This problem makes no sense to me, the code should be identical.

    Read the article

  • Java EE 6 - ordering Servlet Request Listeners

    - by Walter White
    Hi all, I finally updated to Java EE 6 (web profile) and would like to control the ordering of my servlet request listeners. I did that before through the XML ordering by listing the listeners in a particular order. Now, I have placed the @WebListener annotation on the classes which are listeners and am trying to figure out how to order the listeners such that they work properly. One must run before another one, otherwise, it won't have the information it needs and won't work. Also, it doesn't seem my listeners are actually being invoked even though they're marked with @WebListener. I am running embedded glassfish 3.0. Another question that is somewhat related - ServletRequestListeners in Java EE 6 by default are still synchronous meaning they're hit first, then servlet filters, right? ServletRequestListeners are not asynchronous where they merely get notified of an event without interrupting the execution? Walter

    Read the article

  • Multiple Audio listeners in Scene

    - by Kevin Jensen Petersen
    THIS IS UNITY Im trying to make a FPS game over networking, it works fine. But now, when im trying to implement sound, it won't work. My guess would be, to add a Audio listener to the prefab, that gets instansiated whenever a player connects to the server, however the problem about this is that each player's audiolistener have been switched out which the other player(s), so the AudioSource won't play at the player, but at someone else in the game. Any suggestions ?

    Read the article

  • Slick2D, Nifty GUI listeners problem

    - by Patokun
    I'm trying to get Nifty GUI to work with Slick2D. So far everything is going great, except that I can't seem to figure out how to properly interact with the GUI. I'm trying the example in the nifty manual http://sourceforge.n....0.pdf/download but it doesn't seem to entirely work. The Element controller is being called for bind(...), init(...) and onStartScreen() as it should, as I can see their println output, but the next() method isn't being called when I click on the GUI element that I assigned the controller to, nor the screen controller as no output from println is shown. What's weird is, that the player is moving, so the mouse input is working. It's supposed to be called when I click the mouse button on it from the in the XML. Here is my code: My Element controller: public class ElementController implements Controller { private Element element; @Override public void bind(Nifty nifty, Screen screen, Element element, Properties parameter, Attributes controlDefinitionAttributes) { this.element = element; System.out.println("bind() called for element: " + element); } @Override public void init(Properties parameter, Attributes controlDefinitionAttributes) { System.out.println("init() called for element: " + element); } @Override public void onStartScreen() { System.out.println("onStartScreen() alled for element: " + element); } @Override public void onFocus(boolean getFocus) { System.out.println("onFocus() called for element: " + element + ", with: " + getFocus); } @Override public boolean inputEvent(NiftyInputEvent inputEvent) { return false; } public void next() { System.out.println("next() clicked for element: " + element); } } MyScreenController: class MyScreenController implements ScreenController { public void bind(Nifty nifty, Screen screen) {} public void onEndScreen() {} public void onStartScreen() {} public void next() { System.out.println("next() called from MyScreenController"); } } And my XML file: <?xml version="1.0" encoding="UTF-8"?> <nifty xmlns="http://nifty-gui.sourceforge.net/nifty-1.3.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://niftygui.sourceforge.net/nifty-1.3.xsd http://nifty-gui.sourceforge.net/nifty-1.3.xsd"> <screen id="start" controller="predaN00b.theThing.V0004.MyScreenController"> <layer childLayout="center" controller="predaN00b.theThing.V0004.ElementController"> <panel width="100px" height="100px" childLayout="vertical" backgroundColor="#ff0f"> <text font="aurulent-sans-16.fnt" color="#ffff" text="Hello World!"> <interact onClick="next()" /> </text> </panel> </layer> </screen> </nifty> My main class, in case it's needed: public class MainGameState extends BasicGame { public Nifty nifty; public MainGame() { super("Test"); } public void init(GameContainer container, StateBasedGame game) throws SlickException { nifty = new Nifty(new SlickRenderDevice(container), new NullSoundDevice(), new PlainSlickInputSystem(), new AccurateTimeProvider()); nifty.addXml("/xml/MainState.xml"); nifty.gotoScreen("start"); } public void update(GameContainer container, StateBasedGame game, int delta) throws SlickException { nifty.update(); } public void render(GameContainer container, StateBasedGame game, Graphics graphics) throws SlickException { nifty.render(false); } public static void main(String[] args) throws SlickException { AppGameContainer app = new AppGameContainer(new MainGame()); app.setAlwaysRender(true); app.setDisplayMode( 1260 , 720, false); //window size app.start(); } }

    Read the article

  • Design Patterns for Coordinating Change Event Listeners

    - by mkraken
    I've been working with the Observer pattern in JavaScript using various popular libraries for a number of years (YUI & jQuery). It's often that I need to observe a set of property value changes (e.g. respond only when 2 or more specific values change). Is there a elegant way to 'subscribe' the handler so that it is only called one time? Is there something I'm missing or doing wrong in my design?

    Read the article

  • Using Mock for event listeners in unit-testing

    - by phtrivier
    I keep getting to test this kind of code (language irrelevant) : public class Foo() { public Foo(Dependency1 dep1) { this.dep1 = dep1; } public void setUpListeners() { this.dep1.addSomeEventListener(.... some listener code ...); } } Typically, you want to test what when the dependency fires the event, the class under tests reacts appropriately (in some situation, the only purpose of such classes is to wire lots of other components, that can be independently tested. So far, to test this, I always end up doing something like : creating a 'stub' that implements both a addXXXXListener, that simply stores the callback, and a fireXXXX, that simply calls any registered listener. This is a bit tedious since you have to create the mock with the right interface, but that can do use an introspective framework that can 'spy' on a method, and inject the real dependency in tests Is there a cleaner way to do this kind of things ?

    Read the article

  • Nodejs removing event listeners [migrated]

    - by JeffH
    Looking to get some help. I'm new to Nodejs and wondering if it is possible, to remove this custom event emitter. Most of this code comes from the Hand on nodejs by Pedro Teixeira. My function at the bottom is attempting to remove the custom event emitter you setup in the book. var util = require('util'); var EventEmitter = require('events').EventEmitter; // Pseudo-class named ticker that will self emit every 1 second. var Ticker = function() { var self = this; setInterval(function() { self.emit('tick'); }, 1000); }; // Bind the new EventEmitter to the sudo class. util.inherits(Ticker, EventEmitter); // call and instance of the ticker class to get the first // event started. Then let the event emitter run the infinante loop. var ticker = new Ticker(); ticker.on('tick', function() { console.log('Tick'); }); (function tock() { setInterval(function() { console.log('Tock'); EventEmitter.removeListener('Ticker',function() { console.log("Clocks Dead!"); }); }, 5000); })();

    Read the article

  • How to manage a lot of Action Listeners for multiple buttons

    - by Wumbo4Dayz
    I have this Tic Tac Toe game and I thought of this really cool way to draw out the grid of 9 little boxes. I was thinking of putting buttons in each of those boxes. How should I give each button (9 buttons in total) an ActionListener that draws either an X or O? Should they each have their own, or should I do some sort of code that detects turns in this? Could I even do a JButton Array and do some for loops to put 9 buttons. So many possibilities, but which one is the most proper? Code so far: import javax.swing.*; import java.awt.event.*; import java.awt.*; public class Board extends JPanel implements ActionListener{ public Board(){ Timer timer = new Timer(25,this); timer.start(); } @Override protected void paintComponent(Graphics g){ for(int y = 0; y < 3; y++){ for(int x = 0; x < 3; x++){ g.drawRect(x*64, y*64, 64, 64); } } } public void actionPerformed(ActionEvent e){ repaint(); } }

    Read the article

  • Keeping the number of objects and event-listeners on stage as low as possible

    - by DevEight
    Hello. I am creating a site with lots of big scrollable text-boxes in it. Each text-box object contained some text, and two buttons to scroll up/down with. The scroll buttons each had an event listener so the text moved when you clicked them. These text-boxes were stacked on-top of each other with all except one having an alpha of 0. If I wanted to change which text-box is active I move it to the front and call a small TweenLite animation. To the left (outside of the text-box objects) I have an object similar to a menu. It also has about 12 or so event-listeners (one for every button). This turns out cause A LOT of lag an it's very troublesome for my laptop to run it. What I need help with doing is to reduce the number of event-listeners on the stage and also the amount of text-boxes. What I was thinking was to add the text-boxes using AS so I only have 1 on the stage at a time but I couldn't figure out how to do it. I also thought it might be better to just use 1 big event-listeners and from mouseX and mouseY decide which button the user is trying to push. Are there any better alternatives to this? And if so, please elaborate on how to do it.

    Read the article

  • interactive (adding listeners to) DAE model in flex + papervision

    - by G. Matthieu
    I have a DAE model that is parsed into several parts. I am able to deal with them separately, such as changing their material or colour but I am having problems adding click or hover listeners over the children. For example, lets say I have a model of a kitty where each facial feature is a child. I want to be able to hover or click the features and have a window pop up explaining the feature. I've tried parsing the model and adding listeners but it doesn't seem to work. Thanks in advance! L

    Read the article

  • JBoss Seam - order event listeners

    - by Walter White
    Hi all, I would like to order my event listeners. Is it possible to do this in JBoss Seam 2.x? I am thinking as a workaround, which is quite simple, I will just daisy chain my events: fire event A. do something on event A. a. fire event B do something on event B. Any comments with this design? Is this a good / bad practice? Thanks, Walter

    Read the article

  • as3 loops and event listeners

    - by Ross
    I have an array that returns multidimensional data from an mysql database, when this is collected the createNews function creates the user interface. The problem I am having is the loop is iterating quicker than the ui is being created, is there a way to use event listeners with loops so it only continues after my function has completed its work. Any solutions or ideas are much appreciated; Thanks, R. var t:Array = responds.serverInfo.initialData; for (var i:uint = 0; i < t.length; i++) { var date = t[i][1]; var newstitle = t[i][2]; var story= t[i][3]; var image = t[i][4]; createNews(date, newstitle, story, image); }

    Read the article

  • AutoCompleteTextView with custom list: how to set up onClick Listeners and getting the selected item

    - by steff
    Hi everyone, I am working on an app which uses tags. Accessing those should be as simple as possible. Working with an AutoCompleteTextView seems appropriate to me. What I want: existing tags should be displayed in a selectable list with a CheckBox on each item's side existing tags should be displayed UPON FOCUS of AutoCompleteTextView (i.e. not after typing a letter) What I've done so far is storing tags in a dedicated sqlite3 table. Tags are queried resulting in a Cursor. The Cursor is passed to a SimpleCursorAdapter which looks like this: Cursor cursor = dbHelper.getAllTags(); startManagingCursor(cursor); String[] columns = new String[] { TagsDB._TAG}; int[] to = new int[] { R.id.tv_tags}; SimpleCursorAdapter cursAdapt = new SimpleCursorAdapter(this, R.layout.tags_row, cursor, columns, to); actv.setAdapter(cursAdapt); As you can see I created *tags_row.xml* which looks like this: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:paddingLeft="4dip" android:paddingRight="4dip" android:orientation="horizontal"> <TextView android:id="@+id/tv_tags" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:textColor="#000" android:onClick="actv_item_click" /> <CheckBox android:id="@+id/cb_tags" android:layout_width="wrap_content" android:layout_height="wrap_content" android:onClick="actv_item_checked" /> </LinearLayout> It looks like this: So the results are displayed just as I'd want them to. But the TextView's onClick listener does not respond. And I don't have a clue on how to access the data once an item is (de-)selected. Behaviour of the list should be the following: tapping a CheckBox item should insert/append the corresponding tag into the AutoCompleteTextView (tags will be semicolon-seperated) tapping a TextView item should insert/apped the corresponding tag into the AutoCompleteTextView AND close the list. So please help me out. Thanks in advance, steff

    Read the article

  • NHibernate save / update event listeners: listening for child object saves

    - by James Allen
    I have an Area object which has many SubArea children: public class Area { ... public virtual IList<SubArea> SubAreas { get; set; } } he children are mapped as a uni-directional non-inverse relationship: public class AreaMapping : ClassMap<Area> { public AreaMapping() { HasMany(x => x. SubAreas).Not.Inverse().Cascade.AllDeleteOrphan(); } } The Area is my aggregate root. When I save an area (e.g. Session.Save(area) ), the area gets saved and the child SubAreas automatically cascaded. I want to add a save or update event listener to catch whenever my areas and/or subareas are persisted. Say for example I have an area, which has 5 SubAreas. If I hook into SaveEventListeners: Configuration.EventListeners.SaveEventListeners = new ISaveOrUpdateEventListener[] { mylistener }; When I save the area, Mylistener is only fired once only for area (SubAreas are ignored). I want the 5 SubAreas to be caught aswell in the event listener. If I hook into SaveOrUpdateEventListeners instead: Configuration.EventListeners.SaveOrUpdateEventListeners = new ISaveOrUpdateEventListener[] { mylistener }; When I save the area, Mylistener is not fired at all. Strangely, if I hook into SaveEventListeners and SaveOrUpdateEventListeners: Configuration.EventListeners.SaveEventListeners = new ISaveOrUpdateEventListener[] { mylistener }; Configuration.EventListeners.SaveOrUpdateEventListeners = new ISaveOrUpdateEventListener[] { mylistener }; When I save the area, Mylistener is fired 11 times: once for the area, and twice for each SubArea! (I think because NHIbernate is INSERTing the SubArea and then UPDATING with the area foreign key). Does anyone know what I'm doing wrong here, and how I can get the listener to fire once for each area and subarea?

    Read the article

  • event listeners on plugin in document.onload events in opera

    - by gf
    I am trying to understand an issue where event-listener registration on plugins doesn't work in Opera unless i delay them. In particular, this doesn't work: document.onload = function() { plugin.addEventListener("foo", function() { alert('onFoo'); }, false); } while delaying the addEventListener() call somewhat through e.g. an alert() does: document.onload = function() { alert('onload()'); plugin.addEventListener("foo", function() { alert('onFoo'); }, false); } It seems that plugins are only loaded after document.onload. As a non-web-developer, am i missing something simple here? Or is this a known Opera problem with a common work-around?

    Read the article

1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >