JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

yeah..i did remove it

"it"? There were at least two that are wrong. Please don't take this the wrong way, but can you post the corrected version of the line(s) you changed, because it sounds like the origina problem is still there.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

It's hard to understand that description. Maybe if you posted your actual code so far that would be clearer?
Does B extend A?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

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 on line 63. There may be others. I didn't check them all.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Maybe the variable customerService is null at that point - if you posted the exact complete exception messgage then it would probably be clearer, or try printing customerService there to confirm.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Stultiuske and I posted simultaneously, that's quite a common event. Maybe your post was also simultaneous, but that's irrelevant to the teach vs spoonfeed point. You don't have to agree with me; there are many other active members in this forum who will vote as they see fit. I'm now going to have dinner....

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

OK. No I didn't assume you downvoted - all votes without a comment are anonymous by design. There's no connection between the votes on my/stultuske's posts, and the downvote on yours.
In this forum we try to avoid giving people code they can copy/paste without understanding. Your post didn't explain how to do it. It just says "copy this code and your homework will be OK" - no attempt to explain why. If it hadn't already got an upvote I may not have voted, but under the circumstances I didn't think I could let an upvote stand unchallenged.
The earlier posts were examples of giving the OP enough info to do a little research and solve the problem for themselves. Follow that example and you will see more upvotes.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

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)

tux4life commented: Doesn't deserve to be downvoted, the given answer is correct. +13
~s.o.s~ commented: Doesn't deserve downvote +14
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

the same teacher today said that a main method doesn't require a void return type, or any return type at all

Oh man, you really have a problem there; I hope he's not marking your homework. Anyway, you've discovered DaniWeb, where we may not always be right, but if we're wrong someone will point it out very quickly!

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

I don't understand what point your teacher is trying to make.
The Java Language Spec doesn't use the term "attribute" except in two places. One is a very technical discussion of garbage collection, and the other uses it to mean a variable that can be accessed via get/set methods. So strictly speaking your teacher is in some private world of his own, using his own meaning for terms that don't have a proper definition. How does he define attribute so it's different from a variable?
Normally speaking, however, people use "attribute" to mean an instance data member of a class ( a "field" in JLS speak), so a class can have objects from other clases as attributes, it happens all the time, and your String is a perfect example.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

It just needs to override the default equals method that it inherited from Object. The inherited method tests for two Card objects being exactly the same object. For two Cards you can say they are equal if they have the same suits and values. (it's just like equals for Strings, which tests for having the same sequence of characters). That's what you need for any (eg) Ace of Clubs to match the Ace of Clubs that you used as a key in the HashMap. The pseudo-code goes like this:

 class Card {
    ...
    public boolean equals(Card other) {
      if this.suit not equal to other.suit return false; // not equal
      if this.value not equal to other.value return false; // not equal
      return true; // sanme suit and value
    }
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Any special reason to use convoluted arrays and lookups like that? Why not just have a HashMap<Card, Image> and load that with the 52 cards and their respective images. Then you can just use imageMap.get(card);
(Assumes you hace defined equals method for the Card class)

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

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)

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Assuming you have done nothing bizarre with class loaders, this code snippet, running in an instance of a class loaded from the jar, gives you a File reference to the jar file...

File jarFile = new File(this.getClass().getProtectionDomain().getCodeSource() .getLocation().toURI());

From that you can easily get a reference to any other dir on the same logical drive as the jar - is that what you are looking for?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

mKorbel is going to disagree with me but...
In my opinion, key bindings are the right solution for real-life development, but they are not easy for a beginner. KeyListener is much easier to understand. The more you use key listener the more you will run into its problems and limitations until you are ready to tackle key bindings to solve all those problems. For now, I think you will be OK using key listeners.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

AWT classes are in the java.awt package, swing classes are in javax.swing
Swing classes have names that begin with a J (eg JLabel is swing, Label is AWT)
Like mKorbel said, the swing versions replace the AWT versions more than 10 yeras ago. You should not use the old AWT versions unless you have some very special advanced technical reason.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

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
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Along with your x and y coordinaltes you could have a boolean for mouth up. In your key event handler set the boolean correctly when the user presses up or down. In your paint method use that boolean in an if test to draw the arc up or down

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Missing the final } on the previous method.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Excellent. Please mark this thread "solved" for our knowledge base.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

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> faceCombo = new JComboBox<String>();

so Java knows that all the entries are (must be) Strings, and it can check all your add methods to make sure that it is right.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Sorry, I'm having a "senior moment"! Can you explain that again please?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Hi javaprog200
Sorry about the digression there. Here's a simple small runnable test case that shows the solution working:

import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JApplet;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import javax.swing.JLabel;

public class AppletTest extends JApplet {

