7,116 Posted Topics

Member Avatar for zai04

You are going to need 26 of some kind of 2-dimensional array that shows where to print the As in in large block of As, the B's in a large block of Bs etc.

Member Avatar for stultuske
0
206
Member Avatar for riahc3

Before you get carried away with more advanced apps, there's a lot more you can learn from this one. eg * use a proper layout manager (eg GridLayout) rather than the un-portable null layout * replace all those repeated variables and repeated blocks of code with an array of JButtons …

Member Avatar for cisumma
0
387
Member Avatar for letlet_pogs

Hi kluonius. Welcome to DaniWeb. Did you notice this thread is 4 years old? It's unlikely the original poster is still waiting for an answer! ps stultuke's answer above is the right one.

Member Avatar for JamesCherrill
0
7K
Member Avatar for poopuh

If you define a Food class, and create an instance of that class then you have an object no different from a String or an Integer in terms of how you can access or pass it to/from a method. It's just like bguild says, just imagine how you would do …

Member Avatar for bguild
0
287
Member Avatar for coreycebaker

You need to start a Timer with a delay of 10 secsonds. When that time is up the Timer will run a method that you provide, eg to send the next question. If the user answers in time, just cancel the Timer. Here's a simple intro: http://enos.itcollege.ee/~jpoial/docs/tutorial/essential/threads/timer.html

Member Avatar for riahc3
0
144
Member Avatar for Doogledude123

Sorry, I don't have time to study all your code now, but I'll bet 100:1 that it's a problem with keyboard focus. Youy add the key listener to your canvas, but that probably does not have the keyboard focus, so it doesn't get any keyboard events. KeyListener is pretty much …

Member Avatar for Doogledude123
0
753
Member Avatar for game06

DId you try Liuqahs15's suggestion? It looked perfectly sensible to me... ps: Liuqahs15: Nice post. And yes, Java has enums just like that.

Member Avatar for game06
0
212
Member Avatar for SHINICHI

> finds the rows and columns with the most 1s. It's asking you to Look at each row of the matrix, count the number of 1's in each row, find the row (or rows) with the most 1's (in this case row 2, with 3 1's compared to 2 1's …

Member Avatar for JamesCherrill
0
758
Member Avatar for Akusa

public class WordMeaningNode { WordMeaning word; WordMeaning next; You are getting confused between WordMeaning and WordMeaningNode. A WordMeaning is some info about a word, a WordMeaningNode is an entry in linked list (that happens to include a WordMeaning as its data). So in the code above, one of those two …

Member Avatar for JamesCherrill
0
209
Member Avatar for Dorar

root.left.code = root.code + "0"; public Node code; the variable *code* is of type Node, and you try to concatenate a String with it! Maybe the variable *code* should not be a Node?

Member Avatar for JamesCherrill
1
653
Member Avatar for sha11e

The more descriptive it is, the easier it is for someone else to understand. In a real-worldenvironment this the most important consideration.

Member Avatar for JamesCherrill
0
173
Member Avatar for shobhit.yadav.31
Member Avatar for JamesCherrill
-1
27
Member Avatar for sharmeen.batool

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 Post what you have done so far and someone will help you from there.

Member Avatar for JamesCherrill
0
136
Member Avatar for rajhoq12
Member Avatar for JamesCherrill
0
74
Member Avatar for chdboy

You are mixing AWT components and Swing components - this is a formula for confusion and errors. Unless you have some very special reason you should always use Swing components rather than AWT. The swing components have names that begin with a J (JFrame, JButton etc). The ones without the …

Member Avatar for chdboy
0
2K
Member Avatar for game06

Hi game06. Beware incorrect Java terminiology that makes it really hard to understand your questions. A *class* is something you define in your source code. The *new* keyword creates an *instance* , not a class. Many of your uses of *class* above should be *instance* (I think). You would say …

Member Avatar for JamesCherrill
0
136
Member Avatar for Pobunjenik

Two quick points: 1. Date.getHours etc have been deprecated since Java 1.1 (in 1997!) You should use GregorianCalendar instead 2. For updating a GUI you should use a javax.swing.Timer to run your updates on the swing thread, not a java.util.Timer which runs in its own thread.

Member Avatar for Pobunjenik
0
959
Member Avatar for Violet_82

> so what's that year % 4 == 0 about? the above if should only say if( year % 400 == 0 && year % 100 != 0 ) ) because if these 2 conditions are satisfied then the year is leap year > Or am I getting it wrong? …

Member Avatar for Violet_82
0
283
Member Avatar for toldav

" is not working right " tells us nothing. If you have a compiler or runtime error message post the complete message plus the actual code it refers to. If your code is giving an incorrect result explain what result you get and what the correct result should be.

Member Avatar for IIM
0
227
Member Avatar for sk8er3577

You should not have to change the logic classes - that's why we separate logic from user interface in the first place. Obviously you will need new listeners, but they should call the same methods that the mouse listeners call

Member Avatar for JamesCherrill
0
474
Member Avatar for tanya1989

Scanners are just a simple fix for easy input, if you try to use them for formatted data you run out of steam really quickly. Here you have a scanner delimiting on blanks (default behaviour), but you want to keep month and day together. You will find this easier if …

Member Avatar for stultuske
0
335
Member Avatar for game06

Do you inherit x, y, dx, dy from the Item class? If so you can just set dx in the default constructor for Bullet. You haven't given enough info for a proper answer, but my instinct is that if you have two similar items then you should create two instances …

Member Avatar for JamesCherrill
0
129
Member Avatar for daksh1998

[QUOTE=stultuske;1767081]you can run each (desktop) or command line java application, by running ... javac yourClass[/QUOTE] Are you sure? java or javaw work better in this reality :)

