7,116 Posted Topics

Member Avatar for sirlink99
Member Avatar for gedas

Lines 2,3,4 also suspect, the array references will only be executed if the array index is negative and therefore out of bounds. 6,7 seem to take xy coords in the range 1024,768 and scale them to fit the actual size of the current component. They also invert them so the …

Member Avatar for gedas
0
92
Member Avatar for DoEds

It's easy to split up a string into an array of strings, using (eg) a blank as a delimiter [CODE]String s = "abc 123"; String[] parts = s.split(" "); // now parts[0] = "abc", parts[1] = "123"[/CODE] To convert the score from String to int you can use the Integer.parseInt …

Member Avatar for DoEds
0
108
Member Avatar for DARK_BYTE

If you are on version 6 Java you can directly call methods written in scripting languages such as javascript [url]http://www.javabeat.net/articles/13-introduction-to-java-60-new-features-parti-2.html[/url] This could be a good format for user-defined algorithms because (a) the syntax is simple and (b) you can call them, in source code form, directly from your Java code …

Member Avatar for JamesCherrill
0
154
Member Avatar for jemimaloh

Results is an array, and you can't append to an array with +=, that just works for numbers and simple Strings. You need to keep track of how many elements of the array you have already used so that you can put the new String into the next available empty …

Member Avatar for mmusehani
0
134
Member Avatar for sciprog1
Member Avatar for Fulsomenko

Have a look at the java.util.Random class in the API. You can use this to select random letters etc from your arrays.

Member Avatar for peter_budo
0
248
Member Avatar for kvass

Or: Write a method to convert a date (int yyyy, int mm, int dd) to the number of days after Jan 1st 1900 (or some other convenient earliest date) - something along the lines of[CODE]int daysAfterJan1st1900(int yyyy, int mm, int dd) { return (yyyy - 1900)*365 + (something for leap …

Member Avatar for JamesCherrill
0
83
Member Avatar for musikluver4

Separate the mortgage logic & calculations from the user interface. Put them in their own class, with its own variables, and provide public methods that the user interface can call to set the variables and get the calculated mortgage figures. Now you have 2 classes; put each one in its …

Member Avatar for musikluver4
0
171
Member Avatar for doctorjo5

lines 92-98 the editing has got screwed up here - Object source = e.getSource(); needs to inside ActionPerformed

Member Avatar for kramerd
0
2K
Member Avatar for boiishuvo

Extra } at end of line 36? Adopt a standard for where you put your { and } and stick to it to avoid this kind of problem.

Member Avatar for JamesCherrill
0
89
Member Avatar for Dean_Grobler

Suggest you try testing "image" to see if it's null just before line 19. There are often problems with file names & default directories when reading images (or any other files). ps: I don't understand why you have so many JPanels, a lot of them have only 1 component in …

Member Avatar for JamesCherrill
0
4K
Member Avatar for jemimaloh

I'm finding it hard to understand exactly what you are trying to achieve here. F contains a HashTable; in P you want to perform a lookup on that HashTable - is that right? If so, you can: 1. Make the HashTable public in F so P can access it directly …

Member Avatar for jemimaloh
0
523
Member Avatar for sivasuit

In the time it took to create that post you could have typed [B][I]how to read image file using io stream in java[/I][/B] into Google and immediately got a load of examples

Member Avatar for JamesCherrill
0
19
Member Avatar for daudiam

Never - that is NEVER - use sleep anywhere near Swing. Your while(true) loop runs on the EDT and never returns, thus blocking everything. For that kind of timing use a javax.swing.timer Use it to call your button changing method every x millisecs. In that method just change the icon …

Member Avatar for daudiam
0
1K
Member Avatar for mkaredia

You can terminate a Java program immediately by executing System.exit(0); You can do this, for example, if the user types in 'N'. If you have open files or network connections etc you should close those first, but in this case there's no such tidy-up needed, so keep it simple.

Member Avatar for JamesCherrill
0
177
Member Avatar for BUGSIE91

What are the line numbers of those 5 errors, or do you expect us to guess? "cannot fond symbol" usually means a mis-typed name, or trying to use a variable outside its scope.

Member Avatar for JamesCherrill
0
183
Member Avatar for tyson.crouch

[CODE]17. if(order.length > 0){ 18. out.println(order[1].getPhoneType()); 19. }[/CODE] If order is of length 1 this code will always give an NPE (arrays are zero-based) Was it intended to be a loop?, as in [CODE]for (int i = 0; i < order.length; i++ ) { out.println(order[i].getPhoneType()); }[/CODE]

Member Avatar for tyson.crouch
0
162
Member Avatar for akinfemi

This is not enough informtion for anyone to be able to help you. Please post the code where the error happens (in code tags) and the exact complete error message.

Member Avatar for akinfemi
0
258
Member Avatar for flyingcurry

One small suggestion: This code will crash and burn horribly if presented with parameters like (3,2) or, more subtly, (-2,-3). A simple replacement of the == on line 4 with a >= will protect against these nastys, as will the even simpler replacement of lines 4,5 with if (n1>n2) return …

Member Avatar for flyingcurry
0
2K
Member Avatar for Buffalo101

Why not just build the string userName + " " + password + "\n" and use indexOf to see if that complete String is present in the textarea

Member Avatar for Buffalo101
0
187
Member Avatar for simransuri

Unless there's some other code somewhere else, this code creates an Account object and updates it IN MEMORY. When the program exits, all that info is lost, so next time you run it you are back to square 1 again. To keep the account info from one run to the …

Member Avatar for JamesCherrill
0
175
Member Avatar for rowley4

Lines 60-62 In the loop you remove 1 char from endstring with the intention of adding it to begstring on for the call on line 62 line. Problem is that you remove the char THEN you try to get it by using charAt, but it's too late, you've already removed …

Member Avatar for JamesCherrill
0
99
Member Avatar for Qabane

Extra }; after return year; Missing () after public Movies Please post code in code tags next time.

