JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Yes, BaseContainer is declared as implementing Container, so all the methods from Container must be defined fully either in BaseContainer or in every non-abstract subclass of BaseContainer.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Remove the abstract keyword or you can make SquareBaseContainer an interface. By the way, SquareBaseContainer extends BaseContainer, which is also abstract. Remove the abstract keyword from there, too.

He has removed the abstract keyword from SquareBaseConstainer.
If he makes it an interface he definitely cannot instantiate it.
You can't remove the abstract keyword from BaseContainer because it has public abstract double getVolume()

when I take out the abstract part...I still get the error.

Exactly what error do you now get?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

SquareBaseContainer is abstract so you can't instantiate it. Eclipse is just following the Java language definition correctly.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

OK. Please mark this problem "solved" for the DaniWeb knowledge base (it's a particularly interesting little problem!). If you get new problems start a new thread.

ps: Many people dislike the style of having a single statement if block without the {} that you need for >1 statement. Interestingly, if had used {} then your code would have compiled, even after commenting out the code inside the {}.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Did that fix it?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Here's the code you posted

if (e.getKeyCode() == KeyEvent.VK_DOWN)
//down = true;
 
}

The problem with theis code is as I described.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Your problem may be with the immediately preceding if statement(s). Omitting the comments you have

if (some boolean expression)
}

but the language requires that a statement or block follows the boolean expression, even if it's only a solitary ;

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

The goal is to declare a Vector whose elements can be compared - ie that implement Comparable. The simplest form of that is

Vector<? extends Comparable<?>>

you can use that generic form to specify (eg) a parameter passed to a getSmallest method, and you will be able to use compareTo on the Vector's elements without needing to know the exact class of the elements, and without casting anything.
Because Comparable interface is also generic, this particular example of generics comes under the "advanced" heading - it's not easy to understand or get right first time.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Got more time now - so a better answer:
You are trying to create a Vector of Vectors, the "inner" Vectors representing individual rows. This means you MUST create a new Vector for each row. If you add the Vector for the first row, then clear its contents, you will lose the data for the first row.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

I would just create a new one for each line

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You can make it generic, ie able to work with any kind of object in the vector provided that the objects can be compared. If they can't be compared then the whole idea of this method doesn't apply to them. In Java you know objects can be compared because they implement the Comparable interface - which comprises the compareTo method. All the obvious classes such as String, Integer etc implement Comparable - you don't need to override compareTo because they already have it. Classes like Random don't, because it makes no sense.
In short, if you set up your generics right you can use compareTo directly on them to make the comparisons because you know whatever has been passed in has that method.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

First major mistake is this

catch(NullPointerException e)
{
}

Did you get an NPE when you ran your code? You don't know, and neither do we.
Before you do anything else fix this blunder by putting an e.printStackTrace() in the catch and run it again.

Either way - why are you trying to convert to String? You can't meaningfully compare arbitrary Objects by comparing their String representations - eg for Integers you will get a sort order like 1, 10, 11, 2, 3 etc, and for eg instances of the Random class it makes no sense whatsoever.
For meaningful results you should restrict your class to extend something like
Vector<? extends Comparable> so you know you can compare the objects directly

Finally, its a terrible idea to access Vector's protected implementation variables such as elementData. There is absolutely no guarantee that the next maintenance release of Java will not change those names, or even change the whole implementation. You can only rely on the public methods described in the JavaDoc.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You didn't declared it. just declare it in the main method

No no no. You haven't followed the whole conversation here.
The program needs one variable in the main method PLUS a local variable in the getPayment method. The original problem came from trying to pass the main method's var in as a parameter rather than creating a local var in getPayment.

