• Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in 0 not equal to 0.0000 problem

    I'm not c++ buff, but it looks to me like you have set the precision for printing numbers, but that has no effect on the numbers themselves. fx could still …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in toString() and getter returning an object

    Are you sure that's generally true? For example StringBuilder append will call toString implicitly, but I don't think format will.
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in toString() and getter returning an object

    Yes, that's possible, but it's a really bad idea. For a start you are replacing one simple short safe piece of code with two lines of detailed fragile code. Duh! …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in toString() and getter returning an object

    Yes, toString is called when you print or println. If you override the 'garbage' Object toString then you have to return a String. How you construct that String is entirely …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in toString() and getter returning an object

    Every class in Java has a toString method. It's defined in the Object class so everyone inherits it if they don't override it. It returns the name of the class …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Java, Constructor that MUST EXPLICITLY call super

    Make the superclass default constructor private and provide a public constructor that takes a parameter ?
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Playlist java

    I looked at your code on GitHub. Seems pretty complete. Nothing nasty sprang to my notice. What exactly is your question?
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Clarification with the MVC model

    That's not exactly what I would think of as MVC either. But it does look like good architecture, regardless of what you call it.
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Min-Heap Sort Assistance

    Looking at the print method, where the error is generated, I see 2*i+1 etc in a loop where I goes up to the list size, so the out of bounds …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Assist with displaying Non-Duplicate Words

    replaceAll does not modify the current string, it returns a new string, which you have ignored. Your regex seems too complicated. After the replacement you just need to split on …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Printing out words that cross at a common letter

    This appears to be a continuation of Katie's previous thread that was missing the `Java` tag https://www.daniweb.com/programming/computer-science/threads/500517/crossing-english-words-in-java the new `crossesAt` method just duplicates the single line at 19 for some …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Crossing English Words- in java

    Break it down into easier pieces... suppose you have successfully worked out a place where the two words cross - say `pos1` and `pos2` for example. Now you have a …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in What skills do you need to become a good web developer?

    >"There is only one skill needed: code" ... if you just want to be a coder, blindly programming whatever someone else tells you to code, doing the most hours of …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Crossing English Words- in java

    Tag this with `Java` so it shows up in the best place to get an answer. That looks like a decent piece of code - what do you want it …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in how to spot logic errors

    2: Trace the execution one step at a time, using a debugger or lots of print statements until you find where its going wrong (sounds like there are logical expressions …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Loop with ads

    Are you saying that you want the database retrieval to be three records at a time, rather than getting them all them you processing them 3 at a a time? …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in I need help with Java

    You probably want to print the average, and amy other results you calculate. You can put all that inside a `while` loop so it will keep repeating the input and …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in how to spot logic errors

    1: You get an exception (null pointer, zero divide etc) or the program behaves in a way didnlt expect (wrong output etc) 2: Trace the execution one step at a …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Connect jbutton to jtextfield

    Yes. Have a look at javax.swing.Timer (see the API doc in the usual place) - you can set a 10 sec timer and start it counting down when the user …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Add Image to an existing JButton

    Hello Rohini, welcome to DaniWeb Your contributions are welcome, but please take time to read the whole of a thread before posting. Firstly, this thread is 3 years old, so …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Connect jbutton to jtextfield

    Just use ` setEnabled(true); ` or `setEnabled(false);` for your buttons in the appropriate listeners
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Java application Setup

    If you get that information from the user then you have to store that in a configuration file (or equivalent) somewhere so you can find it next time the program …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in What skills do you need to become a good web developer?

    Most bad web sites are not bad because of some technical failure, they are bad because they don't do what the user wants or expects. Learning PHP or whatever is …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in game problem (netbeans java)

    I noticed lines 487/488 yourMoney=Integer.parseInt(jTextField1.getText()); yourMoney=hold; // overwrites the value you just set in the previous line
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Assist with displaying Non-Duplicate Words

    How about replacing all those difficult characters with blanks befor splitting the sentence?
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in NullPointerException when reading and writing to txt file

    Two things stand out... you write the data with a newline before each field and a tab after each. Presumably that should have been a newline only between complete rows? …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in NullPointerException when reading and writing to txt file

    What *exactly* did you change to fix it. What *exactly* is the error remaining in load?
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in NullPointerException when reading and writing to txt file

    The common factor on those two lines is the `contacts` variable You declare it on line 23, but you never initailse it, so it's null. And before you refer me …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in NEED HELP SOLVING THIS QUESTION

    Come on guys! This is obviously a teaching exercise in a Java course, so comments about using spreadsheets or off the shelf applications are hardly relevant.
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in How to I make this application write and display txt file into JTable

    You have written the array of data to a text file, so loading it is a question of Reading each line from the text file (see any tutorial for reading …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in NEED HELP SOLVING THIS QUESTION

    OK You can use a Scanner to read the data from the user, then store it into an array or arrays. You can use loops to go through all the …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in NEED HELP SOLVING THIS QUESTION

    You just copy/pasted your assignment without even a moment taken to explain what help you need. That's highly disrepestectful to the many people who give their time to help others …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in JPanel repaints when Key is Pressed, but not when I call it directly?

    Me too...
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in JPanel repaints when Key is Pressed, but not when I call it directly?

    I can't think of any reason why the key listener should interfere with screen painting.
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in JPanel repaints when Key is Pressed, but not when I call it directly?

    What makes this all the more annoying is that your code is so beautifully written and presented. Anything that professional really should work!
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in JPanel repaints when Key is Pressed, but not when I call it directly?

    Just another long-shot guess... Try setting the size of the SketchPanel in its constructor - JPanels tend to be 0,0 size until you put something in them or use a …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in game help

    Starting at the beginning... line 2 starts a loop using the value of various count variables, but these are never changed in the loop. So either it will execute zero …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in JPanel repaints when Key is Pressed, but not when I call it directly?

    No, sorry, can't see any problems their either. This is baffling! ps: I see you are defining local constrants to save typing `KeyEvent.` All the time Do you know about …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in JPanel repaints when Key is Pressed, but not when I call it directly?

    Can't see anything wrong there. Maybe worth a look a the whole SketchPanel class?
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in JPanel repaints when Key is Pressed, but not when I call it directly?

    I tried to reproduce your problem I edited your code into a little class class MP extends JPanel { { setSize(400, 400); } boolean redrawRequested = true; Color ETCH_BACKGROUND_COLOR = …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in JPanel repaints when Key is Pressed, but not when I call it directly?

    That's bizarre! Any possibility that ETCH_BACKGROUND_COLOR could be ARGB with an alpha of 0?
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in JPanel repaints when Key is Pressed, but not when I call it directly?

    OK. Excellent! So we would expect to see (some of?) a 1200x800 rectangle coloured in some kind of yucky pale grey/green. What do you actually see?
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in JPanel repaints when Key is Pressed, but not when I call it directly?

    Have you checked owner.getAppWidth/Height? Maybe those values have not yet been initialised when the panel is painted for the very first time?
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in java

    Hi Muwanguzi Lynda There are lots of people here who will freely give their time to help you become the best Java programmer you can be. There's nobody here who …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in pseudo code

    It's often a much higher level description of a process or algorithm, eg rubberman's example could be Do <stuff> for each whole number between 1 and 10 In general you …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Could you share your knowledge about life?

    So much in life depends on luck, but you can make yourself sa lucky person by: 1. Giving yourself chances to be lucky - eg it's wondeful luck to meet …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Java- Hollow Asterisk Squares

    You have 3 while loops using columncounter, and in each case you forgot to initialise/reinitialise columncounter before entering the loop(s).
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Java-Factors program

    the problem is with the variable you call "total". Your loop sets total to 15/15 then 15/14, then 5/13 etc - which in integer arithmetic keeps giving you 1's I …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in socket programming

    So this is just another way to continue your previous topic? SInce you ignored the advice in that one, and continued to ask pointless questions without enough information, I don't …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in socket programming

    "you can't." Never say never... Socket synchSocket = new Socket(); synchronized (synchSocket) { // etc } Although I'm pretty sure that's not what he means :)

The End.