Posts

java - JFrame window doesn't show up? -

i'm building space invader style game in java. first do, i'm trying make sense of it. main requirement runs on desktop. now i'm trying use jframe this, isn't letting me want do. when run app, show java "app" running in dock (i run osx), actual jframe window doesn't show up. this how create window: public gildeinvaders() { add(new panel()); settitle("gilde opleidingen space invaders"); setdefaultcloseoperation(exit_on_close); setsize(500, 500); //setsize(gildeinvaders.getconfiguration().getint("game.width"), gildeinvaders.getconfiguration().getint("game.height")); setlocationrelativeto(null); setvisible(true); setresizable(true); } public static void main(final string[] args) throws ioexception { new gildeinvaders(); } the panel i'm initiating instance of jpanel, think right approach: public class panel extends jpanel implements runnable { // lot of variables her...

sql server - How to get the message of RaiseError of a procedure in another procedure -

i have 2 procedures proc_a , proc_b . in both procedure transaction managed. proc_b throws error calling raiseerror , passes message in condition raiserror ('initiator inactive', 16, 1, 'approve transaction'); i executing (calling) proc_b in proc_a . want error message thrown proc_b in proc_a . how can that? try this: create procedure dbo.testa begin raiserror ('initiator inactive', 16, 1, 'approve transaction'); end; go create procedure dbo.testb begin begin try exec dbo.testa; end try begin catch select error_message(); end catch end; go exec dbo.testb; go drop procedure dbo.testb; drop procedure dbo.testa;

windowlistener - Cannot downcast an Object into Frame in Java Window Event handling -

i learning basic event handling in java. i working on frame closing method (implemented windowlistener). understand getsource() call returns object actual event taking place. when downcast window, works fine when downcast 1 more level below (to frame), doesn't work , gives error- frame cannot resolved type in main class, extending frame. @override public void windowclosing(windowevent e) { object objsource= e.getsource(); //window objwindow = (window)objsource; - works fine frame objwindow = (frame)objsource; //- why doesn't work objwindow.dispose(); } unfortunately import java.awt.frame; package not imported in code hence giving error in closing frame window. above code works both frame , window call.

c# - Async methods return null -

if try mock type containing async method such : interface foo { task<int> bar(); } then mock's bar method returning null. guess moq choosing default(task<int>) default return value method, indeed null . moq should rather choose task.fromresult(default(int)) default value. can force moq make async methods returning non-null tasks ? if interested, made extension class makes async methods stubing less verbose : public static class setupextensions { public static ireturnsresult<tmock> returnstask<tmock, tresult>( isetup<tmock, task<tresult>> setup) tmock : class { return setup.returns(() => task.fromresult(default(tresult))); } public static ireturnsresult<tmock> returnstask<tmock, tresult>( isetup<tmock, task<tresult>> setup, tresult value) tmock : class { return setup.returns(() => task.fromresult(value)); } public static ireturnsr...

javascript - Angular ng-bind-html - prevent execution of JS code -

i have problem ng-bind-html directive. i email html data external services (not trusted), may happen receive <script> tag inside message body. don't want execute js code on page. using ng-bind-html directive this. i created example , problem alert() function executed. how deny this? var app = angular.module('myapp', ['ngsanitize']); app.controller('mainctrl', function ($sce, $scope) { $scope.text = " <script>alert(222)</script> <script>alert(222)</script>"; }); <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script> <div ng-app="myapp" ng-controller="mainctrl"> <div ng-bind-html="text"></div> </div> https://jsfiddle.net/suvroc/0c0ee472/8/ since have referenced old version of angularjs, prevented getting proper errors, difficult interpret. tried in similar...

jquery - Node.js and Socket.io not working on this Example -

can please take @ following code , let me know doing wrong on that? running node.js + express + socket.io on ubuntu 12.4 trying create simple push function. server working cant see div id "status" content on page , apparently function not running! thanks , comment in advance , sorry long post! here app.js file /** * module dependencies. */ var express = require('express') , routes = require('./routes') , user = require('./routes/user') , http = require('http') , path = require('path'); var app = express(); // environments app.set('port', process.env.port || 3000); app.set('views', __dirname + '/views'); app.set('view engine', 'jade'); app.use(express.favicon()); app.use(express.logger('dev')); app.use(express.bodyparser()); app.use(express.methodoverride()); app.use(app.router); app.use(express.static(path.join(__dirname, 'public'))); //...

How to read an element in an array and see if it matches with a target string despite double letters -

so i'm trying find amount of times string present in array. if had array of {ab, abbbb, aaaabbb, ac} , had target string of ab, frequency of string ab 3 in array. program disregard repeating abbbb , aaaabbbb , read these element ab. have code changing duplicated sequence non-repeating sequence , comparing target if statement, it's not working , i'm not sure why. `it returning 0 value, when there should number. this code: public static int findfreqwithmutations (string target, string [] arr) { int count=0; (string s:arr) { string ans= ""; (int i=0; i<s.length()-1; i++) { if (s.charat(i) != s.charat(i+1)) { ans= ans + s.charat(i); } } if (ans == target) { count++; } } return count; } ` i'm going make assumption java context clues. looks you're getting wrapped in searching str...