7,116 Posted Topics

Member Avatar for wilsonz91

You can pass an array as a parameter, ie declare the method as public void Sort(Transport[] arrayOfTransportsToBeSorted) then in the method sort that array. and call it like this Sort(metro);

Member Avatar for JamesCherrill
0
6K
Member Avatar for mallak alrooh

I suggest you create a method to do the user interface - ie display the menu, get the input etc. That will keep your code neat and organised = easy to read and undersand. At this stage it's fine to put that in the main class. "if the answer is …

Member Avatar for JamesCherrill
0
142
Member Avatar for kezkez
Member Avatar for TheSecOrg

You can use the following classes: 1. File - this handles the name/path of the file 2. PrintStream - this allows you to use the print() method to send your text to the File 3. FileReader - this allows you to read in the file that you printed earlier 4. …

Member Avatar for TheSecOrg
0
398
Member Avatar for sciprog1

Just a guess, but since these are running on the same machine the server may be sending the response before the client has opened its input stream? You could try opening both the input and output streams before starting to write anything.

Member Avatar for sciprog1
0
82
Member Avatar for hatux

If your methods etc are all static then you can declare your variables as public static [I]outside the methods[/I] which (a) makes them available to all methods in that class and (b) makes them available to other classes by referring to them using the class name, eg ObtainKey.SearchWord This will …

Member Avatar for hatux
0
216
Member Avatar for vishalonne

Like the comments in the code suggest, you need an array of Enemies, not the hard-coded enenmy1-3. The array can then be a big as needed in each run.

Member Avatar for JamesCherrill
0
175
Member Avatar for Kerrai

In order to be able to sort instances of some class (such as Scores) you need to be able the compare two Scores to see what order to sort them in. Scores is a class you define, so there's no sensible guess that Java can make about what order you …

Member Avatar for JamesCherrill
0
3K
Member Avatar for cherryduck

In your event handler you can use evt.getComponent() to get the actual card object that was clicked, which you can then use setIcon etc on. That way you can also use the same event handler for all the cards. If cards are some kind of Swing JComponent then you can …

Member Avatar for cherryduck
0
132
Member Avatar for TGeorge824

There isn't a "Directory" class. Both files and directories are represented by the File class, so all you need is is an ArrayList<File>

Member Avatar for JamesCherrill
0
1K
Member Avatar for ASIWYFA

You can draw your image anywhere in your JFrame using drawImage(...) in the paintComponent method (you should normally override paintComponent, not paint). eg see: [url]http://www.particle.kth.se/~lindsey/JavaCourse/Book/Part1/Java/Chapter06/images.html[/url] Divide your JFrame (conceptually) into a grid of element size equal to the size of your image, then use the text file to determine which …

Member Avatar for JamesCherrill
0
583
Member Avatar for juniper2009

Do you mean the file is empty, or is there no file at all? After line 9 try System.out.println(Arrays.toString(Reg)); to help locate the problem.

Member Avatar for JamesCherrill
0
134
Member Avatar for Dean_Grobler

If you want to exit the app you don't need lines 3-7, you can just do that directly on line 13 If you don't want to exit, you don't need lines 3-7 So in the end it's 3 lines of boilerplate (excluding {}).

Member Avatar for masijade
0
130
Member Avatar for kezkez

The action listeners are both inner classes of your main class, so if you move the declaration of [I]StudentDB db[/I] out to the main class class you can access it from both listeners.

Member Avatar for kezkez
0
158
Member Avatar for AaronLLF

You didn't give us the line number for your exception, but, if it's line 92 you will need to look at the code/doc for org.lwjgl.opengl.Display to find out what it's complaining about and why. But - where do you create/open/display the Display window???

Member Avatar for JamesCherrill
0
585
Member Avatar for jemimaloh

check out the params for substring - you select a substring starting at 0 ending at the last \, but you want one starting at the last \ and extending to the end of the string.

