7,116 Posted Topics

Member Avatar for JavaGr33nh0rn

Line 128 if (type == 2); the semicolon finishes the if statement, so it reads "if type is 2... do nothing". Then the { on the next line just starts an ordinary code block that will be excecuted after the if statement. It's the semicolon that's your problem. Same problem …

Member Avatar for JavaGr33nh0rn
0
262
Member Avatar for peymankop

WHat class are you using for your "form" - if it's a JFrame you can call its setTitle method any time to change the title.

Member Avatar for JamesCherrill
0
125
Member Avatar for iciaguevara

Instead of *setText*, use append to *append* your new text to the text that's already in the text area. (You may want a new line character "\n" as well)

Member Avatar for ~s.o.s~
0
246
Member Avatar for uknown2

Just prompt the user for one of those chars, then use a switch to call the appropriate methods,eg switch (inputChar) { case 'V' {viewAllRooms(); break} case 'A' {addCustomer().... ... etc etc (If you are using Java 7 you can have a switch using a String, but earlier Javas need a …

Member Avatar for bguild
0
2K
Member Avatar for pxmur76

Why not just define the button as the default button - then you can hit enter any time the focus is in the container, plus it gets painted with a highlighted appearance so you know it's the default? getRootPane().setDefaultButton(findButton);

Member Avatar for stultuske
0
1K
Member Avatar for Nakeo

`c.getSuitAsString() == "Diamonds"` etc - doesn't do what you think! == tests for exactly the same object. To test if two strings have the same text (sequence of letters) use String1.equals(String2)

Member Avatar for tux4life
0
442
Member Avatar for zdneth

Capture a proper specification of the scope and important functionality. UML Use Cases are one good way to do it. Don't try to get it 100% complete or correct, because it's going to change anyway. From there you can start an object design (class diagram, activity diagram). Avoid the temptation …

Member Avatar for ~s.o.s~
0
185
Member Avatar for zdneth
Member Avatar for darylglenng

> don't use the '==' operators to compare Strings, unless you want your application to work in a way you don't expect/want it to work. That's a bit cryptic! == tests for two objects being exactly the same object. For Strings you want to know if those two different String …

Member Avatar for M4trixSh4d0w
0
341
Member Avatar for toldav

> Would any java gurus take a look at the code Don't know if i count as a guru, but I can't see any obvious faults in that code. IIM has already given you an excellent way to check if the same number is entered twice. Definitely easier than using …

Member Avatar for tux4life
0
335
Member Avatar for hwoarang69

To use the paint method from bbb you need to create an an instance of the bbb class, eg change line 3 to aaa aaa_class = new bbb(); // valid because bbb is a subclass of aaa

Member Avatar for hwoarang69
0
147
Member Avatar for shammi24
Re: java

shammi24 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 …

Member Avatar for JamesCherrill
0
81
Member Avatar for engrjd91

@engrjd91 Nobody can help unless you are prepared to give a lot more information. Eg Which version of Eclipse? Is this all plugins? Just one plugin? Which one, exactly? Ignoring peoples' questions will get you nowhere.

Member Avatar for engrjd91
0
624
Member Avatar for happygeek
Member Avatar for smilesprower

Looks like you declared your combo box without specifying the type, eg JComboBox faceCombo = new JComboBox(); That means that Java cannot check the validity of anything you put into the combo box. Since Java 1.5 you can specify the type of objects tha the combo box conatins, eg JComboBox<String> …

Member Avatar for JamesCherrill
0
218
Member Avatar for piliff82

@meena19: sorry, that's really terrible advice. Exceptions are there to help you. They trap errors in your program and create detailed message explaining what went wrong and where. There's no such thing as an "unnecessary error". The worst possible thing to do is to ignore them. Unless you have a …

Member Avatar for JamesCherrill
0
762
Member Avatar for carrl00

Why do people prefer while over do-while so much, even when it's a perfect example ? do { // your code String readAgain = scanner.next(); } while (readAgain.equalsIgnoreCase("yes"));

Member Avatar for stultuske
0
299
Member Avatar for javaprog200
Member Avatar for godzab

> How do I fix this error, Wrong answer: Just thinking about it for more than about 30 seconds. Wrong answer: Post it on DaniWeb without sharing the line number where the exception was thrown. Right answer: 1. Get the line number where the exception is being thrown. See wha …

Member Avatar for JamesCherrill
0
214
Member Avatar for bangor_boy

Hi manu.mani, welcome to DaniWeb. Please check the dates on topics before responding - this one is two years old, so its unlikely to still be live. You can check the poster's history as well - in this case he hasn't been active on DaniWeb for 10 months. Also, many …

Member Avatar for JamesCherrill
0
282
Member Avatar for Envycx

Hello Envycx, welcome to Daniweb. There are plenty of people here to help you, but you need to do more than that. If you have an error message then post the complete text of the whole message, and post the code it refers to. Nobody can help if you don't …

Member Avatar for stultuske
-3
77
Member Avatar for nova4005

1. You can use substring to pick each 3 letter sub string and test it for equals "111" 2. You can use three charAt calls like if (input.charAt(i) == '1' && input.charAt(i+1} == ... ps There's no such thing in Java as '111'. ' delimits a (single) char, " delimits …

Member Avatar for bguild
0
548
Member Avatar for erms

rubberman: don't forget that Java chars are Unicode, 16 bits per char, four hex digits not two.

Member Avatar for erms
0
605
Member Avatar for angel06

`while(tryAgain = true)` = is assignment, to test for equals use == but in this case, since tryAgain is already a boolean (true or false) yu can just say `while (tryAgain)`

Member Avatar for IIM
0
167
Member Avatar for sofien.fkih

You declare `int clicked` inside the action performed method, so you get a new `clicked` variable (initialised to 0) every time the method is called. If you move the declaration to just outside the method then it will be an instance variable that keeps its value between calls to `jButton1ActionPerformed`

Member Avatar for JamesCherrill
0
941
Member Avatar for walkingddeadfan

You will find it easier if instead of creating a single 7-digit number, you create a 7 element array of single digits. The you can access each element of the array (digit) by a simple array index.

Member Avatar for DarkLightning7
0
252
Member Avatar for adikimicky

You mixed text output and data input streams. They have different formats, and can't be mixed. Either use text streams to send and receive text only, or use a DataOutputStream with a DataInputStream to send and receive different data types (inlcuding UTF Strings).

Member Avatar for adikimicky
0
183
Member Avatar for xHellghostx

Sorry M4.... but that post makes absolutely no sense at all. When posting about Java please use standard Java terminology. If you are not sure, check in the [Java Language Specification](http://docs.oracle.com/javase/specs/) to see what the correct terms are.

Member Avatar for stultuske
0
320
Member Avatar for somjit{}

I can't see any code that changes the content of the array. This code doesn't, even if it was supposed to if( id[i] == tcid ){ tcid = cwid; }

Member Avatar for somjit{}
0
190
Member Avatar for chonobob
Member Avatar for JamesCherrill
0
606
Member Avatar for rami sohaill

"changed some things" isn't going to get you a good result. The code you posted is nowhere near right. Before you start any coding you need to be very clear what is the algorithm you are trying to code. Coding without knowing what you are coding is a bad idea. …

Member Avatar for rami sohaill
0
224
Member Avatar for michelleruth

You pass two values (x,y) into your method. You then have a loop with values of i 2..63, but you do not use i anywhere in your loop. Instead of pow(x,y) you need to raise 2 to the power i

Member Avatar for michelleruth
0
2K
Member Avatar for joshfizzle

I can't follow all your logic, but it seems your while loops are based on values of a..e, but inside the loop you never change any of those variables, so once you enter the loop you will never leave it. What may be easier is to generate set of nubers …

Member Avatar for joshfizzle
0
230
Member Avatar for andrew.ferrebee
Member Avatar for gkaran487

From your data it looks like a name may be in two parts (Ian Wood) or three (P. M. Vissche), or maybe more? If that's the case you will need some kind of "intelligent" algorithm to decide that it's [Ian Wood] [P. M. Visscher] and not [Ian Wood P.] [M. …

Member Avatar for JamesCherrill
0
270
Member Avatar for fazae

Because your code doesn't include anything to process key events? (It only has listeners for mouse click events.)

Member Avatar for fazae
0
232
Member Avatar for narino

Yes, you can. They are two programs, but thoise are just different parts of the overall single application, and the class diagram should show the relationships between the client and server parts.

Member Avatar for georges-l5
0
1K
Member Avatar for hazzag1995

In the actionPerfomed method for those buttons simply create and setVisible the new window, and setVisible(false) the old one if appropriate.

Member Avatar for peter_budo
0
463
Member Avatar for cisumma

You use a ternary when you want to use one of two different values depending on some boolean. The boolean and the values can be constants or expressions eg if the language is French say "Bonjour", otherwize say "Hello" String greeting = language.equals("French) ? "Bonjour" : "Hello";

Member Avatar for deceptikon
0
164
Member Avatar for sk8ergirl
Member Avatar for sofien.fkih

bguild has already answered your question. Your writer just writes characters to the output stream. Characters do not have fonts, colors, or anything else, they are just characters. Depending on where your file is displayed, characters in the file may be interpreted as formatting information according to some standard, eg …

Member Avatar for Ene Uran
0
117
Member Avatar for ranu jain

We are not mind readers! The message that told you about the array index out of bounds also told you EXACTLY what the invalid index was, and which line of your code it happened in. You must share that info if you want someone to help. Anyway, this code is …

Member Avatar for stultuske
-2
133
Member Avatar for Violet_82

Hi jalpesh Do you have any specific reason for suggesting` System.out.println(String.format(...` rather than `System.out.printf(...` I thought that's what printf does anyway? And what is the rationale for doing both, as in `System.out.printf(String.format("` ? J

Member Avatar for Violet_82
0
4K
Member Avatar for xHellghostx

Simplest code is probably String[] a = {"a","b","c"}; Vector<String> v = new Vector<>(Arrays.asList(a)); Edit: oops - I missed the fact hat tux4life had already covered this - sorry for the duplication. J

Member Avatar for tux4life
0
604
Member Avatar for xHellghostx

> presentValue = futureValue/(Math.pow(1+(annualIntrestRate), futureValue)); Just re-read that - where are the years???

Member Avatar for JamesCherrill
0
181
Member Avatar for SoulofchaOs

> Hi, may I know what's the downvote for ? > Do I have to address any issue ? =/. > Oh, is it because I didn't include the updated code ? Your request for help was pretty pointless without posting the code that displays the problem, but I don't …

Member Avatar for JamesCherrill
0
204
Member Avatar for cgogte

I agree. The Oracle tutorials are the definitive best source for the most complete and up-to-date training material. The problem is "complete" - which means thety rapidly get into all kinds of detail that can overwhelm the beginner. They start with some high-level overview stuff taht is definitely a good …

Member Avatar for ~s.o.s~
-1
155
Member Avatar for reezn

You seem to be mixing parsing with a Scanner and parsing with String.split, and getting the two confused. Your Scanner splits the file by the ';' chars, but you don't use that in your parsing, you just read whole lines. Then you try to split each of those lines on …

Member Avatar for reezn
0
434
Member Avatar for DeepAnalyzer

You are using setText(...), which replaces any existing text. Try append(...) instead

Member Avatar for Lucaci Andrew
0
220
Member Avatar for yup790

The isDirectory() method makes it very clear that the File class doesn't see a directory as a file. If in doubt read the API... > public boolean isFile() > ... > Returns: >true if and only if the file denoted by this abstract pathname exists and is a normal file; …

Member Avatar for yup790
0
388

The End.