Member Avatar for Akill10
0
178
Member Avatar for NewOrder

An enum is just like a class that has a number of instances defined at compile time. You can think of it as if Fishes is a class, with exactly two instances. BURI and AMNON are like two public static final variables that hold references to the two instances. Lines …

Member Avatar for ~s.o.s~
0
117
Member Avatar for DoEds
Member Avatar for JamesCherrill
0
126
Member Avatar for hemant mandal

Hi there! Welcome to DaniWeb You'll find lots of people here ready to help you with your Java problems, just remember to do as much as you can before posting a question, and keep your questions as specific and precise as you can. If you have an error, post ALL …

Member Avatar for JamesCherrill
0
31
Member Avatar for pavan146

Not as such, but in Java you use packages and sub-packages to group classes that share things within the package, but not outside it. Have a look at Java's four scope options - private, (default), protected, public.

Member Avatar for JamesCherrill
0
131
Member Avatar for xc3ss1v3

Place an ex.printStackTrace() in EVERY catch clause. Never ever ever do what you do in lines 45/46 if you want any chance finding bugs. When posting here always post the full text of the exception stackTrace, and make sure we have a listing of the code lines it refers to.

Member Avatar for xc3ss1v3
0
666
Member Avatar for jliao20

So what did the compiler show you? Do you want us to guess? I guess [B]work? this Will[/B] do I win the cigar? (Although anyone who deliberately defines their own public class with the same name as a java.util class deserves any and all trouble they get)

Member Avatar for kramerd
0
7K
Member Avatar for judgemental

No, don't bother. If desPanel is not available then that revised line 12 won't work either.

Member Avatar for javaAddict
0
462
Member Avatar for sciprog1

JFrame has a paintComponent too. You can use this to paint whatever you want as the background for that JFrame. Check that everything inside the JFrame has setOpaque(false) if any controls are obscuring the background.

Member Avatar for sciprog1
0
83
Member Avatar for sciprog1

Very possible. In fact the Java API has all the things you need to do this without too much trouble. Have a look at he Server Socket and the Socket classes. Basically you open a ServerSocket on an arbitrary port the server, the client then opens a Socket connection to …

Member Avatar for sciprog1
0
257
Member Avatar for 080346

You asked this (and I answered it) in your previous post: An easy way is to create it when you build the window at the start, but make it invisible (setVisible(false)). Then when you want it to appear make it visible and pack() your window again.