Member Avatar for jemimaloh
0
124
Member Avatar for jems5

I haven't studied the code, but it looks like you have an array of names, slaes etc in the scanner constructor, but the getName, and the print don't loop thru that, they just access a single string? I would have expected to see a SalesPerson class, each instance representing a …

Member Avatar for quuba
0
101
Member Avatar for Chalandria

[CODE] // determines whether each indiviual character of the user entered string is a letter (is counting cumilative for each string still) for (int x = 0; x < inputLine.length(); x++) if (Character.isLetter(inputLine.charAt(x))) letter++;[/CODE] This little piece of your code examines the String inputLine and sets the variable letter to …

Member Avatar for Chalandria
0
353
Member Avatar for Pink12

How much time have you been given for this? - it will help us get a feel for how much detail is expected.

Member Avatar for tenorsax08
0
80
Member Avatar for musikluver4
Member Avatar for javanew

Please post the full NPE message with all the line numbers and the actual lines they refer to. Indenting the code properly will also help to identify problems.

Member Avatar for JamesCherrill
0
126
Member Avatar for ChaseRLewis

Have a look at this recent thread on exactly that subject [url]http://www.daniweb.com/forums/thread316225.html[/url]

Member Avatar for JamesCherrill
0
80
Member Avatar for Nidhi S.

It would help if the code you posted corresponded to the error messages. Line 149 is for(i=0;i<256;i++) - no NPE there! After that you loop thru all 256 elements of the array, but you previously populated only as many elements as there lines in the data file, so if there …

Member Avatar for Nidhi S.
0
1K
Member Avatar for Sunshineserene

Can't tell without the your code, but if you're trying to parse that "{" at the beginning of your input string, that could be the cause of your problem.

Member Avatar for Sunshineserene
0
2K
Member Avatar for blknmld69

What problem exactly are you having - please give expected vs actual results. ps: Shouldn't tax depend on the quantity * price, not just the unit price?

Member Avatar for blknmld69
0
1K
Member Avatar for LianaN

Are you sure that columnMarginChanged in your TableColumnModelListener has actually been called before it drops thru into the problem code - or is txtAdminTextFields initialised somewhere else?

Member Avatar for JamesCherrill
0
329
Member Avatar for jaymozart

Looks like the array is big, and you just populate the first "n" elements from the data file, so the remaining elements are un-initialised, and give an NPE when anyone tries to compare them for sorting.

Member Avatar for jaymozart
0
168
Member Avatar for Dean_Grobler

Following normal conventions, the constructor for the new window does everything except make it visible. Where you have NewContact n = new NewContact(); you need to follow that with a n.setVisible(true);

Member Avatar for JamesCherrill
0
372
Member Avatar for Xufyan

Re-read cale's post. You call getData() for Salary Experience Education but nowhere for a manager do you call get() for Name and Code

Member Avatar for JamesCherrill
0
140
Member Avatar for Tiny_trixer

[url]http://www.java2s.com/Code/JavaAPI/java.lang/ThreadjoinUsingjointowaitforthreadstofinish.htm[/url]

Member Avatar for Tiny_trixer
0
147
Member Avatar for Xufyan

this(...) calls another constructor for the same class. So the constructor on line 15 starts by calling the default constructor (no args). The constructor on line 22 starts by calling the constructor sphere(double xcentre,double ycentre,double zcentre) to deal with x,y,xcenter before going on the handle the extra r2 parameter Since …

Member Avatar for ruchi18
0
241
Member Avatar for Xufyan

[QUOTE]i searched over google but didn't find the suitable answer...! [/QUOTE] The technical OO terminology is "accessors and mutators" - googling these will give you lots of good info. Here's a good article to start with: [url]http://java.about.com/od/workingwithobjects/a/accessormutator.htm[/url]

Member Avatar for imtiyaz41
0
460
Member Avatar for virendra_sharma

I just Googled it and found loads of examples etc. Google is your friend.