   public AppletTest() {

      // gives "BoxLayout cannot be shared" ...
      // setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

      // works...
      getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));

      JPanel panel1 = new JPanel();
      panel1.setBackground(Color.yellow);
      add(panel1, BorderLayout.NORTH);
      panel1.add(new JLabel("New label in panel 1"));

      add(Box.createRigidArea(new Dimension(100, 100)));

      JPanel panel2 = new JPanel();
      panel2.setBackground(Color.cyan);
      add(panel2, BorderLayout.SOUTH);
      panel2.add(new JLabel("New label in panel 2"));
   }

}
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

They seem to be references to the JFrame add method in Java 1.5 (just calls the content pane add method). JApplet does the same thing (at least in Java 1.7).
What has that got to do with adding two JPanels, as in (just run it):

import javax.swing.JApplet;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import javax.swing.JLabel;

public class AppletTest extends JApplet {

   public AppletTest() {
      JPanel panel1 = new JPanel();
      add(panel1, BorderLayout.NORTH);
      panel1.add(new JLabel("New label in panel 1"));
      JPanel panel2 = new JPanel();
      add(panel2, BorderLayout.SOUTH);
      panel2.add(new JLabel("New label in panel 2"));
   }

}
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Do you have any authoratative links (eg from Oracle) for that, as opposed to just adding two JPanels to the content pane?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

@IIM
1. Why re-post all that code?
2. Are you saying that you can't add two JPanels to a JApplet?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

I don't use box layout myself, but I believe the message is a misleading one, and is caused by the layout being set for for a different component type than the "target" parameter (content pane vs JApplet) (the setLayout is forwarded to the JApplet's content pane). A quick Google for that error message will get you a full discussion, but I think one solution may look like this:

getContentPane().setLayout(new BoxLayout(getContentPane(), etc
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Did you setLayout the box layout for your applet?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

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"));
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

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 the array and index expression are
2. If there's more than 1 index expression on that line then print all the index expressions and corresponding array sizes to find out which it is.

Now you have some hard data you may be able to see the problem, or you could share that data here for more help.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

No need to take it personally. No insult was intended. You would probably be surprised how many beginners would literally copy and paste a fragment like that. You didn't show any code, so I had to guess what it was that crashed.
Anyway, I'll stay out of this thread if that's what you want.
J

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

The "... etc etc" was intended to tell you that the code was incomplete. I'm not going to write your program for you. You can find information and tutorials on the switch statement, then use the example I gave you to apply that information to your own program.
I have pointed you in the right direction, but you have to make the journey yourself.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Netbeans is your development environment. It works with various recent versions of Java, including the most recent - Java 7

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

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 single char)

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

It's possible you have a previous test still running, so the port is still in use. Check the task manager for instances of java.exe or javaw.exe.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

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).

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

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 to see what the correct terms are.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Excellent! Please mark thread solved.
J

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

The debug statemengt I'm looking at shows tcid and cwid but it does NOT show the actual array content.
You are updating tcid, but you are not updating the array.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

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;
}
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

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

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Why not just return a Color, store the Color in a Color variable, use the Color, etc, as a Color object? Why do you want to use an int for this? Why do you want to get the RGB values, why not just use the Color in your g.setColor call?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

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 and test for duplicates. As long as there is any duplicate just keep generating a new set of numbers., ie

do {
   generate numbers
   test for duplicates
} while there any any duplicates
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
  1. Yes. Swing calls paintComponent when needed. Resizing the container os one reason why a repaint would be needed.

  2. rand.nextInt(255) returns a random int in the range 0-254, not 255. The Color constructor takes three values 0-254 representing the red/green/blue components of the color, so that whole code creates a new color with random R G and B components covering the full range of valid colors.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

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";
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

.exists down't work

.exists does work. It's been in the Java API forever, and is used in more programs than we can count. The fault almost certainly is either in your understanding or in your code. The most likely problem is that Java is looking for the file in a different directory. Follow bguild's excellent advice and print f.getAbsolutePath() to see where Java is looking for your file.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

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; false otherwise

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Hi jalpesh
Do you have any specific reason for suggestingSystem.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

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You can use the Formatter class, but even so I think it's simpler if you get that the way you want it then put it in a simple method yoiy can call every time you want to display a money value. (That also puts you in a good place if you want to change currency to (eg) Euros, with . as the thousands delimiter and , for the cents)

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You can usually hold money as an integer number of cents - very few applications ever neen to handle a fraction of cent. int will usually do, or long if you need amounts over 20 million dollars. If you write a simple method to take a value in cents and format it as a String with dollars and cents, dollar sign, commas etc then it's no harder than working in floating point dollars.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

First step is simply to do exactly what it told you to do:
Recompile with -Xlint:unchecked for details.
That will tell you what the unsafe or uchecked problem is, and exactly where it is. Then you can either update the code or add an annotation to allow the operation.