Member Avatar for kramerd
0
103
Member Avatar for 080346

Do you want the second text field to appear only when needed? An easy way is to create it when you build the window at the start, but make it invisible (setVisible(false)). Then when you want it to appear make it visible and pack() your window again.

Member Avatar for Dean_Grobler
0
139
Member Avatar for NewOrder

Hello again NewOrder. It looks like you just drove Norm away again. I've had a chance to re-charge my batteries, so I'll give this a quick try. 1. Going to "ArrayList<object>" won't help. 2. Do you just want to search on the student's name? If so, this is the key …

Member Avatar for JamesCherrill
0
236
Member Avatar for rocky86

You can convert the number to a String then extract every char that is one of '1', '3' etc from that String.

Member Avatar for kramerd
0
74
Member Avatar for Xufyan

You already asked the same question in your previous thread. Please do not double-post. You teacher is being silly. You cannot overload pop() with no parameters, and there is no parameter needed for a pop. Serena5 already gave you good advice [QUOTE]have two methods: int popInt() and float popFloat()[/QUOTE]

Member Avatar for Xufyan
0
1K
Member Avatar for Xufyan
Member Avatar for Voldemort2

[QUOTE]Can you suggest some smaller problems that help me to be familiar with this class so that i can implement this in my project. [/QUOTE] Firstly, that's the right question. So, create a small graphic image file (use any paint program you like),, maybe 10x10 pixels, with a small block …

Member Avatar for Voldemort2
0
152
Member Avatar for bhanu1607

[QUOTE]replace the name of the method: public void paintComponen(Graphics g) by public void paint(Graphics g) [/QUOTE] Unless you have some special reason, this is not a good idea. Sun's doc makes it clear that you should always override paintComponent rather than paint unless there's a specific reason not to [url]http://java.sun.com/products/jfc/tsc/articles/painting/#callbacks[/url]

Member Avatar for bhanu1607
0
101
Member Avatar for judgemental

Not sure what your problem is here - just use ImagePanel instead of JPanel as the container for all your components. You'll have to make sure they are all setOpaque(false) for the image to show through. You can adjust the image size to fit the panel by calling getScaledInstance(...) on …

Member Avatar for JamesCherrill
0
122
Member Avatar for pmark019

I haven't seen an example of how JScrollPane works when it has no contents - maybe that's your problem? Try it with something in it, even a humble JLabel with a short text should be enough. [CODE]JScrollPane scroll = new JScrollPane(new JLabel("Hello")); add(scroll);[/CODE] ps the getContentPane() has been redundant since …

Member Avatar for NormR1
0
170
Member Avatar for kdott

How about a HashMap<String, ArrayList<String>> ? Hashmap has photo name as key, list of keywords as value. Get list of keywords for a photo is trivial, list of photos for a keyword is easy using contains(keyword) on each of the keyword lists in a loop.

Member Avatar for JamesCherrill
0
160
Member Avatar for handrews3583

All your methods and variables must be inside a class. On line 20 you have the } that ends the class definition, so everything after that is NOT in a class. Once you have closed a class definition with its final } the only things can can follow are a …

Member Avatar for JamesCherrill
0
269
Member Avatar for aro_kai

w and h look dangerous - suggest you make them local and set them explicitly from the img itself at the start of this method. I'd print them out here as well, just in case.

Member Avatar for JamesCherrill
0
192
Member Avatar for pavan146

kramerd: that is [I][U]so [/U][/I]neat. Thanks for making my day! J

Member Avatar for pavan146
0
108
Member Avatar for patishere
Re: JAVA

What do you mean, exactly, by randomise? To put an image in a JLabel create your image as an ImageIcon, then use JLabel's setIcon method. The API doc has all the details.

Member Avatar for JamesCherrill
0
101
Member Avatar for Vincent Addison

These are methods of the String class. Yoou will find all the reference material for all the Java classes on Oracle's web site. Here's String to get you started. [url]http://download-llnw.oracle.com/javase/6/docs/api/java/lang/String.html[/url]

Member Avatar for JamesCherrill
0
98
Member Avatar for Bhargavi V
Member Avatar for Bhargavi V
0
337

The End.