Posts

Showing posts from August, 2010

javascript generator value of this -

what value of this in javascript generators in javascript? in below code, both comparisons return false, , when .tosource() , this appears empty object . references ecma or mdn docs helpful, wasn't able find in either. function thisgenerator(){ while(1) yield this; } var gen=new thisgenerator(); alert(gen.next()==thisgenerator); alert(gen.next()==gen); this still obeys normal rules. considering, global scope window : var gen = (function() { yield this; })(); gen.next() === window // true var gen = (function() { "use strict"; yield this; })(); gen.next() === undefined // true in quirks mode, this in unbound functions global scope (which happens window ), while in strict mode undefined . ps: when calling function bound, still usual: var o = { foo: function() { yield this; } }; o.foo().next() === o // true var o = {}; function foo() { yield this; }; foo.call(o).next() === o // true

css - :nth-child related only to specific class or element -

it's possible assign :nth-child specific element, without count other element in middle (ex http://jsfiddle.net/mgc4v/ <*br>). <p>1</p> <br> <p>2</p> <p>3</p> p:nth-child(3) { background-color:red; } the red line second one, not third..thanks p:nth-of-type(3) { background-color:red; } will select third <p> element :) , question ? see http://www.w3.org/wiki/css/selectors/pseudo-classes/:nth-of-type example : http://codepen.io/anon/pen/dxgos

getting a json string in php from jquery ajax post -