BaldingEar commented: very helpful +0
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Just declare one in the method. You can use that for calculations and a return value, and java will forget it after the method is finished. That's called a local variable.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You just need to declare it as a local variable inside the method.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You pass the variable "payment" as the last parameter to that method, but you have never initialised(given a value to) payment before making the call.
Given tha the method is supposed to calculate payment, I can't see why you need to pass it as a parameter at all.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Did you read my post from 6 days ago? The one that starts "Looks like you keep adding all the data to the vector v, but you need to clear that down (or start a new vector) for each line."?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Hi bibiki.
What I'm not seeing here is any code to update the contents of the JTable when the database is updated. GUI methods like update or repaint won't achieve anything unless you change the data in the JTable first.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You can convert any double to an int anywhere you want by casting it (like in my previous example).
ps: A double can store values that have more precision than an int, or are larger than the largest possible int, so it's up to you to think about what the values are going to be and what result you expect from converting them.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

convert what to int?
you pass in two doubles and return one int. What is the relationship between the doubles and the returned value?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Here's an example of casting a double to int. You can use the same technique in your method

double d = 12.3;
int i = (int) d;
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Sorry, don't understand that question. Can you be more explicit?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Math.pow returns a double, but you can convert that to an int in your method and return the int, if that's what you want.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Your array of Shapes starts out containing 20 nulls which get replaced by Shapes when you add a new Shape. It looks like the var count contains the number of Shapes currently in the array, so that it what you need for the upper limit of your for loop - ie stop the loop before it goes into the null part of the array.
I can't see the code where you add a new Shape - shouldn't that be in the ButtonListener ?
What's the point of all the parameters on the constructor on line 21? You don't use any of them!

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

byte to char is a valid numeric promotion. The bottom 127 values of ASCII are the same as Unicode. Should be OK.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Just a question: since you are reading from an ASCII 1-byte-per-character stream, what's wrong with
char c = scan.nextByte();

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

A String contains many chars, so you need a method like charAt that allows you to specify which char you want. There's no general way to turn a whole String into one char - eg supposing there were such a method, what would you expect Character.parseChar("ABCDEF") to return?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

The String method charAt(int position) returns a single char, there's no conversion needed. What didn't you understand about Stevanity's posts?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Great! Mark this "solved" so other people can see the solution.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You may need to setFocusable(true); on your JPanel followed by requestFocus();

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

OK, good luck.
I'll check in on this tomorrow morning.
J.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

please tell me how

Use one of the "set" methods for DefaultTableModel. You can read about them in the API JavaDoc.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Here's the first

javax.swing.table.DefaultTableModel defaultTableModel = new javax.swing.table.DefaultTableModel();

and this creates a second new one for your JTable

Object rows[][] = { { "AMZN", "Amazon", "67 9/16" ,"DELETE","UPDATE"},
{ "AOL", "America Online", "68 3/4" ,"DELETE","UPDATE"},
{ "BOUT", "About.com", "56 3/8" ,"DELETE","UPDATE"},
{ "CDNW", "CDnow", "4 7/16" ,"DELETE","UPDATE"},
{ "DCLK", "DoubleClick", "87 3/16" ,"DELETE","UPDATE"},
{ "EBAY", "eBay", "180 7/8","DELETE","UPDATE" },
{ "EWBX", "EarthWeb", "18 1/4" ,"DELETE","UPDATE"},
{ "MKTW", "MarketWatch", "29" ,"DELETE","UPDATE"},
{ "TGLO", "Theglobe.com", "4 15/16" ,"DELETE","UPDATE"},
{ "YHOO", "Yahoo!", "151 1/8" ,"DELETE","UPDATE"} };
Object columns[] = {"Sr.no", "Book Title", "Author Name", "Delete", "Edit"};
JTable table = new JTable(rows, columns);

You need to put all that data into defaultTableModel then do a

jTable1.setModel(defaultTableModel);
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You still have two models. You need to put all that data into defaultTableModel

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Please read my first post. You have two table models in your program. You should have only one. The data is is the one you display, but you try to remove from the other one, which has no data.
Norm - I don't know how to make this clearer - can you help?

