Search Results

Search found 190 results on 8 pages for 'zachary spencer'.

Page 1/8 | 1 2 3 4 5 6 7 8  | Next Page >

  • Custom Java ListCellRenderer - Can't click JCheckBox

    - by Spencer
    Made a custom ListCellRenderer: import java.awt.Component; import javax.swing.JCheckBox; import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JPanel; import javax.swing.ListCellRenderer; /** * * @author Spencer */ public class TaskRenderer implements ListCellRenderer { private Task task; private JPanel panel = new JPanel(); private JCheckBox checkbox = new JCheckBox(); private JLabel label = new JLabel(); public TaskRenderer() { panel.add(checkbox); panel.add(label); } public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { task = (Task) value; label.setText(task.getName()); return panel; } } Have a JList with each cell in it rendered using the above class, but the checkboxes in the panels for each cell cannot be clicked. Thought it had to do with it not getting focus. Any ideas? Thanks, Spencer

    Read the article

  • Java Singleton Pattern

    - by Spencer
    I'm used the Singleton Design Pattern public class Singleton { private static final Singleton INSTANCE = new Singleton(); // Private constructor prevents instantiation from other classes private Singleton() {} public static Singleton getInstance() { return INSTANCE; } } My question is how do I create an object of class Singleton in another class? I've tried: Singleton singleton = new Singleton(); // error - constructor is private Singleton singleton = Singleton.getInstance(); // error - non-static method cannot be referenced from a static context What is the correct code? Thanks, Spencer

    Read the article

  • Quick Java question about variables

    - by Spencer
    I'm declaring a variable: private static final String filename = "filename.txt"; First, does the order of private static final matter? If not, is there a standard excepted sequence or convention? Second, the filename in my application is fixed. Is this the best was to store it's value? Thanks, Spencer

    Read the article

  • How do I change the root directory of an apache server?

    - by Spencer Cooley
    Does anyone know how to change the document root of the Apache server? I basically want localhost to come from /users/spencer/projects directory instead of /var/www. Edit I ended up figuring it out. Some suggested I change the httpd.conf file, but I ended up finding a file in /etc/apache2/sites-available/default and changed the root directory from /var/www to /home/myusername/projects_folder and that worked.

    Read the article

  • C++ enum in foreach

    - by Spencer
    I've have a card class for a blackjack game with the following enums: enum Rank { Ace, Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten, Jack, Queen, King }; enum Suit { Clubs, Diamonds, Hearts, Spades }; When I create the deck I want to write the code like this: // foreach Suit in Card::Suit // foreach Rank in Card::Rank // add new card(rank, suit) to deck I believe there is no foreach in c++. However, how do I traverse an enum? Thanks, Spencer

    Read the article

  • C++ console output in Netbeans

    - by Spencer
    When I run a C++ program in Netbeans on a Mac that has cout or printf statements the output is displayed in a terminal opened using X11. Is there a console built into Netbeans? If yes, how do I change the output to it? Thanks, Spencer

    Read the article

  • C++ pass enum as parameter

    - by Spencer
    If I have a simple class like this one for a card: class Card { public: enum Suit { CLUBS, DIAMONDS, HEARTS, SPADES }; Card(Suit suit); }; and I then want to create an instance of a card in another file how do I pass the enum? #include "Card.h" using namespace std; int main () { Suit suit = Card.CLUBS; Card card(suit); return 0; } error: 'Suit' was not declared in this scope I know this works: #include "Card.h" using namespace std; int main () { Card card(Card.CLUBS); return 0; } but how do I create a variable of type Suit in another file? Thanks, Spencer

    Read the article

  • is_tarfile() returns True for a blank file

    - by Zachary Young
    Hello all, I am testing some logic to handle a user uploading a TAR file. When I feed a blank file to tarfile.is_tarfile() it returns True, which is not what I am expecting: $ touch tartest $ cat tartest $ python -c "import tarfile; print tarfile.is_tarfile('tartest')" True If I add some text to the file, it returns False, which I am expecting: $ echo "not a tar" > tartest $ python -c "import tarfile; print tarfile.is_tarfile('tartest')" False I could add a check at the beginning to check for a zero-length file, but based on the documentation for tarfile.is_tarfile(name) I think this is unecessary: Return True if name is a tar archive file, that the tarfile module can read. I went so far as to check the source, tarfile.py, and I can see that it is checking header blocks but I do not fully understand how it is evaluating those blocks. Am I misreading the documentation and therefore setting unfair expectations? Thank you, Zachary

    Read the article

  • Game Programming - GUIs

    - by Spencer
    I've been coding for a while now and would like to start looking into programming games. I know the industry's standard language is C++, for 3D graphics the main choice is between Direct 3D and OpenGL, but what is the most widely used GUI framework? I'm currently on a Mac so if native Windows API is the answer, then what is the cross platform choice? To be clear, I'm not looking for people's favourites but simply what the common or standard game industry's choice is so that I can learn and familiarize myself with it. Thanks, Spencer

    Read the article

  • How do you sort files numerically?

    - by Zachary Young
    Hello all, First off, I'm posting this because when I was looking for a solution to the problem below, I could not find one on stackoverflow. So, I'm hoping to add a little bit to the knowledge base here. I need to process some files in a directory and need the files to be sorted numerically. I found some examples on sorting--specifically with using the lamba pattern--at wiki.python.org, and I put this together: #!env/python import re tiffFiles = """ayurveda_1.tif ayurveda_11.tif ayurveda_13.tif ayurveda_2.tif ayurveda_20.tif ayurveda_22.tif""".split('\n') numPattern = re.compile('_(\d{1,2})\.', re.IGNORECASE) tiffFiles.sort(cmp, key=lambda tFile: int(numPattern.search(tFile).group(1))) print tiffFiles I'm still rather new to Python and would like to ask the community if there are any improvements that can be made to this: shortening the code up (removing lambda), performance, style/readability? Thank you, Zachary

    Read the article

  • XNA - Strange Texture Rendering Issue Using XNA BasicEffect

    - by Spencer Marr
    I have been reading and working through Riemers 3D XNA tutorials to expand my knowledge of XNA from 2D into 3D. Unfortunately I am having rendering issues that I am unable to solve and I need a point in the right direction. I am not expecting the Models to look identical to Blender but there is some serious discoloring from the texture files once rendering through XNA. The Character model is using completely incorrect colors (Red where Grey should be) and the Cube is rendering a strange pattern where a flat color should be drawn. My sampling mode is set to PointClamp. The Character model that I created has a 32 by 32 pixel texture that has been UV mapped to the model in blender. The model was then exported to .FBX. For the Cube Model a 64 by 64 pixel texture is used. foreach (ModelMesh mesh in samuraiModel.Meshes) { foreach (BasicEffect effect in mesh.Effects) { effect.Projection = Projection; effect.View = View; effect.World = World; } mesh.Draw(); } Does this look like it is caused by a mistake I made while UV Mapping or Creating Materials in Blender? Is this a problem with using the default XNA BasicEffect? Or something completely different that i have not considered? Thank You!

    Read the article

  • Eloqua API Full Code Example in JAVA

    - by Shawn Spencer
    Is there anyone out there who has mastered to retrieve some data programmatically from Eloqua? First of all, I'm more or less a newbie, as far as JAVA. I can follow tutorials, take directions and will Google till my fingers bleed. I understand the basics and am slightly familiar with OOP. My main problem is that I have a Friday deadline (and tomorrow is Thanksgiving). At any rate, all the Eloqua code snippets (that I've been able to find) illustrate one aspect of a specific issue, and that's it. In my case, I would greatly appreciate a JAVA project of some sort, with all the necessary files to do web services (WSDL, SOAP and perhaps WSIT) and the main class and all that included. No, I don't want you to do my work for me! Just give me enough to find my way around, enter the information I need to retrieve and all that. I'll take it from there. Any pointers, links or suggestions?

    Read the article

  • Can the csv format be defined by a regex?

    - by Spencer Rathbun
    A colleague and I have recently argued over whether a pure regex is capable of fully encapsulating the csv format, such that it is capable of parsing all files with any given escape char, quote char, and separator char. The regex need not be capable of changing these chars after creation, but it must not fail on any other edge case. I have argued that this is impossible for just a tokenizer. The only regex that might be able to do this is a very complex PCRE style that moves beyond just tokenizing. I am looking for something along the lines of: ... the csv format is a context free grammar and as such, it is impossible to parse with regex alone ... Or am I wrong? Is it possible to parse csv with just a POSIX regex? For example, if both the escape char and the quote char are ", then these two lines are valid csv: """this is a test.""","" "and he said,""What will be, will be."", to which I replied, ""Surely not!""","moving on to the next field here..."

    Read the article

  • How would you explain that software engineering is more specialized than other engineering fields?

    - by Spencer K
    I work with someone who insists that any good software engineer can develop in any software technology, and experience in a particular technology doesn't matter to building good software. His analogy was that you don't have to have knowledge of the product being built to know how to build an assembly line that manufactures said product. In a way it's a compliment to be viewed with an eye such that "if you're good, you're good at everything", but in a way it also trivializes the profession, as in "Codemonkey, go sling code". Without experience in certain software frameworks, you can get in trouble fast, and that's important. I tried explaining this, but he didn't buy it. Any different views or thoughts on this to help explain that my experience in one thing, doesn't translate to all things?

    Read the article

  • Are there any good html 5 mmo design tutorials?

    - by Dwight Spencer
    Hey all. I got a rather inspired after playing gaia online's zOMG and wanted to revive an old project idea I've had laying around for a few years now. I'm looking to work with html5 (ie canvas, svg based sprites, & WebGL) to build a graphical web based MUD/MMO. Obviously, this is a new take on an old idea and after searching google I haven't really turned up many good resources. But does anyone have any tutorials or other resources to point me in the right direction?

    Read the article

  • How much freedom should a programmer have in choosing a language and framework?

    - by Spencer
    I started working at a company that is primarily a C# oriented. We have a few people who like Java and JRuby, but a majority of programmers here like C#. I was hired because I have a lot of experience building web applications and because I lean towards newer technologies like JRuby on Rails or nodejs. I have recently started on a project building a web application with a focus on getting a lot of stuff done in a short amount of time. The software lead has dictated that I use mvc4 instead of rails. That might be OK, except I don't know mvc4, I don't know C# and I am the only one responsible for creating the web application server and front-end UI. Wouldn't it make sense to use a framework that I already know extremely well (Rails) instead of using mvc4? The two reasons behind the decision was that the tech lead doesn't know Jruby/rails and there would be no way to reuse the code. Counter arguments: He won't be contributing to the code and is frankly, not needed on this project. So, it doesn't really matter if he knows JRuby/rails or not. We actually can reuse the code since we have a lot of java apps that JRuby can pull code from and vice-versa. In fact, he has dedicated some resources to convert a Java library to C#, instead of just running the Java library on the JRuby on Rails app. All because he doesn't like Java or JRuby I have built many web applications, but using something unfamiliar is causing some spin-up and I am unable to build an awesome application in as short of a time that I'm used to. This would be fine, learning new technologies is important in this field. The problem is, for this project, we need to get a lot done in a short period of time. At what point should a developer be allowed to choose his tools? Is this dependent on the company? Does my company suck or is this considered normal? Do greener pastures exist? Am I looking at this the wrong way? Bonus: Should I just keep my head down and move along at a snails pace, or defy orders and go with what I know in order to make this project more successful? Edit: I had actually created a fully function rails application (on my own time) and showed it to the team and it did not seem to matter. I am currently porting it to mvc4 (slowly).

    Read the article

  • How would one go about integrated python into a c++ written game for the use of user-made scripts

    - by Spencer Killen
    I'm quite new to game development (not the site) and I'm currently just trying to educate myself about some certain things before I really begin working and a game. anyway, I'd like to know what basic algorithm/outline of how a game would be coded effeciently with the implementation of user coded scripts for gameplay and levels that are written in python, Is this even possible? would all the features of python be avalible? like say "multi-threading"?

    Read the article

  • Game engine IDE template [on hold]

    - by Spencer Killen
    Hey so I'm working on a fairly basic javascript game, and it's beginning to get to the point where my 'engine' to which I wrote, is difficult to manage in an all text environment, Iv already thought of using a javascript IDE like jet brains, but i was wondering if I could go 1 step further and have use a piece of software to purpose as an IDE and have a customizable GUI that I could use to automate class construction and such, for example, I have it set up right now so that everytime I want to create a new block (it's a platformer) I must copy a text file and fill in all the setting such as bounding box, sprite ect, it would be a lot easier if I could press a button and have a menu apear where I would fill in these values (I have a game maker background) is there software like this? If not what are some similar solutions to my problem?

    Read the article

  • Is it possible to efficiently store all possible phone numbers in memory?

    - by Spencer K
    Given the standard North American phone number format: (Area Code) Exchange - Subscriber, the set of possible numbers is about 6 billion. However, efficiently breaking down the nodes into the sections listed above would yield less than 12000 distinct nodes that can be arranged in groupings to get all the possible numbers. This seems like a problem already solved. Would it done via a graph or tree?

    Read the article

  • Ubuntu won't use my nvidia driver

    - by Spencer
    I'm running Ubuntu 12.10 on a laptop that has both Intel Integrated Graphics and an Nvidia Geforce 540m. I installed the drivers properly, but I can't manage to actually use them. I'm stuck in 640x480 resolution and the drivers aren't detected anywhere. Each time I open the Nvidia settings menu it says: "You do not appear to be using the NVIDIA X driver. Please edit your X configuration file (Just run 'nvidia-xconfig' as root), and restart the X server." ^Doing so does not help. Anybody have any ideas?

    Read the article

  • Are there any good html 5 mmo design tutorials? [on hold]

    - by Dwight Spencer
    Hey all. I got a rather inspired after playing gaia online's zOMG and wanted to revive an old project idea I've had laying around for a few years now. I'm looking to work with html5 (ie canvas, svg based sprites, & WebGL) to build a graphical web based MUD/MMO. Obviously, this is a new take on an old idea and after searching google I haven't really turned up many good resources. But does anyone have any tutorials or other resources to point me in the right direction?

    Read the article

  • JQuery Autocomplete Where the Results are Links

    - by Spencer
    I am trying to create a JQuery Autocomplete box where the words being suggested for autcomplete are links (similar to what happens on Facebook or Quora). Basically, I want the autocomplete results to drop down and I want people to be able to click on them and be navigated to a different page. Here is the code I am currently using <!DOCTYPE html> <html> <head> <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script> <script> $(document).ready(function() { $("input#autocomplete").autocomplete({ source: ["Spencer Kline", "Test Test Test Test Test Test Test Test Test", "php", "coldfusion", "javascript", "asp", "ruby"] }); }); </script> </head> <body style="font-size:62.5%;"> <input id="autocomplete" /> </body> </html>

    Read the article

  • Xml Serialization and the [Obsolete] Attribute

    - by PSteele
    I learned something new today: Starting with .NET 3.5, the XmlSerializer no longer serializes properties that are marked with the Obsolete attribute.  I can’t say that I really agree with this.  Marking something Obsolete is supposed to be something for a developer to deal with in source code.  Once an object is serialized to XML, it becomes data.  I think using the Obsolete attribute as both a compiler flag as well as controlling XML serialization is a bad idea. In this post, I’ll show you how I ran into this and how I got around it. The Setup Let’s start with some make-believe code to demonstrate the issue.  We have a simple data class for storing some information.  We use XML serialization to read and write the data: public class MyData { public int Age { get; set; } public string FirstName { get; set; } public string LastName { get; set; } public List<String> Hobbies { get; set; }   public MyData() { this.Hobbies = new List<string>(); } } Now a few simple lines of code to serialize it to XML: static void Main(string[] args) { var data = new MyData {    FirstName = "Zachary", LastName = "Smith", Age = 50, Hobbies = {"Mischief", "Sabotage"}, }; var serializer = new XmlSerializer(typeof (MyData)); serializer.Serialize(Console.Out, data); Console.ReadKey(); } And this is what we see on the console: <?xml version="1.0" encoding="IBM437"?> <MyData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Age>50</Age> <FirstName>Zachary</FirstName> <LastName>Smith</LastName> <Hobbies> <string>Mischief</string> <string>Sabotage</string> </Hobbies> </MyData>   The Change So we decided to track the hobbies as a list of strings.  As always, things change and we have more information we need to store per-hobby.  We create a custom “Hobby” object, add a List<Hobby> to our MyData class and we obsolete the old “Hobbies” list to let developers know they shouldn’t use it going forward: public class Hobby { public string Name { get; set; } public int Frequency { get; set; } public int TimesCaught { get; set; }   public override string ToString() { return this.Name; } } public class MyData { public int Age { get; set; } public string FirstName { get; set; } public string LastName { get; set; } [Obsolete("Use HobbyData collection instead.")] public List<String> Hobbies { get; set; } public List<Hobby> HobbyData { get; set; }   public MyData() { this.Hobbies = new List<string>(); this.HobbyData = new List<Hobby>(); } } Here’s the kicker: This serialization is done in another application.  The consumers of the XML will be older clients (clients that expect only a “Hobbies” collection) as well as newer clients (that support the new “HobbyData” collection).  This really shouldn’t be a problem – the obsolete attribute is metadata for .NET compilers.  Unfortunately, the XmlSerializer also looks at the compiler attribute to determine what items to serialize/deserialize.  Here’s an example of our problem: static void Main(string[] args) { var xml = @"<?xml version=""1.0"" encoding=""IBM437""?> <MyData xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema""> <Age>50</Age> <FirstName>Zachary</FirstName> <LastName>Smith</LastName> <Hobbies> <string>Mischief</string> <string>Sabotage</string> </Hobbies> </MyData>"; var serializer = new XmlSerializer(typeof(MyData)); var stream = new StringReader(xml); var data = (MyData) serializer.Deserialize(stream);   if( data.Hobbies.Count != 2) { throw new ApplicationException("Hobbies did not deserialize properly"); } } If you run the code above, you’ll hit the exception.  Even though the XML contains a “<Hobbies>” node, the obsolete attribute prevents the node from being processed.  This will break old clients that use the new library, but don’t yet access the HobbyData collection. The Fix This fix (in this case), isn’t too painful.  The XmlSerializer exposes events for times when it runs into items (Elements, Attributes, Nodes, etc…) it doesn’t know what to do with.  We can hook in to those events and check and see if we’re getting something that we want to support (like our “Hobbies” node). Here’s a way to read in the old XML data with full support of the new data structure (and keeping the Hobbies collection marked as obsolete): static void Main(string[] args) { var xml = @"<?xml version=""1.0"" encoding=""IBM437""?> <MyData xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema""> <Age>50</Age> <FirstName>Zachary</FirstName> <LastName>Smith</LastName> <Hobbies> <string>Mischief</string> <string>Sabotage</string> </Hobbies> </MyData>"; var serializer = new XmlSerializer(typeof(MyData)); serializer.UnknownElement += serializer_UnknownElement; var stream = new StringReader(xml); var data = (MyData)serializer.Deserialize(stream);   if (data.Hobbies.Count != 2) { throw new ApplicationException("Hobbies did not deserialize properly"); } }   static void serializer_UnknownElement(object sender, XmlElementEventArgs e) { if( e.Element.Name != "Hobbies") { return; }   var target = (MyData) e.ObjectBeingDeserialized; foreach(XmlElement hobby in e.Element.ChildNodes) { target.Hobbies.Add(hobby.InnerText); target.HobbyData.Add(new Hobby{Name = hobby.InnerText}); } } As you can see, we hook in to the “UnknownElement” event.  Once we determine it’s our “Hobbies” node, we deserialize it ourselves – as well as populating the new HobbyData collection.  In this case, we have a fairly simple solution to a small change in XML layout.  If you make more extensive changes, it would probably be easier to do some custom serialization to support older data. A sample project with all of this code is available from my repository on bitbucket. Technorati Tags: XmlSerializer,Obsolete,.NET

    Read the article

  • Haskell vs Erlang for web services

    - by Zachary K
    I am looking to start an experimental project using a functional language and am trying to decide beween Erlang and Haskell, and both have some points that I really like. I like Haskell's strong type system and purity. I have a feeling it will make it easier to write really reliable code. And I think that the power of haskell will make some of what I want to do much easier. On the minus side I get the feeling that some of the Frameworks for doing web stuff on Haskell such as Yesod are not as advanced as their Erlang counter parts. I rather like the Erlang approach to threads and to fault tollerence. I have a feeling that the scalability of Erlang could be a major plus. Which leeds to to my question, what has people's exerience been in implementing web application backends in both Haskell and Erlang. Are there packages for Haskell to provide some of the lightweight threads and actors that one has in Erlang?

    Read the article

  • Change CSS EMs to Percentage Automatically.

    - by Zachary Brown
    I cheated on a small site I was working on and used a site builder (Web Dwarf by Virtual Mechanics) to save time. I didn't realize it at the time, but this builder specifies the width, height and positions using CSS EMs. Is there an automated tool out there that will read through the CSS and convert each EM to a percentage so it will display correctly on wide screens as well? Any help would be great! Thanks. Here is the CSS: http://pastebin.de/14055

    Read the article

1 2 3 4 5 6 7 8  | Next Page >