Member Avatar for JamesCherrill
0
82
Member Avatar for Dean_Grobler

This question doesn't quite make sense - the actionEvent is created by Swing normally. Can you please explain exactly what you want to achieve?

Member Avatar for Dean_Grobler
0
450
Member Avatar for Xufyan

It's a mistake. It should read byte[] b=new byte[255]; byte is a numeric type - an 8 bit integer. This declares an array of 255 bytes. Because b was incorrectly declared, the methods that have it as a parameter also don't compile. The method that was supposed to be used …

Member Avatar for JamesCherrill
0
166
Member Avatar for deleti0n

ParkedCar.minparked ParkedCar is the class, so this is a reference to a [B]static [/B]variable. But minparked is (correctly) an instance variable. You have to refer to it using an instance of the ParkedCar class, not the class itself, as in ParkedCar car = (something) if (car.minparked (etc)

Member Avatar for javaAddict
0
114
Member Avatar for Claude2005

This [url]http://download.oracle.com/javase/tutorial/uiswing/components/table.html[/url] is a very good intro, and includes a section on how to sort a table.

Member Avatar for Claude2005
0
112
Member Avatar for Born2Bgeek

Within the face's drag event handler you can get the new mouse coordinates. If you kept a copy of the previous coordinates you know what the move was (change in x, change in y) and you can explicitly move the hat by that same amount.

Member Avatar for JamesCherrill
0
127
Member Avatar for diggerman

You just need an int to hold the number of entries already in the array(s) - initial value 0. This is also the correct index to use for the first available array element. Increment it each time you add something to the array. [CODE]int numEntries = 0; while (user is …

Member Avatar for diggerman
0
13K
Member Avatar for kezkez

Duplicate definitions of studentDB on lines 5 and 10. By defining a new one on line 10 that's the one that gets initialised, but it ceases to exist at the end of the constructor method.

Member Avatar for JamesCherrill
0
78
Member Avatar for Xufyan

getData is an instance method, so you call it via an instance of the Manager class (eg "first"). You have called it via the name of the class, not an instance. You can only do that for static methods.

Member Avatar for JamesCherrill
0
373
Member Avatar for juice33

Sorry Dupron, but no cigar. Windows file names are not case sensitive. The message was about cmis141Student1.participationGrade(); There is no such method in that class, so the symbol is undefined.

Member Avatar for JamesCherrill
0
104
Member Avatar for sciprog1
Member Avatar for Dupron
0
154
Member Avatar for jems5

You can use a boolean to tell you which letter to use. Instead of line 23 test the boolean, assign the appropriate char, then toggle the boolean true -> false or false -> true so that next time thru the loop you will print the other char. Or Get a …

Member Avatar for jems5
0
2K
Member Avatar for gedas

It looks like the coords are loaded into the x/ycoordinates arrays - so each element of the array-pair represents a different point. In which case you already have access to all the points, you don't need any new variables. Eg - to connect the first two points by a line …

Member Avatar for gedas
0
157
Member Avatar for AaronLLF

Yes, gameLoop looks like the main method here. It's normally considered bad practice to put too much code in main() because this hinders any possible re-use. The ideal main() just instantiates an instance of the class, and calls an instance method that does whatever needs to be done. So, the …

Member Avatar for kramerd
0
680
Member Avatar for johnlop1

A safe way to check for a "blank" line is to trim() the String then test if its length is 0.

Member Avatar for JamesCherrill
0
117
Member Avatar for Intrevix

By printing the right number of blank lines before it starts, then printing the right number of spaces before the *... on each line.

Member Avatar for JamesCherrill
0
135
Member Avatar for sam1
Member Avatar for DoEds

I assume this is a continuation of the recent thread? In that, you said scores should be in an integer array, and I told you how to convert the strings to integers. If you make it an array of ints it will sort numerically. However, if you want to sort …

Member Avatar for JamesCherrill
0
128

The End.