User Profile

Collapse

Profile Sidebar

Collapse
mrjohn
mrjohn
Last Activity: Nov 24 '10, 08:47 PM
Joined: May 13 '09
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • mrjohn
    replied to Can I have two .h files that #include each other?
    in C
    That worked like a charm. Thanks.
    See more | Go to post

    Leave a comment:


  • mrjohn
    started a topic Can I have two .h files that #include each other?
    in C

    Can I have two .h files that #include each other?

    I've got two classes, and each one has a pointer to another. However, I'm having trouble with one of them. Actor.h is acting like the other class doesn't exist.

    [code="C++"]//---------------------------------------------------------------------------
    // A map tile
    //---------------------------------------------------------------------------
    #ifndef TILE_H
    #define TILE_H

    #include...
    See more | Go to post

  • mrjohn
    replied to Please help me fix this code
    in Java
    So what's the problem with it?
    See more | Go to post

    Leave a comment:


  • It does look like looking for cells "off the edge" is what is causing the null pointer exception. I do have one question though. Is context supposed to be context[x][y] or context[y][x]? Because you seem to use context[myX][myY] as well as context[myY][myX]. I recommend making your code use just the Cartesian X/Y version, as it makes the grid more intuitive.

    As far as going "around the world" goes, consider the fact...
    See more | Go to post

    Leave a comment:


  • That's a little hard for me to tell without the context, but it sounds like encapsulation to me, as abstract methods have no data to hide.
    See more | Go to post

    Leave a comment:


  • mrjohn
    replied to program does not display output
    in Java
    Two bugs.

    On line 15 (Your if-statement where you check to see if characters are the same), you have A.charAt(A.leng th())-i-1). You need to move the -i-1 part into the charAt() method, or you'll have a null pointer exception. So it'd be A.charAt(A.leng th()-i-1)).

    The other bug is that you've got your if statement that determines which output to print inside your for-loop. Since your loop exits if it finds a mismatch, it'll...
    See more | Go to post

    Leave a comment:


  • mrjohn
    replied to Image placement on myspace
    Odd... I tried it on Blogger and it worked. Perhaps it is just MySpace.
    See more | Go to post

    Leave a comment:


  • mrjohn
    replied to Image placement on myspace
    It has been a little while, but I think this might do it...
    <img src="whateveh" alt="whateveh" style="float: right;" />
    See more | Go to post

    Leave a comment:


  • mrjohn
    replied to Memory concerned citizen
    in Java
    If obj is inside a method, won't it be set to null at the method's conclusion anyways? Then the garbage collector will get it.
    See more | Go to post

    Leave a comment:


  • mrjohn
    replied to Form Field Problem
    Perhaps you could post the code for us?
    See more | Go to post

    Leave a comment:


  • mrjohn
    started a topic How does one break into Java programming?

    How does one break into Java programming?

    Hey, I've been working with Java a bit, and I think I'm getting the basics, but I want to be able to use it effectively as a job. Are there any specific things that every Java programmer should know? Are there any specific things that really help? Or any technologies that complement Java?

    I've wanted to "break into the business," but I'm a bit overwhelmed. I've looked at freelancing sites such as oDesk, but for every job...
    See more | Go to post

  • I use Eclipse, myself. It's both free and very helpful. It doesn't have the drag 'n drop GUI making capabilities (Like the Microsoft Visual XXXX series), so you have to write them manually, but it is still a quite excellent program.
    See more | Go to post

    Leave a comment:


  • mrjohn
    replied to java or .net
    in Java
    While I'm a bit of a newbie, as I best understand it C# is kinda like Microsoft's version of Java. They're very similar. You could go with C# for now and then do Java later. The change wouldn't be that difficult.
    See more | Go to post

    Leave a comment:


  • As a disclaimer, I don't use netbeans. However, can't you just create some getter methods for your arrays in the class that they're in? Then you can use those setters to get the data from any class in the same directory.

    i.e.
    [code="java"]public int[] getMyData()
    {
    return arrayNameHere;
    }
    //Or for a single value
    public int getMyData(int index)
    {
    if(index >= 0 &&...
    See more | Go to post

    Leave a comment:


  • mrjohn
    replied to Problem painting an image
    in Java
    Thanks. I think that Eclipse was unable to see it.
    See more | Go to post

    Leave a comment:


  • mrjohn
    replied to ArrayList issue
    in Java
    I took a quick look at it with the debugger, and it looks as though you don't ever assign a value to status in BankAccount.jav a. I think this may be the problem.
    [code="java] private String setStatus(Strin g newStatus){
    if (status.equals( OPEN))
    {
    this.status = OPEN;
    }
    if (status.equals( SUSPENDED))
    {
    this.status = SUSPENDED;...
    See more | Go to post

    Leave a comment:


  • Ah... well, after some monkeying around and looking at examples on the web, I found the solution. I'm sorry, I probably should have posted it on this thread when I found it.

    To fix it, all I had to do was replace line #52 with something like the following code:
    [CODE="java"]
    lab l = new lab();
    frame.addKeyLis tener(l);
    frame.add(l);[/CODE]
    See more | Go to post

    Leave a comment:


  • mrjohn
    started a topic Trouble getting Keyboard input with KeyListener
    in Java

    Trouble getting Keyboard input with KeyListener

    Hey, I'm trying to make a program that will recognize when certain keys are released, so that I can encorperate it into a game I'm making. Unfortunately, it doesn't seem to be working. When I run the program and press keys, nothing happens. Any ideas?

    [code="java"]import java.awt.Dimens ion;
    import java.awt.Graphi cs;
    import java.awt.Graphi cs2D;
    import java.awt.Image;
    import java.awt.event. KeyEvent;...
    See more | Go to post

  • mrjohn
    replied to Applet Problam
    in Java
    I'm no expert with applets 'n ActionListeners , but I think you need to change
    [code="java]public class test1 extends Applet[/code]
    to
    [code="java]public class test1 extends Applet implements ActionListener[/code]

    Kinda hard to say more until you explain what your applet is supposed to do.
    See more | Go to post

    Leave a comment:


  • mrjohn
    started a topic Problem painting an image
    in Java

    Problem painting an image

    Hey, I've got some code that is supposed to paint part of an image on a JPanel. Unfortunately, when I run it, I get a nullPointer Exception.

    [code="java"]public void paintMap()
    {
    Graphics g = this.getGraphic s(); //Create a new Graphics object.
    Graphics2D g2d = (Graphics2D) g; //Cast it to a Graphics2D object (Has more options)
    Image spaceImages = Toolkit.getDefa ultToolkit().ge tImage ( "stars.png"...
    See more | Go to post
No activity results to display
Show More
Working...