• Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in AI - predicting new location of moving object

    If you want a predicted position for moving things then you must have some kind of clock, because the predicted position will change over time. If the velocity of the …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in AI - predicting new location of moving object

    Assuming the velocity doesn't change, the position after time t is just current position + velocity * t You don't need speed as well because velocity, by definition, includes speed …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Application won't print the required instructions requested in the program!

    It seems unlikely that literally "nothing happened" when you changed the contents of a JLabel in your window... You are going to have to be clearer in your explanations - …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Application won't print the required instructions requested in the program!

    Did you try to replace the code at line 55 instructionLabel = new JLabel ( "*** Welcome to Simpletron! ***" + "\n*** Please enter your program one instruction ***" + …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in random numbers and recurring loop

    "does anyone know of a loop that could be repeated so that the players can enter the correct age. I need to created a loop so that when, let say …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in How to pass a string from client to server

    You cannot mix Data streams and Readers/Writers - they use completely different data formats. Data sttreams send (binary) data, readers/writers send text. Either use a DataOutputStream to send data to …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in void is an invalid type for the variable actionperformed

    You are trying to define a method withiout finishing the previous method defintion. You canno define one method inside another method like that.
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Give me some simple ideas for projects to work on

    There's a topic for project ideas in the Java section - but the language is irrelevant https://www.daniweb.com/software-development/java/threads/430542/java-projects-for-learners
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Application won't print the required instructions requested in the program!

    Add that JLabel to your existing window Or use that HTML in instructionLabel (line 55)
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Application won't print the required instructions requested in the program!

    JLabel does not display multi-line simple text. You could use a JTextArea or somesuch, or you can use simple HTML formatting to display multi-line text in a JLabel
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Interface VS Abstract

    If this seems a bit vague and ambiguous, then that's because it is. The technical differences between abstract and interface have been blurred even more in Java 8. The best …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Doubt on Inheritance.

    Yes
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Exception in thread "main" java.lang.NumberFormatException: null

    Looking at the next line in the stack dump, the parseInt was called from line 111, so it is the "Year" tag that has a null value
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Doubt on Inheritance.

    aTask is defined as being of type Task, so you can use it to refer to any methods defined in the Task class. If, and any particular time, it happens …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Interface VS Abstract

    No. If you have any abstract methods then the class MUST be abstract. There's no need for subclasses to use any of the parent's methods if they don't want to. …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Reading/Writing Arraylist from file

    Why re-invent the wheel? Why not use ObjectOutputStream and ObjectInputStream to write your meeting data as Java objects and read them in the same way? If there's a top-level object …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Server sends, client receives but doesn't send back

    Sending a packet should not take more than a millisecond or two, so there's no problem doing that on the EDT. Even if that was a problem you could just …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Interface VS Abstract

    stultuske: yes - you are right. The JLS says "A class type should be declared abstract only if the intent is that subclasses can be created to complete the implementation...", …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Server sends, client receives but doesn't send back

    Why do you have that test? Why not just listen for packets and process them whenever they arrive?
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Server sends, client receives but doesn't send back

    No, the problem is here: void whileChatting() { // do { if (this.packet == null || !this.send) { // null means receive first packet this.packet = receivePacket(); } if (this.send) …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Doubt on Inheritance.

    Back up one step... You declare a reference variable of type Task. That variable can refer to any instance of Task, or any instance of any subclass of Task. (Because …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Interface VS Abstract

    An abstract class is a class with one or more methods declared abstract (ie the signature is declared, but there is no implementation. Becuase one or more methods are not …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Drawing using Graphics2D

    Just for a laugh I hacked this little program to help get the quad curves. Open the bitmap. Click 3 times to define a new curve (start/control/end points). Drag points …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Calendar with insertig events

    Create the Event class first. The create a List<Event>. It doesn't matter what kind of List it is (ArrayList, LinkedList, Vector etc).
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Doubt on Inheritance.

    You can now use aTask to do anything that's valid for a Task. Later you coiuld change the PracticeTest ofr a FinalTest or any other subclass of Task without breaking …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Calendar with insertig events

    If you need to add events, then the obvious way to start is to create an Event class. It would have start date/time, and date/time, title, location etc as instance …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in How to split up Korean characters into components

    The Character class has a load of methods for dealing with complicated UniCode characters - maybe that's what you need?
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Counting letters in a user inputted string

    You can use String's `charAt` method to get individual chars. Wrap that in a simple loop to get all the chars one at a time.
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Counting letters in a user inputted string

    It's just like counting words, except simpler. Instead of splitting the String into words, you just take each char from the String and count those.
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Drawing using Graphics2D

    I think you will have to create a Shape using multiple arcs, quad curves, maybe even cubic curves. Although cubic curves have the potential to construct this with fewer segments, …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in will someone help me real badly

    To get random integers you need to create a single instance of Random, then call its `nextInt` method for each new random int value you need. Here's the general form …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Server sends, client receives but doesn't send back

    That toggled loop looks to me like you are trying to go "procedural" where you should be event driven. Normally in both client and server you would have a loop …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Java and Paint

    Yes, absolutely. Use the `ProcessBuilder` class - Google for API details and tutorials
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Running a multithreaded server (or at least trying)

    startRunning creates an infinite nuber of concurrent server threads, each of which tries to open the same server socket. That's the wrong threading strategy. To make things worse, you have …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in will someone help me real badly

    Sorry, but that code is completely unreadable. Can you try to split it down into some sensible methods... try to divide it so that no if/else block or loop spans …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in trying to debug a drawing panel w/Buffered Image

    :) ps: Never NEVER *NEVER* do this when writing new code: } catch (Exception e) { } If/when there is an error you just told Java that you didn't want …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in trying to debug a drawing panel w/Buffered Image

    Well yes, but since you never use `g2` you may as well delete that whole line. All it's doing is confusing anyone who reads it.
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in trying to debug a drawing panel w/Buffered Image

    public void paintComponent(Graphics g) { super.paintComponent(g); g = graphic.getGraphics(); g.drawImage(graphic,0,0,null); } You re-use the `g` variable on the third line here, thus losing your reference to the component's Graphics, so …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Adding a window to a Container Error

    I guess your ChartFrame is a kind of JFrame - ie a top-level container or window, so you cannot place that inside a lower-level container like JPanel. If you are …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in 'The registry refers to a nonexistent Java Runtime Environment installation

    What is the .exe file? Simply re-installing the latest version usually fixes any out-of-date or incorrect registry settings. Java 1.6 is years out of date, no longer supported, and riddled …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Remove all occurrences of a string with gui

    You get the input from the user, but you parse it as an int. Why is that? You have code (lines 14 - 46) that remove a given string from …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Java Program crashes at around 30min. libosxapp.dylib plugin crash

    If you can cut it down to a self-running stand-alone version I can run it on my Mac and see if it has the same problem. That will help determine …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in We are Java beginner .. Please help us

    No. That would have thrown an `InputMismatchException`. His output is just the result of calling toString on a Scanner object when trying to print it.
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Java Programming for a Grocery store

    DaniWeb Member Rules (which you agreed to when you signed up) include: "Do provide evidence of having done some work yourself if posting questions from school or work assignments" http://www.daniweb.com/community/rules …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Random Array of objects

    No need for the Strings or the switch, classes are Classes in their own right! Class[] carTypes = {Van.class, Cab.class ... }; for ( int i = 0; i < …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in We are Java beginner .. Please help us

    Line 13 you print the Scanner object `a` The output you see is the description of your scanner object. I guess you wanted to print the user's input, `kakdo`?
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Having a problem with this class assignment

    What about zeros? Zero isn't positive or negative?
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Looking for a good tutorial for creating chat messenger in Java

    In any case I do wish you the best of fortune. It's always the ordinary people who suffer when politicians play their games. May your luck be better in future. …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Command key, Java Robot Meta

    Sorry man, the first version looks right to me. Maybe it's OK but there's some other problem that makes it look like its not working? If you post a runnable …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Active Tile not moving even though I am changing it's position

    I'm not sure I can be a lot clearer than my previous post without writinga lot of sample code - and frankly I don't have that much time. The key …

The End.