7,116 Posted Topics

Member Avatar for brandon66

Add an ActionListener to the combo box. That will be called whenever the user selects a new Widget. In there you can update the price and total. Same thing for the Quantity spinner. http://docs.oracle.com/javase/tutorial/uiswing/components/combobox.html#listeners

Member Avatar for NormR1
0
201
Member Avatar for javalover

Do you mean something like JUnit, where you define test cases and it runs them and checks that the results are correct?

Member Avatar for NormR1
0
773
Member Avatar for Dark007

Step 1: Try to arrange your code so that there are the smallest number of classes and methods that the client needs to call on the server. You may want to create a new class that just acts as a "wrapper" for the server classes/methods so that everything the client …

Member Avatar for Dark007
0
190
Member Avatar for calomari

I use Eclipse, mainly because it was the obvious next step from Borland JBuilder which I was using when that expired many years ago. However, since then I have been constrained because IBM (the largest employer of Java developers in this part of the world) prefers SWT over Swing, so …

Member Avatar for stultuske
0
94
Member Avatar for Matth963

Because the if/else/print"no" is inside the while loop it will be executed once for each line in the file. Your logic should check for the password being in the file, then display the frame or the error afterwards. Something like this (pseudo-code) boolean passwordFound = false read each line of …

Member Avatar for Matth963
0
298
Member Avatar for rahul.ch

