• Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in h writing a program in which after button click writing start on the anothe

    The 4 numbers are your xPressed, yPressed, xReleased, yReleased. They are all you need to draw the same line(s) in another window. You have a server program running or yur …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Java Generics, Sort ArrayList in ascending order

    If you want to set the ith element of a List to some value, the correct method call is like this: myList.set(i, someValue);
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in object-oriented design project

    So, you have published you teacher's original (copyrighted?) assignment here. And what did you expect to achieve by that?
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Java Generics, Sort ArrayList in ascending order

    24: compareTo returns an int -1, 0, or +1, but not a boolean 31/32: you can't have method calls like that on the LHS of an assignment. You probably want …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in h writing a program in which after button click writing start on the anothe

    Yes. All the stuff I suggested before is about drawing on another window applies perfectly in that case. First, get it working with two windows in the same program, using …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in h writing a program in which after button click writing start on the anothe

    Earlier you said "it did catch the mouseevents ... it doesn't draw anything on the other window" - which is the problem I was addressing. But now it seems you …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Gave Reputation to David W in Negatif An Positif C++ (Help)

    A next step might be to use functions to get valid input in a loop? Also maybe use a struct tp hold the 'counts'? Take a look: // countPosNeg.cpp // …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in How to get value from database and setColor to many JButton

    That logic looks suspicious! Maybe something like this (in pseudocode) would work better for each row in the result set { use the noRoom to find the corresponding button if …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Star patterns printing

    Sorry necrovore, that would add an asterisk to every line. Between lines 19 and 20 would be better. The problem is that on the last line the loop lines 6-9 …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in h writing a program in which after button click writing start on the anothe

    `repaint()` tells Swing that you want to update your window. Swing adds that request to it's queue of work and when it gets to the top of the queue it …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Negatif An Positif C++ (Help)

    or you could simply use a loop (in pseudo-code): int posCount=0, negCount=0 while (more input to process) input next number if (next number > 0) posCOunt++ else negCount++ print counts
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in How to be ?

    1. Decide which platform you are going to major in. It's not hard to learn a new language; algorithms and techniques are mostly portable; but to be good at games …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Need help map in java

    Start by reading the instructions... "store the values in Card object with the attributes symbol and number." ... but also, when you need to add a new key/value pair you …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in h writing a program in which after button click writing start on the anothe

    its something along the lines of private int startX, startY, etc public void updateDrawing(int newStartX, int newStartY ... etc) { startX = newStartX; etc repaint(); } then you can call …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in h writing a program in which after button click writing start on the anothe

    WHich part did you not understand? I'm not going to give you the code, but I will try to explain what code *you* need to write.
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in h writing a program in which after button click writing start on the anothe

    OK! You didn't explain that. So the listeners have to be added to the window where you are clicking/dragging the mouse. What you ned to do is then to pass …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in h writing a program in which after button click writing start on the anothe

    I have not tried your code, but it looks OK. The way you add the mouse listeners in `new2` looks perfectly normal. Why do you think you are doing something …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Marked Solved Status for h writing a program in which after button click writing start on the anothe

    hello i m writing a program in which i try to write on the frame by mousemotionlistener and mouselistener methods till now i did the writing part and i i …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in h writing a program in which after button click writing start on the anothe

    LInes 46,47 The only place you can draw to the Graphics is inside the `paint` method (or `paintComponent`, which would be better). Swing is double-buffered and anything you draw in …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Evendispatched exception-unknown source

    The "unknown source" is just referring to the internals of the Java API classes (for which the source code is not on your computer). The first lines of the message …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Hash Map : Question about duplicate keys

    Your understanding is wrong in that the key/value pair is not replaced, just the value. The API doc says "If the map previously contained a mapping for the key, the …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in question

    static = one value, shared for all instances of the class non-static = every instance has its own values
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in check if a number is between two values

    That cast converts a char numeric value to an int by padding it arithmetically. What you seem to want is to parse a character value in the range '0' - …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in BASIC C

    hazelkahn So we don't delete all your posts as junk, can you please explain what you are trying to do. Do you want solutions to these exercises? Are you proposing …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in incremental game

    Yes, some people here do have such source code. If you give us your teacher's email them we could email it directly to him/her and save you the effort of …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in cant find symbol - method string

    Same problem as in your previous post: "sum" is not a Java type, nor a class. Line 8 also has invalid syntax for calling a method
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in password masking

    You have to use the `Console` class and its `readPassword` methods. In that case it's probably easier to drop the BufferedReader and just use Console's `readLine`. Docs are in the …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in hi

    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 Java Generics-Find Max Element in Array

    Maybe a better option, but for a new learner I would always advise sticking to the standard API if possible - 3rd party libraries do add an extra level of …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Need help with BlueJ school project (audioplayer))

    A couple of hints to get you started: You changed the signature of the method by adding a parameter. That's not what is required. You declared a variable for the …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Java Generics-Find Max Element in Array

    The > operator only works for numeric primitives. Depending on the type of the generic arguent that could mean Circle1 > Circle2 (etc) Because all your generics implement Comparable. you …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Getting the minimum value of a column in a 2d array

    You didn't say what your question was, but... decide whether you are using i,j or row,col - don't mix them Don't forget to print the answers
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in illeagal start of exprssion

    lines 3,4 you have two {
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in A little error needed help!!

    rch1231 Yes, that's a solution, but I hoped the OP would get the benefit of working out the solution for himself! ddanbe it will work (compile and execute without errors), …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Counter arrays

    Sorting the array is massive overkill for just finding the largest entry, and permanently changes the array, which may also be undesirable. stultuske's "try this logic instead" approach is by …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in A little error needed help!!

    ( 9 / 5 ) 9 and 5 are both ints, so the division is done in integer arithmetic, giving the result 1
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Sudokou game Backtracking implementation

    "someone give me a code" ? ! This is not a site for the lazy, the cheat, or the selfish entitled. This is a site for people who want to …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Gave Reputation to Ahmed_62 in Sudokou game Backtracking implementation

    plz someone give me a code of sudokou solver using backtracking algorithm as console app
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in QUICK HELP: minor error in code

    Even better, do that and also make sure your names accurately reflect their use. If I see a method `void setColor(String colors)` then I would expect to be able to …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Gave Reputation to Stefce in reading form file

    Just and example public Account(String username) throws FileNotFoundException, IOException { this.username = username; File folder = new File("C:\\"+username); File file = new File(folder, username + ".txt"); FileReader freader = new …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Gave Reputation to Stefce in How to keep a randomized string from repeating

    Im using this on my game quiz.. hope it will help you too: String[] questions = { "What year is launched Facebook ?", // 0 "What year is born Michael …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in reading form file

    After you read the first int, the next call will read the second number int num1 = f.nextInt(); // reads 1nd num int num2 = f.nextInt(); // reads 2nd num …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Xuggler Audio Recorder not working, and video longer than it should be

    Re video: just what I suspected. You may find that threading the screen shot and the writing may buy you a little improvement - it's not hard, so give it …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Xuggler Audio Recorder not working, and video longer than it should be

    Maybe: You have video code like loop do CPU intensive stuff wait 20 mSec that's only going to loop 50 times per second if the CPU stuff is instantaneous (which …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in need random numbers for a multiplication game

    ? That reads the wrong way round... If you do not set a seed then the Random() constructor picks one - eg current time in mSec - so two runs …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Static Final String to Enum

    I meant, for example, allowing the user to chose his own preferred colors for his application. Or having different color "themes" that he can chose from. Or having different day/night …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Static Final String to Enum

    Yes, I edited your post so it wasn't code, as requested. Here's the thing about enums: they are fixed at compile time. So if your colors are hard-wired into the …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Static Final String to Enum

    OK. So all really you want is a `getColor` method to wrap some kind of Map<String, Color> so you can do stuff like myField.setBackground(getColor("MyFieldMainArea")); or maybe myField.setBackground(getColor("MyField", MAIN_AREA)); <I have …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Static Final String to Enum

    SO the intent is to replace ocurrences of GRAY50 with the background color (which may been defined by a previous call to the (invalid) method called `Color(String)` on line 15, …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Static Final String to Enum

    Sorry man, I cannot understand what you just posted. Why does a method called `getBackgroundColor` return a String? Why does it need a parameter? What is the significance of the …

The End.