sohiabmaroof commented: 1 +1
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Yes, well, I didn't see any code to put any data in defaultTableModel, so I'm not surprised that trying to delete a row gives an error.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

This is very confusing.
You create a model called defaultTableModel and have lots of code that works with this model, but the model that's actually in the JTable (at least until line 51) is the completely different one whose definition begins

(new javax.swing.table.DefaultTableModel(
   new Object [][] {
    {"asdf",
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

After that input you call the method at line 30 which will drop thru to the while at line 47. Which is a very interesting loop
while (tallPosisjon <= famousFinalFour.length())
neither tallPosisjon nor famousFinalFour seems to change inside the loop, which means if it executes right thru once it will loop infinitely - isn't that your symptom?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

GridBagLayout is the daddy of them all, but has a steep learning curve and gets quite verbose (thanks to all the options). However, I think it's the ultimate tool in the Swing expert's toolbox, so it's worth the effort.
Having said that, it's often easier just to nest JPanels with an assortment of simple layout managers (border & grid mainly).

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

I personally have no idea, but I Googled java steganography and got 612,000 hits. Looks like lots of info and code out there if you just look for it.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

args is declared in your code, but it is inialised at run time with copies of the arguments that were entered on the command line. If there were no arguments it's initialised to an array of length zero (not null, just an empty array). So an attempt to reference the first element of the array [0] is an index out of bounds error.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Did you mean BigDecimal? That would certainly be an appropriate class for currency.

mKorbel commented: correct +9
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

P.S. I tried using changeLeft -= billBack10 * TEN_DOLLAR; but when it calculated 10.35 - 10 the result was 0.3499999999999.
This resulted in a missing penny at the end. (Probably the same error is in that sample code you found).

This kind of thing is inevitable when using float/double, and often results in all kinds of ad-hoc rounding that cannot be proved to work 100% of the time. Best solution is to hold all the monetary amounts as integer cents.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Have you upgraded to Java 7 yet? If so, JLayer may be what you're looking for...
http://download.oracle.com/javase/tutorial/uiswing/misc/jlayer.html

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Time for a reality check.
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 coding your homework for you. Bumping your own thread and sending PMs is not going to encourage anyone to help. Just re-read what you posted earlier:

I need to get started on my AP English homework soon. Please respond with a fix to the code, and not just hints. I'm not good with hints.

Nobody speaks to me like that, so you can finish this one without me.

CoolPrizes commented: Post is not helpful. Please go improve your attitude. -1
Ezzaral commented: No reason for a red mark from a brat with a sense of entitlement. +15
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Looks like you keep adding all the data to the vector v, but you need to clear that down (or start a new vector) for each line.
Also you are creating the table inside your read loop, so you create new one each time ou read a line, but you should do this just once, after the loop

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

1. You should know better by now. It's not good enough to say "i have an error" - you must post the full error meswsage.
Anyway, you have 2 constructors that take a String as the only parameter, so there's no way for Java to tell which to use (the fact that you gave the parameters different names is of no help), so it's an error.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

This tutorial teaches you how to print anything that you display in a JFrame
http://www.apl.jhu.edu/~hall/java/Swing-Tutorial/Swing-Tutorial-Printing.html

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

A Vector is like an array, except that it starts out with size 0, and grows to fit the data you put into it - you just keep using its add method.
You can also have a Vector whose elements are also Vectors - like a 2 D array. JTable has a constructor that takes a Vector of Vectors as a parameter to supply all the data in the table. Each "outer" Vector represents on row, and the "inner" Vectors have the individual cell values for that row.
So instead of reading your data into an array, read each line and and add it to a new Vector<String>, then add that Vector to a Vector<Vector<String>> which you can pass directly to JTable.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

1. Forget about some crummy buggy thing you found on the net.
2. You are nearly there. On line 35 you work out how many 20's, but then you need to subtract that from the balance remaining.