i tring write page, takes rss feed news site via ajax , sends php can work it. news feed returned object array. have tried posting is, , json string. post method seems success, php gives undefined index notice. first time using ajax , php , seem have problem getting data php side. the error: notice: undefined index: data in ...\index.php on line 33 current code following: ajax side url = 'http://feeds.bbci.co.uk/news/rss.xml?edition=int'; $.ajax({ type: "get", url: document.location.protocol + '//ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=1000&callback=?&q=' + encodeuricomponent(url), datatype: 'json', error: function(){ alert('load error, invalid url'); }, success: function(xml){ values = xml.responsedata.feed.entries; var senddata = json.stringify(values); console.log(senddata); $.ajax({ type: "post&qu

java - Why I can't use + operator with Integer and Double in generic method? -

i encountered strange issue. don't understand why code doesn't work: public static <type1 extends integer, type2 extends double > object addition(type1 first, type2 second) { return second * first; } the compiler claims operator * cannot applied type2,type1 . types extends integer , double has + operator defined them. don't understand this you wrong. neither integer nor double or other objects extending number class have "+" or other operator definied. reason why able perform (integer + double) autoboxing. , autoboxing kind of "hardcoded" feature applies small predefined set of classes, such integer, double, etc. furthermore, integer , other number subclasses declared "final", therefore "type extends integer" has no meaning, since cannot extend integer.

spring Transaction exception handling -

basically spring transaction management .we can annotate service layer class @transactional. also have annotated dao layer class @repository make checked exception unchecked exception. now when runtimeexception encoutered service layer class rollback. my question how go exception handling. have put error message ui .so need capture exception . how go it.

Is Three.js Normal Map Shader Computing Lighting In Tangent Space? -

i trying familiarized three.js , came across strange can't quite wrap head around. in other systems, (non web based), i've used, lighting normal maps calculated in tangent space. in three.js things bit different. example, if consider code in webglshaders.js @ line 2643: "mat3 tsb = mat3( normalize( vtangent ), normalize( vbinormal ), normalize( vnormal ) );", "vec3 finalnormal = tsb * normaltex;", they set orthonormal basis matrix tangent space, , transform normal space. far good. the issue is... seems place transform vectors tangent space??? so light direction vector calculate not converted tangent space, , neither eye direction vector??? both of subsequently used calculate lighting on lines 2692-2694: "vec3 pointhalfvector = normalize( pointvector + viewposition );", "float pointdotnormalhalf = max( dot( normal, pointhalfvector ), 0.0 );", "float pointspecularweight = speculartex.r * max( pow( pointdotnormalhalf,

c++ - Winbio.h No such file or directory error -

i'm experiencing dificulty in compiling tutorial msdn : http://msdn.microsoft.com/en-us/library/windows/desktop/ee207405(v=vs.85).aspx . mentioned in title, i'm getting no such file or directory @ compile time after linking winbio.lib generated using dumpbin , lib commands in vs 2008, , code : #include <iostream> #include <windows.h> #include <stdio.h> #include <conio.h> #include <winbio.h> hresult capturesample(); int main(int argc, char** argv) { hresult capturesample(); return 0; } hresult capturesample() { hresult hr = s_ok; winbio_session_handle sessionhandle = null; winbio_unit_id unitid = 0; winbio_reject_detail rejectdetail = 0; pwinbio_bir sample = null; size_t samplesize = 0; // connect system pool. hr = winbioopensession( winbio_type_fingerprint, // service provider winbio_pool_system, // pool type winbio_flag_raw, // access: capture raw data null,

android:how to ensure only one process(of a remote-service) running even all APPs integrated this service in the apk -

1.i'm implementing sdk using android remote service. 2.in order distribute sdk,i'd many apps integrate sdk be. 3.in order save system resources, i'd 1 process of remote service running in background support apps need remote-service. is there way achieve this? thanks. you write resource locking mechanism. if you're handling call app a, , app b wants same call, return error code isn't fatal, rather tells app try @ time. or create queue callback app b fires when app done.

ios - How to add and use a custom font in my xcode project -

Image
i trying add , use font within app. i've followed post reference can't work. i've added font frutiger95ultrablack.ttf supporting file , added {app-name}-info.plist. then tried use in app delegate change uinavegationbar nothing happens. what missing?? [[uinavigationbar appearance] settitletextattributes:[nsdictionary dictionarywithobjectsandkeys: [uicolor whitecolor], uitextattributetextcolor, [uifont fontwithname:@"frutiger95ultrablack" size:16.0], uitextattributefont,nil]]; (from above comment:) [uifont fontwithname:...] requires postscript name of font parameter, might different file name.

c# - React to dropping item out of Control with AllowDrop = true -

i'm new handling drag-n-drop events in c# , i've confronted problem. i have winforms project form containing button , panel. i've set panels allowdrop property true , added handler dragdrop event: panel1.dragdrop += new drageventhandler(panel1_dragdrop); for button i've added mousedown event handler initializes dragdropeffects: void btn1_mousedown(object sender, mouseeventargs e) { (sender button).borderstyle = system.windows.forms.borderstyle.fixed3d; dragdropeffects dde1 = dodragdrop((sender button), dragdropeffects.all); } i have no problem dragdrop event raised panel; my question how can handle event of user dropping item outside area allowdrop property set true? suppose want set buttons borderstyle fixedsingle when user while perfoming dragging releases mouse button outside of panel - event should handle? handle panel's dragleave event .

ios - UIViewController half screen "drawer slide" animation -

i trying have uiviewcontroller appears "slide" animation right. not push segue, not facebook app. want new viewcontroller slide on top of current 1 (not push away), cover part of screen, leaving other part showing first viewcontroller. what have tried: closest have gotten creating custom segue following: - (void)perform { __block uiviewcontroller *src = (uiviewcontroller *) self.sourceviewcontroller; __block uiviewcontroller *dst = (uiviewcontroller *) self.destinationviewcontroller; catransition* transition = [catransition animation]; transition.duration = .50; transition.timingfunction = [camediatimingfunction functionwithname:kcamediatimingfunctioneaseineaseout]; transition.type = kcatransitionmovein; transition.subtype = kcatransitionfromright; [src.navigationcontroller.view.layer addanimation:transition forkey:@"switchtoview1"]; [src.navigationcontroller pushviewcontroller:dst animated:no]; } this achieves anima

c - Buffer overflow works in gdb but not without it -

Image
i on centos 6.4 32 bit , trying cause buffer overflow in program. within gdb works. here output: [root@localhost bufferoverflow]# gdb stack gnu gdb (gdb) red hat enterprise linux (7.2-60.el6_4.1) copyright (c) 2010 free software foundation, inc. license gplv3+: gnu gpl version 3 or later <http://gnu.org/licenses/gpl.html> free software: free change , redistribute it. there no warranty, extent permitted law. type "show copying" , "show warranty" details. gdb configured "i686-redhat-linux-gnu". bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>... reading symbols /root/bufferoverflow/stack...done. (gdb) r starting program: /root/bufferoverflow/stack process 6003 executing new program: /bin/bash missing separate debuginfos, use: debuginfo-install glibc-2.12-1.107.el6_4.2.i686 sh-4.1# however when run program stack on own seg faults. why might be? exploit development can lead serious headaches if don&#

javascript - Google Maps Zoom in on Marker with One Click Multiple Markers -

i have read lot of other posts here on stackoverflow , in google search, , still cannot work correctly. think has loop. set mouseover event info windows, want map zoom in on marker when click , center in map. have tried: google.maps.event.addlistener(marker,'click',function(e) { map.setzoom(9); map.setcenter(e.latlng); }); which has worked best still doesn't center on marker, after multiple clicks. marker not in view. the code snippet wanted use this: // add double-click event listener google.maps.event.addlistener(marker, 'dblclick', function(event){ map = marker.getmap(); map.setcenter(overlay.getposition()); // set map center marker position smoothzoom(map, 12, map.getzoom()); // call smoothzoom, parameters map, final zoomlevel, , starting zoom level }) // smooth zoom function function smoothzoom (map, max, c

jquery - twitter callback for follower count -

$(function() { // number of twitter followers twitter.com twitterusername = 'hputtick'; $.getjson('http://twitter.com/users/'+twitterusername+'.json?callback=?', function(data) { $('.twitflw').append('' + data.followers_count + 'followers'); }); }) how can code left $('.twitflw').append(post) at moment follow count isn't showing @ on ipad or nexus.

node.js http server response socket write event? -

is there way control each step of tcp socket write know server side progress of large sized image data transfer? at worst, how alter main node bin folder add event? finally, can explain me why max length of node.js http tcp sockets 1460? from documentation : socket.write(data, [encoding], [callback]) sends data on socket. second parameter specifies encoding in case of string--it defaults utf8 encoding. returns true if entire data flushed kernel buffer. returns false if or part of data queued in user memory. 'drain' emitted when buffer again free. the optional callback parameter executed when data written out - may not immediately. event: 'drain' emitted when write buffer becomes empty. can used throttle uploads. see also: return values of socket.write() so, can either specify callback called once data flushed, or can register "drain" event handler on socket. doesn't tell progress on o

sonatype - How to create URL to browse an artifact in NEXUS repository? -

i want generate url browse directly artifact. i can browse specific repository following url. https://repository.sonatype.org/index.html#view-repositories;maven-sites~browsestorage is possible browse specific item single url? e.g. in above repository there artifact called nexus-oss/css. have url directly expand tree in browsestorage view artifact nexus-oss/css. thx derek you can browse directly, afaik not using nexus ui. example: https://repository.sonatype.org/content/sites/maven-sites/nexus-oss/css/ if there url this, reckon this: https://repository.sonatype.org/index.html#view-repositories;maven-sites~browsestorage~/nexus-oss/css/maven-base.css since url when select specific artifact , click "contained in repositories" link.

ruby - Why am I having trouble creating a custom array method that returns a hash with indices of matching array values? -

i'm trying monkey patch array class method that, when passed [1, 3, 4, 3, 0, 3, 1] , return hash { 1 => [0, 6], 3 => [1, 3, 5] } , key number matching to, , value array indices of matches. here's code have far. can't tell why it's returning {1=>[0, 2, 3, 1, 2, 0], 3=>[0, 2, 3, 1, 2, 0], 0=>[0, 2, 3, 1, 2, 0]} : class array def dups matches = {} matches_index = [] self.each |i| self[(i_index + 1)..-1].each_with_index |j, j_index| matches_index << j_index if self[i] == self[j] end matches[i] = matches_index end matches.keep_if { |key, value| value.length > 1 } end end to improve on stas s excellent solution: class array def dups (self.each_index.group_by {|i| self[i]}).keep_if{|k, v| v.size > 1} end end which results in array of only duplicates.

ios - Is it possible to move a ui element from one location to the other using fading? -

i able fade out uiview location , fade in @ location b at same time . possible ios? one way create image of view, put on screen (in image view) on actual view, set view's alpha 0, set frame (or adjust layout constraints) put in new position, start animation fades out image, , fades in actual view. something should work: #import "viewcontroller.h" #import <quartzcore/quartzcore.h> @interface viewcontroller () @property (weak,nonatomic) iboutlet uiview *fadingview; @property (weak,nonatomic) iboutlet nslayoutconstraint *topcon; @property (strong,nonatomic) uiimageview *iv; @end @implementation viewcontroller -(ibaction)moveview:(id)sender { uiimage *viewimage = [self imagewithview:self.fadingview]; self.iv = [[uiimageview alloc] initwithframe:self.fadingview.frame]; self.iv.image = viewimage; [self.view addsubview:self.iv]; self.fadingview.alpha = 0; self.topcon.constant = 200; // topcon iboutlet top constraint superview

html - Centering a DIV in CSS -

here link site working on friend - http://jayclarkephotography.com/ i trying center logo. have tried various ways, new making websites, think missing something. on a inside header, add following css: display: block; width: 340px; margin: 0 auto; you might want ajust padding of header, because logo not dead center.

php - Message array to string conversion -

that might fool question, need know how solve this: notice: array string conversion in c:\xampp\htdocs\search_view.php on line 248 why getting message, can solve it? echo'<div id="thumb"> '.$ids = array(); $ids[] = $results['idgames']; ($i = 0; $i < count($ids); $i++) { $id = $ids[$i]; $v = $results['total_votes']; $tv = $results['total_value']; if ($v) $rat = $tv / $v; else $rat = 0; $j = $ids[$i]; $id = $ids[$i]; echo '<div class="topcontentstar"> <div id="' . $id . '" class="">'; ($k = 1; $k < 6; $k++) { if ($rat + 1 > $k) $class = "" . $k . " ratings_stars_index ratings_vote"; else $class = "" . $k . " ratings_stars_index ratings_blank"; echo '<div class="' . $class . '"></div>'; } echo ' </div> </div></div>;

c# - Console.ReadKey Unexpected Behavior with Pasted Text - Multi-Keys Entered at Once -

call console.readkey() , @ prompt paste (edit->paste) of clipboard text length > 1 (let's 'hello world!'). i discovered unexpectedly, on subsequent calls console.readkey(), instead presenting prompt user, no prompt given! instead, subsequent characters pasted text read ... no prompt! bottom line: use readkey, need make sure (darn sure) when call readkey next time, gives user prompt. currently, makes readkey unusable critical scenarios this. it not there way disable this, or clear inputted not yet read out values. in case, presented critical errors simple console app, looping looking either words 'r' 'run', or 'e' 'end'. since near time prompt file path, easy @ point user has used paste file path @ point on accident. problem (!!!), if file path contained 'r', runs. using system; namespace practise1 { class program { static void main() { rundialogue2(); } public

packages - django-likes: setup and error -

being new django trying implement first package, django-likes, , keep running error below. documentation , project code listed below. advice , insight appreciated. note: model being utilized modelform documentation: https://crate.io/packages/django-likes/ error: exception type: keyerror exception value: 'request' exception location: /home/alxmrph/webapps/dearmusic/lib/python2.7/django/template/context.py in __getitem__, line 57 python executable: /usr/local/bin/python settings.py: template_context_processors =( 'django.contrib.auth.context_processors.auth', 'django.core.context_processors.debug', 'django.core.context_processors.i18n', 'django.core.context_processors.media', 'django.core.context_processors.static', 'django.core.context_processors.tz', 'django.contrib.messages.context_processors.messages', 'django.core.c

perl - How to remove lines from a list which can be found within other longer lines in the list? -

i have file, list.txt , this: cat bear tree catfish fish bear i need delete lines found somewhere else in document, either duplicate line, or found within longer line. e.g., lines "bear" , "bear" same, 1 of these deleted; "cat" can found within "catfish", "cat" deleted. output this: catfish tree bear how can delete duplicate lines including lines found within longer lines in list? so far, have this: #!/bin/bash touch list.tmp while read -r line found="$(grep -c $line list.tmp)" if [ "$found" -eq "1" ] echo $line >> list.tmp echo $line" added" else echo "not added." fi done < list.txt if o(n^2) doesn't bother you: #!/usr/bin/env perl use strict; use warnings; use list::moreutils qw{any}; @words; $word ( sort {length $b <=> length $a} { %words; @words = <>; chomp @w

javascript - Non-blocking Synchronous AJAX -

is there way perform synchronous ajax query doesn't freeze browser? in opinion synchronous requests lot easier work in cases, fact block other parts of code executing real killer. there way synchronous ajax without negative side effects? (and yes, realize term "synchronous ajax" oxymoron.) i'll provide example of bad side of effects of allowing such behavior. lets have program: <script> var file = "foo.json"; function nullit() { file = null; } function loadfile() { if (file != null) { synchronousload(file);//imagine load takes 5 seconds alert("i loaded: " + file); } } window.onload = loadfile; </script> <button onclick="nullit()">click me</button> the bad thing here- while synchronousload() blocking 5 seconds, user clicks button, , event handler runs completion. now file variable null. synchronousload() finishes , returns, letting execution resume on next li

javascript - button in jquery and jscript -

i trying understand difference between jquery , javascript. , apologies if silly question. this attempt @ jquery. on pressing button text in <p> should change requested. cannot work. http://jsfiddle.net/qahda/7/ this javascript attempt. cannot work either http://jsfiddle.net/alhb8/1/ can please me my jquery above working. my jscript above working. i trying point write jquery in such way written in javascript. can me this? thanks edit thanks answers/corrections: looking part 3 enter link description here part 1 using javascript,i think. in future should careful,using left hand pane, include jquery library , make sure jsript wrapped in head/body jquery you need include jquery library page selecting jquery version in first dropdown in left panel demo: fiddle js sample the problem since function defined within onload callback, not available in global scope causing error saying uncaught referenceerror: myfunction not defined the s

Wordpress navigation Menu issue -

i'm having problem second tier of navigation showing when hover on products button. can see problem here. http://www.americancarpgear.com any suggestions? change line 37 of index.js from: $(this).find('ul').stop(false, true).fadein(200); to: $(this).find('ul:first').stop(false, true).fadein(200); there multiple ul's within product drop down, children being shown on hover. instead, should show first child ul on hover.

php - LAST_INSERT_ID() not returning for all tags -

so have 3 tables follows. topics topic_tags tags topic_id tag_id tag_id topic_data topic_id tags right can insert topic_data topics, , tags being inserted so... tag_id tags 1 2 3 4 test but when i'm trying insert tag_ids topic_tags table, it's inserting last 1 this topic_id tag_id 0 4 and it's not inserting topic_id when topic inserted. this form posts data. <form method="post" action="add_topic.php"> <table> <tr> <td align="left"><b>enter topic keywords. <ul id="topic" name="tags[]"></ul> </td> </tr> <tr> <td colspan="3"><textarea name="topic_data" cols="50" rows="3" id="topic_data" placeholder="what topic talking about?"></textarea></td> </tr> <tr> <td colspan="3" a

go - How to pass type into an http handler -

i'm attempting separate http go code "controllers" creating new package them, can't figure out how pass db type handler. want able pass in db type create in main.go index handler in index.go. if wrong way solve this, let me know better way (i'm learning go , keep simple now). code far: main.go: package main import ( "database/sql" "fmt" _ "github.com/go-sql-driver/mysql" "github.com/gorilla/mux" "log" "mvc3/app/c" "net/http" ) var db *sql.db func main() { fmt.println("starting up!") var err error db, err = sql.open("mysql", "root@/dev?charset=utf8") if err != nil { log.fatalf("error on initializing database connection: %s", err.error()) } db.setmaxidleconns(100) err = db.ping() if err != nil { log.fatalf("error on opening database connection: %s", err.erro

Rails: using gsub to find and make links -

i've got text area called body in model. i'd change every image link image. i've got method supposed doesn't seem work. breaks @ each image. def get_images_in(body) body_with_links = body.gsub( %r{http://[^\s<]+} ) |url| if url[/(?:png|jpe?g|gif|svg)$/] "<a href='#{url}' target='_blank'><img src='#{url}' /></a>" end end return body_with_links end any ideas? thank-you! update here's link gist sample body text. first things first, don't need use return statement in ruby. ruby return last thing default. in case, string returned gsub : def wrap_image_with_link(body) body.gsub( %r{http://[^\s<]+} ) |url| if url[/(?:png|jpe?g|gif|svg)$/] "<a href='#{url}' target='_blank'><img src='#{url}' /></a>" end end end this still isn't quite right. focus initial regular expression on img tag: def

iphone - How to listen DataContext change to adjust UI state accordingly -

this question taking roots discussion inside https://github.com/slodge/mvvmcross/issues/367 thread. if we're following recent examples of setting bindings mvvmcross framework setup bindings control properties (like uilabel.text) using bind(), to() extensions: this.delaybind(() => { var set = this.createbindingset<kittencollectioncell, kitten>(); set.bind(namelabel).to(kitten => kitten.name); set.bind(pricelabel).to(kitten => kitten.price); set.bind(_loader).to(kitten => kitten.imageurl); set.apply(); }); (taken https://github.com/slodge/nplus1daysofmvvmcross/blob/master/n-11-kittenview_collections/kittenview.touch/views/kittencollectioncell.cs ) but if want adjust ui state basing on values datacontext. example show/hide buttons , labels , adjust constraint values. if (((userinfo)datacontext).isadmin) { savebutton.hidden = false; securitylabelconstraint.constant = 50; /* etc */ } how can listen datacontext change ev

postsharp 3 introduce/remove constructor aspect -

i'm evaluating postsharp 3.0 , know if there way introduce and/or remove constructors. the use case remove public parameterless constructors, , introduce private paramterless one. thanks in advance, kavan no, not possible remove or introduce constructors using postsharp.

Having issue with mapping in spring dispatcher servlet -

i have jsp page contains form , on submitting form need call get method. current mapping, when try load jsp page instead of loading jsp page calls get method. following mappings made. web.xml: <servlet> <servlet-name>dispatcher</servlet-name> <servlet-class>org.springframework.web.servlet.dispatcherservlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>dispatcher</servlet-name> <url-pattern>/test/*</url-pattern> </servlet-mapping> testharnesscontroller : @controller @requestmapping("/testharness") public class testharnesscontroller { @requestmapping(method = requestmethod.get) public string handlegetrequest(httpservletrequest request, httpservletresponse response) { return null; } @requestmapping(method = requestmethod.post) public string handlepostrequest(httpservletrequest request, httpservletresponse response) {

Append AJAX items to masonry with infinite scroll -

i've searched around , looked @ bunch of different logic, , think i'm close can't infinite scroll script append data masonry. have ajax file while pulling data, , main line inside of file pulls data when scrolling: function getdata() { // post data ajax.php $.post('ajax.php', { action : 'scrollpagination', number : $settings.nop, offset : offset, }, function(data) { // change loading bar content (it may have been altered) $this.find('#spinner').html($initmessage); // if there no data returned, there no more posts shown. show error if(data == "") { $this.find('#spinner').hide(); } else { // offset increases offset = offset+$settings.nop;

How do you make a multi lined text document within a batch file? -

what mean this: echo testing >> new_text_document.txt is there way give "testing" multiple lines? might work better variables like: set xyz= testing echo %testing% >> new_text_document.txt i don't know. if can help, apreaciated. in advance. there many ways, depends on need. 1 way put newline in variable (note 2 empty lines critical): @echo off setlocal enabledelayedexpansion set nl=^ echo two!nl!lines >> new_text_document.txt use 1 or 2 > not matter. since >> appends can many lines of echo too @echo off :other stuff echo multiple >> new_text_document.txt echo lines >> new_text_document.txt echo. >> new_text_document.txt echo of text >> new_text_document.txt that may clunky instead @echo off :other stuff ( echo multiple echo lines echo. echo of text ) >> new_text_document.txt last not least can similar bash trick have no eol marker. @echo off more +4 %~f0 &

vim plugin - Extraneous BufUnload event triggered in vim -

i run vim no file on command-line, shows scratch buffer. when run :e foo to edit file 'foo', there bufunload event triggered file 'foo'. here test vim command use demonstrate issue: autocmd bufunload * echom "unloaded " . expand("<afile>") does know causing this, , if there way detect situation , ignore it? i can reproduce latest vim 7.4a.39. guess has fact vim reuses initial scratch buffer number (1) first :edit ed file. please report problem vim_dev mailing list .

Python/wxWidgets: Vertically aligning text in a wrapped StaticText -

i've seen lot of posts around internet none of advice works. here test code: import wx class displaytext(wx.dialog): def __init__(self, parent, text="", displaymode=0): # initialize dialog wx.dialog.__init__(self, parent, size=(480,320), style=( wx.dialog_ex_metal | wx.stay_on_top ) ) # freeze ui user won't see stuff flashing self.freeze() # (for mac) setup panel self.panel = wx.panel(self,size=(480,320)) self.panel.setbackgroundcolour(wx.colour(0,0,128)) # setup sizer vertical centering self.sizer = wx.boxsizer(wx.horizontal) # create text field self.txtfield = wx.statictext(self.panel,size=(448,-1),style=wx.align_centre_horizontal) self.txtfield.setlabel(text) self.txtfield.wrap(448) self.txtfield.setlabel(self.txtfield.getlabel()) self.txtfield.setfont(wx.font(36, wx.default, wx.bold, 0)) self.txtfield.setforeground

canvas - Android Null Exception on Calling function -

i want change color on button click passing color integer parameter on click android throws error of null pointer exception. , application crashes .. stuck here kindly me please function name setcolor() myview class public class myview extends activity { button brushlarge; button brushmeduim; button brushsmall; button erase; button save; button trash; button rainbow; button color1; button color2; button color3; this.color1 = ((button)findviewbyid(r.id.color1)); this.color2 = ((button)findviewbyid(r.id.color2)); this.color3 = ((button)findviewbyid(r.id.color3)); this.color1.setonclicklistener(new view.onclicklistener() { public void onclick(view paramview) { toast.maketext(getapplicationcontext(), "color1", toast.length_long).show(); //myview.this.coloringview.setcolor("#cd5c5c"); } }); this.color2.setonclicklistener(new view.onclicklistener