Bit of oddness, seen if I do the following:
import javax.swing.*;
public class FunkyButtonLayout {
public static void main(String[] args) {
JFrame frame = new JFrame("");
JPanel j0 = new JPanel(); // j0 gets added to the root pane
j0.setLayout(null);
JPanel j1 = new JPanel(); // j1 gets added ...
I'm getting an unusual behavior that I can't seem to get to the bottom of. When I run this, if I move in the swf area it traces normally on mouse move. To be expected.
But it's tracing for the move event when I click anywhere on screen. If I click and drag, it traces as if I were moving in the swf area of the browser.
Here's the code. ...
Let's say I want some instance of String behave differently from other, "normal" instances - for example cancel the effect of the "upcase" method. I do the following:
class String
def foo
def self.upcase
self
end
self
end
end
It seems to work fine, and the way I need it:
puts "bar".upcase #=> "BAR"
puts "bar".fo...
I remember reading a book named:
Java Puzzlers Traps, Pitfalls, and Corner Cases
that described odd behavior in Java code. Stuff that look completely innocent but in actuality perform something completely different than the obvious. One example was:
(EDIT: This post is NOT a discussion on this particular example. This was the firs...
This may sound like a bit of a rhetorical question, but I ask it here for two reasons:
It took me a while to figure out what C++ std::norm() was doing differently from Matlab/Octave, so others may stumble upon it here.
I find it odd to define the norm() function as being something different (though closely related) to what is generally...
For Each row As DataGridViewRow In DGV.Rows
DGV.Rows.RemoveAt(CInt(row.Index.ToString))
Next
The above code will remove every other row
For i As Integer = 0 To 7 Step 1
For Each row As DataGridViewRow In DGV.Rows
DGV.Rows.RemoveAt(CInt(row.Index.ToString))
...
I'm writing a ChecklistBox control, which is a listbox that renders CheckBoxes inside the list. I'm then using this control inside of a DataForm's EditTemplate. Along with this control, I've got two text boxes that are bound to properties of the DataContext of the Dataform.
For reference, the ChecklistBox has three implemented propert...
In the question by DKSRathore How to simulate the Out Of memory : Requested array size exceeds VM limit some odd behavior was noted when creating an arrays.
When creating an array of size Integer.MAX_VALUE an exception with the error java.lang.OutOfMemoryError Requested array size exceeds VM limit was thrown.
However when an array was...
I have a combo, which is showing some awkward behavior. Given a list of options from the combo-box, the user should pick the name of a city clicking with the mouse. Here is the code:
QtCore.QObject.connect(self.comboCity, QtCore.SIGNAL("currentIndexChanged(QString)"), self.checkChosenCity)
def checkChosenCity(self):
...
Python's tarfile module ignores errors during extraction by default, unless errorlevel is set to either 1 or 2 (or debug to 1 if only error messages need to be printed).
Try doing a mkdir /tmp/foo && sudo chown root /tmp/foo && chmod a-w /tmp/foo and using tarfile to extract a .tar.gz file over /tmp/foo -- you will see that your Python...
In Visual basic 6, i declare a sub like this:
Private Sub test1(ByRef XmlFooOutput As String)
...
End Sub
Aafter that, I declare another sub like the following one:
Private Sub test2(ByRef xmlFooOutput As String)
...
End Sub
Automagically, the first method is transformed in:
Private Sub test1(ByVal xmlFooOutput As String)
....
I ran into a little problem today when I was creating a really quick script to scan lines files in a user specified directory for //todo:...
So I had a line like this:
if (stripos($data, '//todo:')) { //case-insensitive search ^^
//deal with the data appropriately
}
This did not find //todo: anywhere in any of the files! This was ...
Consider the following short code snippet.
namespace B
{
public class Foo
{
public string Text
{
get { return GetType().FullName; }
}
}
}
namespace A.B
{
public class Foo
{
public string Text
{
get { return GetType().FullName; }
}
}
}
Get ...
Hi, I'm having some trouble with a very basic CUDA program. I have a program that multiplies two vectors on the Host and on the Device and then compares them. This works without a problem. What's wrong is that I'm trying to test different number of threads and blocks for learning purposes. I have the following kernel:
__global__ void m...
So a bit of an overview around the lead up to this exception.
I've created a website on my dev machine (windows xp, asp.net 4) and targeted it to .Net 3.5. I then deployed the 100% working website on the stage machine (Windows 7, ASP.net 2, IIS 7.5).
After sorting out numerous security problems, I've come to a stop at this bewildering...
This is the weirdest thing that has ever happened to me sime I am a (PHP) programmer...
I have two files, with the following code (proj. euler stuff) that return different outputs.
<?php
$numbers =<<<eot
2,3
5,2
9,3
4,9
6,3
10,5
eot;
$numbers = explode("\n",$numbers);
$max = 0;
foreach($numbers as $k => $n){
list($base,$expo) = exp...
I'm starting to learn perl, using the Wrox Beginning Perl available on perl.org and have a question regarding a for loop example they provide in Chapter 3.
#!/usr/bin/perl
use warnings;
use strict;
my @count = (1..10);
for (reverse(@count)) {
print "$_...\n";
sleep 1;
}
print "Blast Off!\n"
This is the script they pr...
Why is
byte someVar;
someVar -= 3;
valid but
byte someVar;
someVar = someVar - 3;
isnt?
...
I'm trying to confirm a binding behavior I believe I have observed, but I'm not exactly sure of.
My original understanding was that a UserControl was sort of a black box, where if you wanted to share information back and forth with the controls contained within, you had to (1) use the DataContext or (2) define them on the surface of the...
In C#, if you have a struct like so:
struct Counter
{
private int _count;
public int Value
{
get { return _count; }
}
public int Increment()
{
return ++_count;
}
}
And you have a program like so:
static readonly Counter counter = new Counter();
static void Main()
{
// print the new v...