Member Avatar for stultuske
0
3K
Member Avatar for XerX

Short version: A JPanel is a container that you can add to a JFrame to help organise and lay out fields and buttons. In your code 1. You have two JFrames and that's confusing you. CelsiusConverterCoded extends JFrame, so your new CelsiusConverterCoded() is a JFrame, but then you create another …

Member Avatar for XerX
0
1K
Member Avatar for HelloPeople1

Depends on the methods - do you mean different methods for one map (in which case see IIM's post), or that there are multiple maps each with its own implementation of the same method signature (in which case build a java.util.Map<String, Maps> to hold the name as key and a …

Member Avatar for JamesCherrill
0
290
Member Avatar for milkman93

Why not just create an empty ArrayList<Integer> before entering that loop, then inside the loop just add each parsed int value to that ArrayList? Then you will have an arraylist with all the values, where you can do whatever processing or calculations you want.

Member Avatar for JamesCherrill
0
293
Member Avatar for game06

Depending on how many things vary from level to level it may make sense to have a Level class with 4 instances, each instance having its own values for all counter etc etc.

Member Avatar for JamesCherrill
0
167
Member Avatar for StefanRafa0

Do you really mean "translate"? - in which case see stultuske's post Or do you mean "transliterate" - replace each letter by it's nearest cyrillic equivalent regardless of meaning, in which case you could use something like this pseudo-code: for each letter in the original string find that letter in …

Member Avatar for StefanRafa0
0
177
Member Avatar for SylvanSagacious

Your methods are all static, and static methods cannot access instance variables without an instance. Your simplest fix is just to leave clientList where it is, but declare it as static so all the methods can access it. (There are all kinds of reasons why Java programs are usually not …

Member Avatar for JamesCherrill
0
350
Member Avatar for Frensi

"Whenever I try to run this nothing happens. " Wrong. It throws an exception which you cannot ignore. > Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 3 > at Hobbits.main(Hobbits.java:8) h is an array of size 3, so valid index values are 0,1,2 On line 8 you try to access index 3

Member Avatar for thepastimer
0
201
Member Avatar for pheonixkid

> should i try putting in some System.out.println(""); codes in the methods to see where it is not working from? Yes, absolutely yes. That's always a good thing to do right from the start.

Member Avatar for pheonixkid
0
279
Member Avatar for riahc3
Member Avatar for riahc3
0
162
Member Avatar for inaxassan

public Boolean isFull() { if( isFull()) { ... When you call isFull(), on its first line it calls isFull(), which, on its first line calls isFull(), which, on its first line calls isFull(), which, on its first line calls isFull(), which, on its first line calls isFull()...

Member Avatar for JamesCherrill
0
184
Member Avatar for jithinjohny

Neither. Stick to a programmer's editor and the commmand line compiler until you have a good feel for Java and what's going on. An IDE is just going to add confusion and learning curve to a situation that already has a lot of confusion and learning curve. Then move to …

Member Avatar for jwenting
0
1K
Member Avatar for dasdgfds

There's no easy way to move the actual JButtons in a grid. What you can do is to keep a track of the x,y coordinates of the player (etc) so you can change the text or icon of the appropriate JButton as the player moves. In pseudo code, for example …

Member Avatar for JamesCherrill
0
365
Member Avatar for milkman93

Static initialisers are OK, but in radhakrishna.p's example watch out for the scope of arr! You can also use an instance initialiser http://docs.oracle.com/javase/tutorial/java/javaOO/initial.html which (to answer stultiske's question) save having to duplicate code between multiple constructors, and can be used in anonymous inner classes.

Member Avatar for milkman93
0
2K
Member Avatar for bananacat
Member Avatar for bananacat
0
339
Member Avatar for game06

"more random"? I don't know what that means. If your code is intended to enter the if block half the time at random, just use `if (ran.nextBoolean())` ... which is as random as Sun's mathematicians know how to make it.

Member Avatar for JamesCherrill
0
105
Member Avatar for saurabh.mehta.33234

Within a single thread statements will be executed in the correct order. Between two different threads there are no guaarantees unless you explicitly synchronise.

Member Avatar for stultuske
0
182
Member Avatar for blacklooksgood

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 is interested in helping you cheat or doing your homework for you. DaniWeb Member Rules (which you agreed to when you signed up) …

Member Avatar for <M/>
0
2K
Member Avatar for game06

current_node is an instance variable. It has one value (maybe null) for each instance of the class. You cannot use it without an instance. Your main method is static - it executes without an instance of the class - so you can't use current_node unless you specify explicity an instance …

Member Avatar for JamesCherrill
0
300
Member Avatar for Lamirp

No, sorry radhakrishna.p, that explanation is not right. The problem is that the parameter and the newCheckBox variable are local to the makeCheckBox method. As soon as that method finishes both those variables are discarded. Some time later the ItemListener is called, which tries to use those variables, but they …

Member Avatar for Lamirp
0
285
Member Avatar for lester.awotwe

"Urgent" means "I left this too late"? 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 Post what you have done so far and someone will help you from …

Member Avatar for JamesCherrill
0
181
Member Avatar for SylvanSagacious

You get a null pointer because you have not initialised the variable *socket*. You seem to be missing the call to create a DatagramSocket and *connect* that to the server.

Member Avatar for JamesCherrill
0
782
Member Avatar for hassansayed

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 Post what you have done so far and someone will help you from there.

Member Avatar for <M/>
0
109
Member Avatar for asifalizaman

Hi, welcome to DaniWeb. The way it works here is that people post their problems/questions and other people then reply and try to help. If you see a problem posted and you know the answer then please post a reply. You may also want to review the [DaniWeb rules](http://www.daniweb.com/community/rules) - …

Member Avatar for mike_2000_17
-3
578
Member Avatar for mdfaisalamin

Scanner is "A simple text scanner", you can't use it to parse a binary file. Have a look at DataInputStream which reads binary data - although you may need to write a bit of code to handle text that's encoded as zero delimited bytes

Member Avatar for ~s.o.s~
0
243
Member Avatar for game06

With all those == tests you are testing for exactly just touching, but depending on dx, dy, and the whole history of the movement an exact touch may be unlikely. (If any of the variables is floating pint an == is even more unlikely.) You coud try using >= or …

Member Avatar for JamesCherrill
0
150
Member Avatar for SHINICHI

jignam: 1. Don't hijack other people's posts. Start your own for your won question. 2. 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 Create a new thread, post …

Member Avatar for JamesCherrill
0
241
Member Avatar for saurabh.mehta.33234

6: Animal c = new Animal(); // creates a new Animal (1) 13: Animal e = new Animal(); // part of initialisation of Animal (1) - creates another new Animal (2) 13: Animal e = new Animal(); // part of initialisation of Animal (2) - creates another new Animal (3) …

Member Avatar for saurabh.mehta.33234
0
139

The End.