(to clarify Majestic's post: == works exactly as the language definition says it should, including for Strings. It tests for two references being equal, ie referring to exacty the same object. However, it doesn't do what beginners sometimes think it does, ie test for two Strings containing the same sequence …

Member Avatar for rahul.ch
0
245
Member Avatar for plasticfood

When you created the instances of Node that currentNode refers to, what did you have in the <> How is curentNode defined?

Member Avatar for plasticfood
0
234
Member Avatar for silverkid

star88 Where do we start? Your post is just a pile of low-quality code with no explanation I have no idea why you posted it You seem unaware that this is the Java forum and that's not Java code Any comments before I delete it?

Member Avatar for LaughingOtter
0
22K
Member Avatar for roshan janyani

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 include: "Do provide evidence of having done some …

Member Avatar for JamesCherrill
-1
45
Member Avatar for krovi

The Java classes like Integer, Boolean etc are good examples or wrapper classes, but they are not the only ones. This discussion says it all... http://stackoverflow.com/questions/889160/what-is-a-wrapper-class

Member Avatar for JamesCherrill
0
114
Member Avatar for rahul.ch

That's just how postfix works. O n line 4 the value of x-- (10) is passed to the met method, then the value of x is decremented. In the method met, the value of the expression x-- (also 10) is evaluated. The parameter x is them decremented, but this is …

Member Avatar for rahul.ch
0
173
Member Avatar for borchu

So your sound is in a byte array? In that case you can simply write that to the socket via an ObjectOutputStream. At the receiver you just read it via an ObjectInputStream and now the receiver has a copy of the sender's array. You already have code to do that, …

Member Avatar for borchu
0
983
Member Avatar for rahul.ch

st is a copy of s1, which is a ref to a Sample1. You then try to cast that so Sample2, which is invalid. The relevant rule is that you can cast a subclass to it superclass, but not vice-versa. This is because every Sample2 is, by definition a Sample1, …

Member Avatar for rahul.ch
0
246
Member Avatar for greg2186

OK, you have code to show a letter grade. What *exactly* is wrong with the results it gives you? Maybe you are getting multiple letter grades? Eg if the grade is 80 then it will pass the if tests on lines 43, 46, 49, 52 and 55. Have a look …

Member Avatar for greg2186
0
1K
Member Avatar for dantheman4

Use it to replace the code that's already in main to print the parallelogram. How much of this program did you write, and how much did you copy without really understanding it? Your code looks like typical Java learner code, but the code in main for the parallelogram looks like …

Member Avatar for JamesCherrill
0
239
Member Avatar for bad.boy.Vlad

Java is not the same as JavaScript. You have posted in the wrong forum.

Member Avatar for bad.boy.Vlad
0
261
Member Avatar for calculuskatie

Yes. @niravn: the code on that site is a terrible example of how to code Java in 2012. Post deleted. Remember ou are required to comply with DaniWeb member rules, including "Do ensure that all posts contain relevant content and substance and are not simply vehicles for external links". Any …

Member Avatar for stultuske
0
180
Member Avatar for im abcd

By using Eclipse you are adding layers of complexity to your task. I can't immediately see anything wrong with you code, so its probably something to do with your usage of Eclipse, eg the run configuration. At your stage of learning you would be best advised to stick to a …

Member Avatar for im abcd
0
255
Member Avatar for borchu

When you send a file it goes in two stages 1. You read the file into an array, one block at a time 2. You write those blocks to the socket ... similarly at the receive end. If you don't have a file then the data will be in some …

Member Avatar for borchu
0
248
Member Avatar for sanilo

You're close. All you need to do is to add the new field to the existing visible JFrame - not a button, not a new frame, just the existing one. Depending on what layout manager you are using you may also need to call pack() afterwards to let the layout …

Member Avatar for JamesCherrill
0
196
Member Avatar for SSagar

You could try JNI. Here's a decent-looking tutorial: http://www.codeproject.com/Articles/2876/JNI-Basics-1

Member Avatar for JamesCherrill
0
217
Member Avatar for lj81

In Java "this" is always the current object - the one whose context the current method is executing in. The Thread constructor takes an instance of Runnable as its parameter, so "this" must be an object whose class implements the Runnable interface (which consists of a single run method). When …

Member Avatar for JamesCherrill
0
117
Member Avatar for zeusprog

Integer values won't fit in a byte. Perhaps you could show a small example of what Integer values you expect, and how they should look after being converted?

Member Avatar for zeusprog
0
3K
Member Avatar for AngelOfRock

Look at the line of your code where the NPE was thrown. Print the values of the variables at that line to see which is null. Backtrack with more prints until you find out why it's null. ps: `if (e.equals(button1))` e is an ActionEvent, button1 is JButton. They can never …

Member Avatar for JamesCherrill
0
812
Member Avatar for kkcaddy

Maybe you have a class of your own called Date that is in the same directory as this code?

Member Avatar for NormR1
0
195
Member Avatar for Dark_Omen

It's a floating point binary number, and cannot exactly store the decimal value. This is true of all floating point binary - any hardware, any language. To format your output with (eg) rounding to 2 decimal places see these tutorials: http://docs.oracle.com/javase/tutorial/java/data/numberformat.html http://docs.oracle.com/javase/tutorial/i18n/format/numberFormat.html

Member Avatar for JamesCherrill
0
482
Member Avatar for 47pirates

The recursive call on line 84 is ringing an alarm bell, but the variables names are so totally useless (what's m supposed to be?) that I can't tell any more than that.

Member Avatar for 47pirates
0
105
Member Avatar for zeusprog

getBytes will extract the text bytes from the string - it doesn't know or care about hex. It will give you {'1', '0', 'B' ... Then you convert each of those and you get 32 integer values each in the range 0-15. To decode that as 16 integer values each …

Member Avatar for zeusprog
0
232
Member Avatar for sageetam

Please check the Daniweb member rules before posting DaniWeb Member Rules include: "Do provide evidence of having done some work yourself if posting questions from school or work assignments" http://www.daniweb.com/community/rules

Member Avatar for JamesCherrill
0
33
Member Avatar for hszforu

You have that error message because you out an executable statement that's not in a method. Executable statements need to be in a method or constructor. That could be main, or any other method that gets called directly or indirectly from main (including constructors). (Ps: for the experts out there, …

Member Avatar for hszforu
0
238
Member Avatar for Deepika Deepi
Member Avatar for LoyalOne2

You seem to be getting some reasonable code written there, so what's your question?

Member Avatar for Starstreak
0
151
Member Avatar for rostand.lagarde

Please check the Daniweb member rules before posting DaniWeb Member Rules include: "Do provide evidence of having done some work yourself if posting questions from school or work assignments" http://www.daniweb.com/community/rules

Member Avatar for JamesCherrill
0
32
Member Avatar for borchu

Once you have your socket connection you can send the file over it by simply reading it in sensible sized blocks and writing them in a single stream of bytes to a DataOutputStream via the socket. This is the standard code for doing that kind of thing, which you will …

Member Avatar for borchu
0
9K
Member Avatar for zeusprog

You could try creating the input stream before you write anythung to the output stream - maybe there was a response but you missed it before you opened the input stream? Anyway, add print statements at key points in that code so you can see exactly where it is hanging …

Member Avatar for zeusprog
0
158
Member Avatar for admiralis

That seems a reasonable start. I would now expect to see quite a lot more detail about how you find the plants that meet the criteria - probably some kind of loop with an if test??? Ps proper indentation makes this much easoer to read, and helps you spot errors.

Member Avatar for JamesCherrill
0
195
Member Avatar for royaan.khan
Member Avatar for admiralis

> It is not working. Do nothing. Put some print statements into your code, starting at the first line of main so you can see what code is being executed, for how many times, and what isn't. ps: I agree with stultuske - classes like that is how you would …

Member Avatar for admiralis
0
277
Member Avatar for ihiroshi30

You're not ready to start any coding yet because you don't know what the code is supposed to do! I suggest you get a paper and pencil and try drawing a calendar or two - with real dates. That way you will learn what's needed in your program.

Member Avatar for JamesCherrill
0
244
Member Avatar for student_2012

DaniWeb Member Rules include: "Do provide evidence of having done some work yourself if posting questions from school or work assignments" http://www.daniweb.com/community/rules

Member Avatar for NormR1
0
427
Member Avatar for jalpesh_007

line 34 you initialise aspStr as null, but then on line 37 you try to append text to it. You can't append anything to a null. Initialise it to an empty String ie "" instead.

Member Avatar for jalpesh_007
0
297
Member Avatar for calomari

> Actually I got it running by removing... Very unlikely! If you remove `public static void main(String[] args)` your program won't run at all. `for(counter%10==0){...` will ignore the counter variable and loop forever, just executing sleep after sleep. Since this is the last thing in the program it will just …

Member Avatar for Taywin
0
126
Member Avatar for ITshard

Please post your code here, using the "code" button in the post editor so we can all read it.

Member Avatar for JamesCherrill
0
199
Member Avatar for klin1344

Lines 57,58 You only need one Name object becuase that contains both first and last name fields You may also consider some constructors that allow fields to be set, eg `public Name(String first, String last) { ...` because that's simpler to use than creating an empty name then setting both …

Member Avatar for JamesCherrill
0
714
Member Avatar for jakubee

> the String class is automatically copied if you use get() from the ArrayList Have you any reference or demo for this? I would be very surprised if get did anything other than just return a ref to the original object.

Member Avatar for JamesCherrill
0
1K
Member Avatar for borchu

Why synchronised? Why interrupt the server - that means it won't be listening when you start the client. Just start the server then start the client in two different threads and let them both run.

Member Avatar for borchu
0
3K
Member Avatar for eirene08

I ran the code and it displays the numbers 1-12 in a circle, like a clock. *Except*: the circle is distorted - more like a pear lying on its side, and the numbers are rotated so 12 is upside-down. So it's safe to conclude that the code basically works, but …

Member Avatar for Taywin
0
574
Member Avatar for kraykezia

You can get the contents of any cell in the table, so you just need a loop that accesses every row in one column. When the data is changed you can add a listener to the table that will be called so you can recalculate the sum. Study the API …

Member Avatar for NormR1
0
261
Member Avatar for andrewisthebomb

> If it's a double then it will ALWAYS have a numeric value. Unless, of course its value is NaN (Java Language Spec. 4.2.3) ;)

Member Avatar for NormR1
0
1K
Member Avatar for paryudi

1. How much memory does each calculation need (how many of what kind of objects)? 2. Do you need to keep all the objects for each calculation? 3. Is it possible to run a smaller version of the calculation so you can tell whether it is a bug or a …

Member Avatar for JamesCherrill
0
683

The End.