javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Well if it is says that is missing a return statement, then it's missing a return a statement. The problem is exactly that, it is missing a 'return'. You are supposed to know how to create methods:

public [B]Lot[/B] removeLot(int number)

In the way you have created it, you must return a Lot object. So either return one or change the method.

Call the methods of the Lot object. Based on what they return determine whether it is sold or not. Use if statements. If you look at the toString method of the Lot object you will understand which method to use and what is the rule. It is also described at your requirements.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

The print method is a pre-defined method in Java. There is the println() method and the print() method. This is a static method of the PrintWriter class. Its better if you change the name of that method and try. If you have to use print() method compulsorily then you have to override that method.

Completely useless information and confusing. Are you really suggesting that he overrides the method of the PrintWriter class????
Or are you saying the name is the problem? That is completely wrong.
And there is NO pre-defined print method in java.
Different classes have print methods, but there is no confusing since in order to call them, you need an instance of their classes.

System.out.println() calls the print method of the System.out PrintStream instance

Don't let this guy confuse you gaya88.

BestJewSinceJC commented: thannnk you. well said. +4
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

You do know how to create methods, don't you?
The answer is easy everything has been given to you and most of the suggestions here will repeat what the assignment says to do:

a. Add a close method to the auction class. This should iterate over the collection of lots and print out details of all the lots. You may use a “for each” or “while” loop and any lot that has had at least one bid is considered sold. For lots that have been sold, the details should include the name of the successful bidder, and the value of the winning bid. For lots that have not been sold, print a message indicating this fact.

Just create method that does what it says. Check the java.util.ArrayList class. Iterate the lots (ArrayList) (for loop) and print them. The description also says when a lot is considered sold, and what to do with it.
Now if you don't know how to call methods or a write a for-loop then that is up to you to find out.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

do i still need to add the if function to it?

I don't understand. Post your new code. Also, are you allowed to use the Vector or the ArrayList class?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

3. Modifying data of selective item.

For modifying I suggest that once you call the findItem method, to ask the user for new data from the keyboard and change the item found:

System.out.println("Item found:");
System.out.print(Inventory[i]);
// ask for new data
inventory[i].set...();

return;

4. Deleting existing items.

After you search for the item you want to delete you can set that item to null:

inventory[i] = null;
noOfItems--;

That will change all you implementation of course. Your array will have gaps between the elements with null values.

So when you add instead of simply increasing noOfItems and using it as index, you can loop the array and whenever you find a null value, insert the new item to that spot and increase the noOfItems. Remember that when you initialize the array all its elements are null.

At the findItem method you can have your search to be like this:

if ( (inventory[i]!=null) && (item_name.equalsIgnoreCase(inventory[i].getItem_name()))
)

For counting items and printing them you can print only those that are not null:

System.out.println("Num of items:"+noOfItems);
for(int i=0; i< noOfItems; i++) {
  if (inventory[i]!=null) System.out.println(inventory[i]);
}

For 5 and 6, you need to redesign your class and change your whole implementation:

public class item {

private String item_name;
private String barcode;
private double price;
private int quantity = 0;

public void sellItem() {
  quantity--;
}

public void buyItem() {
   quantity++;
}

public boolean isAvailable() {
  return quantity>0;
}
}

That would mean that whenever you add an …

linx311 commented: brilliant post! great help! lots of info too +0
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Since the print just prints the month and total of the class and you already have those values in your class and you call it with parameters those values, shouldn't you be doing this:

void print() {
	System.out.println("Your bill for month "+month+" is "+total);
}

Inside the class?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

After reading the post, I realized, that everything has been given to you with plenty of explanation and you had to write only one method.
The method signature has also been given as well what you must do, what classes to use, what those do and how to use them.
I don't understand what more we can do apart from writing the code for you, which we won't, Because:
1) That is not what we do here.
2) You haven't provided any useful information, so we can give you some hints.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

ei guyz, i am new in java world, i knew some but i can't understand the some of them...

can you help me to do the atm program,?
can you share the codes??

thanks a lot..

Create a class for Account. (name, pin, balance, ...) with methods.
Create a class Bank with a list of Accounts.
Create a menu with options.
Show what you have done so far.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

[This is a multi-post; I thank you people for the attention]

hi

How could I show a database datetime field (like mm/dd/yyyy) on a JTextField?

regards

2 ways:
> Read it from the database using: ResultSet.getDate(), and store that value into a java.util.Date object. Then use java.text.SimpleDateFormat

> Read it as text from the query and then just display it:

select to_char(date_column,'DD/MM/YYYY HH24:MI:SS'), other_columns
from ....

You can use whatever format you want. Then read that column using ResultSet.getString()

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

I couldn't understand what your problem is so I tried to run it.
It asked me to enter some numbers, but once I entered the first number, it exited without asking for more.

It is because you call this: input = JOptionPane.showInputDialog(null,GET_NUMS,null,JOptionPane.QUESTION_MESSAGE); only once outside the while loop.
Now since you already make that call once, and you enter the loop with input having value, I would suggest that you put it at the end of the loop:

while (goodNum && counter < seriesLength)
{



input = JOptionPane.showInputDialog(null,GET_NUMS,null,JOptionPane.QUESTION_MESSAGE);
} 		// end while goodNum and counter < length

Also , if you run it now you will see that it always displays the lowest to be 0 and the max the last number entered.
It is because:
> you initialize the lowest with 0
> You have those checks outside the loop.

You need to put these checks inside the loop and initialize those variables with the initial input:

while (seriesLength <0 || input.equals(""))
{      
            seriesLength = Double.parseDouble(JOptionPane.showInputDialog(null,SERIES_REQUEST,null,
               											JOptionPane.QUESTION_MESSAGE)); // gets input from user
																      
            input = JOptionPane.showInputDialog(null,GET_NUMS,null,JOptionPane.QUESTION_MESSAGE); // gets input from user
}

largest=inputNum;
smallest=inputNum;

while (goodNum && counter < seriesLength)
{



input = JOptionPane.showInputDialog(null,GET_NUMS,null,JOptionPane.QUESTION_MESSAGE);
} 		// end while goodNum and counter < length
BestJewSinceJC commented: :) lot of effort to help this kid. +4
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

BTW, that was not meant to be knock on you, or anything, so I hope you didn't take it that way. ;-)

Don't worry. I am always interested in learning new different ways to do things.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Actually I don't do

public class Frame extends JFrame implements ActionListener

but not for the reasons posted by you. ;-)

I try not to extend the Swing classes, at all unless I specifically need to alter their behaviour, which I almost never do. I prefer composition to extension in Swing (and many other areas). I also do not have the "component" class implement the listeners as I feel this (and the previous point) is a single class doing too many things, and as being responsible for too much. It is also (in both points) very bad in terms of MVC separation, as it will probably being doing at least a bit of all of it.

For some simple one-off "small" application, say a MineSweeper or something, go ahead and have at it, otherwise ....

Ok.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

I want to design utorrent client for my semester project in java, can anyone tell me where should i start and what are the necessary steps for this, also if any useful website and information. Thank you.

The link provided the necessary steps you needed to start. Since it is for your semester it is assumed that you are familiar with java and you can at least start with a simple code so you can post it in order to get more help.

But don't expect an experienced to waste time to the searching for you.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

I just read balmark's code because all those comments got me curious.
What the buck was that???
I mean seriously can this code be characterized simple or efficient or any useful at all. Why would anyone do this?
I see two classes, one extends JButton and the other implements ActionListener. And the way one is instantiated using the others reference is, I don't know.

I mean no one does this anymore?

public class Frame extends JFrame implements ActionListener {
   JButton butt = new JButton("aaaa");

   ....
   butt.addActionListener(this);

   ....
   
   public void actionPerformed(ActionEvent ae) {
      ....
   }
}

Why extend JButton if the only thing you will do is pass an ActionListener as a parameter, when you can "add" it directly to the JButton itself. And why implement ActionListener as a seperate class, since it is an interface and a class can implement as many interfaces as you want? Or you can have an inner class implement ActionListener.

Now if you say that I am out of topic because the issue here was inner classes, then so is the code posted by balmark, which like I said, I can't seem to understand its usefulness.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

who needs a method to tell you value types if you know about overloading methods or instanceof etc.

instanceof will not work on primitive types, but this will:

public void test(Object obj){
  System.out.println(obj.getClass());
}

Which is the same answer like the one that was already given.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

ok dude it has a lot of syntax error . .
just use an IDE to figure out what is the error of your code. Because it's so hard to figure out when you compiled it in the cmd

It doesn't make any difference whether it is compiled using a IDE or a command prompt.
They do the same thing:
> The IDE will point in the code where the error is. So does the command prompt. The error message specifies the file and line where the error happened
> The IDE has a short message of the error. So does the command prompt. It has a mesage as what went wrong and sometimes it says what is needed fixing.

Now if you or the poster are too lazy to read the error messages at the command prompt because you like better the pretty colors of an IDE that is something else.


So my suggestion is:
DifficultUsrnme If you get error messages, the READ them. They explain the error and show the line. Of course if some errors are too difficult of course post them, but I doubt that all 41 errors are impossible.
If they are, try to copy paste them here. Right click on the command prompt to open a small dialog box that will help you copy them

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster
public void test(Object obj){
 if(obj instanceof String){
   System.out.println("Obj is a String, I can cast it to a string and use its methods eg.");
   System.out.println("The Strings length: "+ ((String)obj).length());
 }
}

you can also just overload methods, so the correct one gets called eg.

public void test(String obj){
  System.out.println("obj is a string");
}
public void test(Integer obj){
  System.out.println("obj is an Integer");
}
public void test(Object obj){
  System.out.println("obj is not a string or integer, it is a "+obj.getClass());
}

public void runtest(){
  Integer in = new Integer(4);
  String str = "Hi";
  Double d = new Double(55);

  test(in);
  test(str);
  test(d);
}

That is not what avinash_545 has asked. He wanted to do that with primitive types (int, float). Not Integer, Double. And even though your code "accidentally" does that, it has already been answered.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Never mind I found it. I usually come up with solution after I make posts that ask for more information.

Anyway, you need a way to find the type of a variable. As BestJewSinceJC has mentioned you can do this:

Object.getClass().getName();

But he said that will not work with primitives. Actually with a small trick, it will:

public String [B]type[/B](Object obj) {
   return obj.getClass().getName();
}

Now try to call it like this and see what happens:

Integer intgr = new Integer(10);
int i = 5;

System.out.println(intgr + " is: "+[B]type[/B](intgr));
System.out.println(i + " is: "+[B]type[/B](i));
stephen84s commented: Autoboxing, but honestly your post could be more clear on the fundamentals the solution uses. +5
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

hi everybody!!!!!!!
can anyone tell me how do we test the data type of variables in java, like if a variable is a string, the system prints out that this variable is string or not.
more especially how can we test this on primitive data type?

waiting for your replies!!!

Can you post the exact description of your problem? What are trying to accomplish and what have you been asked to do?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

i need the program for word frequency by word length

Start a new thread and don't expect someone to give you the code unless you show some effort.
Also explain better you problem.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Didn't you start an identical thread? Double threading will not get you anywhere

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

CODE TAGS. Use them. Read the rules.

Just click the button that says "CODE" when you make a post.
And when you submitted your post didn't see how it was posted? Did that seem readable to you?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

give me the sample output that you want to be output

It has been 2 years since the last post. You think that the OP was waiting for you?
If you really want to help someone then why don't you try the most recent posts?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Don't worry about the down voting. It is a system recently implemented in order to improve the forum.

But many people miss use it:
You will find entire threads of people complaining about how their perfectly good posts got down voted for no reason whatsoever by persons unknown.
I mean, I had a correct post that was written many months before they added that "voting system" and some days after the "Voting system" was added to this forum; I got down voted; my many months old thread!

So expect this to happen. It has happened to other posters that are much better than you and me

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Part of the exception was this:

at fileIOPKG.FileIO.getNextInt(FileIO.java:34)

Now you know at which java file and line the error occured. waht are you calling there. Are you entering correct data form the keyboard?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

how to store the retrived data from database into th especified text field

The answer is very simple and easy. It is one of the very first things you learn when someone starts with jsp. Which is why I believe that you rushed into writing JSPs before giving some time to do some serious studying.

So the answer is this:

String data = ....
...
value='<%= date%>'

If you can't understand the above you need to take some time to sudy on your own and come back with more specific questions.
If you already know the above again: ask more specific questions.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

There are plenty of examles in this forum and at the java forum on how to connect to the database and execute queries.
So submit the data you want, get them with request.getParameter() and save them to the database

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

If you take into account some of the natural disasters that have happened recently, it is possible that a city located at a not so safe location be sunk underwater.

Imagine what would have happened if a hurricane like Catrina or a tsunami hit Venice for example.

Given the lack of recording and transportation methods they had at those ancient times, it is quite easy such an incident at an isolated city to be forgotten and after many years tales of that place to become what today we call myths.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Ok, so I was getting my daily dose of Stargate Atlantis then in the final episode atlantis lands in the atlantic ocean.

What is amazing is that you watched that show!

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Of course you have to declare everything before you use it. Java is similar to C++.
I don't remember if it has Objects. I think it does. Anyway, when you said that you got that java code, I assumed that it worked and it was well written, meaning that all variables were declared.

As far as their types you need to look at the code and see how they are used. For example, of course the gameOver is boolean since the code says: gameOver = false; at some point.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

I don't see any difficult stuff that would get you confused: System.out.println() is used to print whatever you pass as argument and then changes line. The '+' symbol, when applied to String, concatenates:

var1 = 5;
var1 = 10;
"aaaa" + var1 -> aaaa5
"aaaa " + (var1 + var2) + " bbbbb" -> aaaa 15 bbbbb
"aaaa " + var1 + var2 + " bbbbb" -> aaaa 510 bbbbb

Math.random() : Generates a random double number between [0,1)

And the keyboard.next() probably reads from the input.
Also if you are unfamiliar with java but know C, then you can read that program try to understand what it does and how the algorithm works and write one in C. You don't have to copy and replace every single line and command from java to C. It cannot be done

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

You are right it doesn't make any sense.
I was saying,

> If he wanted to read the integer contents of the file to use the Scanner. I think that if the file doesn't contain text, you cannot use the Scanner class to read it. I don't know about the last one.

> If he wanted to read the bytes of the file no matter what is the file type use the FileInputStream.

I also believe/think that if a file contains numbers, then you will get different results if you try to read those numbers with Scanner and if you try to read the bytes of the file with FileInputStream

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

You've said about 100 times in this thread that you want to read in an integer. Now you're changing your mind and saying you want to read in binary?

It doesn't matter how Scanner interprets something correctly, it just does. By worrying about the underlying implementation when you want to accomplish a specific task, you're wasting your time. Just read the documentation. Scanner tells you it knows how to read in ints, chars, Strings, etc, and that is all that matters. Ex: this code will read in all the integers from a file.

Scanner input = new Scanner(new File("your exact file path goes here"));
while(input.hasNext()){
if (input.hasNextInt()){
System.out.println(input.nextInt());
} else System.out.println(input.next());
}

From his latest post I understood that miles.85 wanted to print the bytes of the file, that is why I suggested that class. Anyway both solutions are correct and it's up to miles.85 to choose what he want.
To read only integer the contents of the file with Scanner or the bytes of the file, no matter what file it is.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Then you need to take a look at the FileInputStream class

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

The way I see it, first you need to create the file and fill it with data. Then try to read it. The tricky part would be to figure out the format of the file. For example if you want to represent a crewman's data you can do this:

Crewman,personName,pid,year,month,day,

After you read this line use String.split(",") method and create a Crewman instance with the above data.
But since there would be many spaceships with many crewmen, you might want to try a more tree structure approach for your file:

The number 5 is the number of SpaceShips and the 10 the number of crewmen

5
<SpaceShip>
spaceShipName
<Crewman>
10
Crewman,personName,pid,year,month,day,
Crewman,personName,pid,year,month,day,
Crewman,personName,pid,year,month,day,
.......
</Crewman>
year,month,day, // registration date
engineName
Captain,personName,pid,year,month,day,
</SpaceShip>
.....
<SpaceShip>
....
</SpaceShip>

I tried to keep it simple and not confuse you with xml. The more appropriate way would be this:

<SpacePort>
<NumOfSpaceShips>5</NumOfSpaceShips>
<SpaceShip>
<SpaceShipName>uss177</SpaceShipName>
<SpaceShipType>Enterprise</SpaceShipType>
<Crewmen>
<NumOfCrewmen>10</NumOfCrewmen>
<Crewman>
<name>Data</name>
<pid>01010101</pid>
<year>0</year>
<month>0</month>
<day>0</day>
</Crewman>
<Crewman>
.....
</Crewman>
.....
</Crewmen>
<RegistrationDate>
<year>2555</year>
<month>12</month>
<day>26</day>
</RegistrationDate>
<EngineName>engine</EngineName>
<EngineType>warp</EngineType>
<captain>
<name>Picard</name>
<pid>112112</pid>
<year>2500</year>
<month>12</month>
<day>21</day>
</captain>
</SpaceShip>
.....


<SpacePort>

If you don't want to mess with xml parsers, you can try and write a program with lots of ifs statement were you read the file line by line and …

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

You get that error not because the Scanner class is not working, but because your code doesn't compile.
Have even tried to read that error message:?

The local variable a may not have been initialized

Ana.java:15

Now what do you need to do in order to fix that?

It is important what is the file type. Even if its extension isn't .txt, if it contains text like this:
10010101011010101010101010101011000011110............
then the Scanner can read it. Scanner.nextLine. Check the Scanner's class API

Then just read the first line as String. Then use substring to get any number of bits from that line:
1001 or 10010101 and use the Integer class in order to convert that into decimal. Check the Integer's class API

Also when you say that you want the above to be converted into binary doesn't make any sense since it is already in binary.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Have you tried setting the autocommit to false. If you don't even if you had the connection, the rollback wouldn't work.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

In order to tell you how to logout, you need to tell us how you login. When the user enters the username and logs in successfully, what do you do afterwords?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Of course it returns false, since you do this:

<% 
boolean isCkecked = false;
%>
.....

<%
session.setAttribute("isCkecked",isCkecked); 
%>

The isCkecked is declared false. Then you pass its value which is false at the session.

This:

<input type="radio" name="code1" value="1"   onclick="<%isCkecked = true;%>"

Will not do what you think it does. Every time you run it the value of isCkecked will ALWAYS BE TRUE, because this: isCkecked = true; is executed before the page loads. It doesn't display anything at the page.

When it loads the isCkecked is already true and nothing can change its value. When the page loads the html code that will be rendered is this:

<input type="radio" name="code1" value="1"   onclick=""

This: <%isCkecked = true;%> just executes this code: isCkecked = true; before the page loads

Whenever you click the radio button you CANNOT change the value of any java variable. The java code is executed at the server and javascript is executed at the client. The onlclick executes javascript code and whatever you write there doesn't change any java values.

What you need is to submit a form with the radio button, take the value with request.getParameter, do whatever you want and then redirect back to the page.

This:

<% 
boolean isCkecked = true;
%>

<input type="radio" name="code1" value="1" <%=(isCkecked)?"checked":"" %>   >

First the isCkecked becomes true.
Then this is executed: (isCkecked)?"checked":"" and the result is the String checked.
Then the page loads like this: <input type="radio" name="code1" value="1" [B]checked[/B] >

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

If you have read the assigment more carefully you would have seen that it says to use the classes:
FileInputStream and DataInputStream
Check their API.

You will create a FileInputStream instance with the file as argument and the you will create a DataInputStream instance with the previous FileInputStream instance as argument at the constructor. Don't be bothered that DataInputStream takes as parameter a InputStream, FileInputStream extends that class.

Then by using the readInt method of the DataInputStream you can read the int numbers that you want.

Also there is a method that DataInputStream inherites:

public int available()
throws IOException
Returns the number of bytes that can be read from this input stream without blocking.

Every time you call that it returns how many bytes are left to read. Don't worry that you are using the readInt method, the available will do its work.

So inside a while loop, you can read one int after the other with each loop. Use the available method to determine when the while loop will stop:

while (HAS AVAILABLE BYTES) {
   int i = dataInputStream.readInt(); 
}

My problem is that if you use the above, you will read integers in a sequence, but you said that want to know the int that is found at a specific coordinates.
Maybe you will read the enitre file and write its contents into an array so you can reuse it, but for that I didn't find any information.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

The program doesn't work because you haven't followed ny instructions:

public class ShapesPanel extends JPanel implements ActionListener {
  public ShapesPanel() {
      ....
      circle.addActionListener (this);
      square.addActionListener (this);
  }  


public void actionPerformed (ActionEvent event)
      { 	
		  		if (event.getSource() == circle)
        	 	{
..
				}
				
         	else
				{
				..
				}  
      }
}

ShapesPanel is the one that implements the ActionListener and that is the one that needs to implement the actionPerformed method and that class ( this ) would be the input to the addActionListener.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Chaeck this site:
http://www.w3schools.com/default.asp
Find the attributes of the radio button at the html tutorials or the html references where all the tags and their attributes are listed.

boolean isCkecked = ....;
<input type="radio" name="code1" value="1"  <%= (isCkecked )?"checked":"" %> />

I am almost certain the "checked" is the right thing to use but better check the site as well

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Thanks for the reply I'm just worried that I'm not understanding the problem maybe I'm over thinking it. Did I do this project correctly by eliminating the infinity, NaN answers for dividing an integer by zero? Thanks

Well I didn't test it thoroughly, so when you get the errors, what input do you enter, does it display and what do you want it to display?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

I executed your code and it works.

What is your problem?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Look how you have defined the draw method in your Circle class, and how you are calling it.

About the "square1" error you have declared it correctly at the ShapesPanel class but you are using inside the private ButtonListener class.
Maybe you should do this:

public class ShapesPanel extends JPanel implements ActionListener {
  public ShapesPanel() {
      ....
      circle.addActionListener (this);
      square.addActionListener (this);
  }  


public void actionPerformed (ActionEvent event)
      { 	
		  		if (event.getSource() == circle)
        	 	{
			   	circle1.draw();
					circle2.draw();
				}
				
         	else
				{
					square1.draw();
					square2.draw();
				}  
      }
}
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Can you post your complete assignment?

Usually for these kind of exercises, you read the file into an object (2D array) and then you can access the data, or read them directly from the file.
But the file as you know doesn't have integers inside it. From what I see it contains binary data inside, so maybe that is what your teacher wants. To read the bytes of the file the FileInputStream class is used.

Knowing the complete description of your requirements will help me help you.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

You need to better explain your problem. You say that:
"I am getting the data from Ms-sql for 3 combos". If you have read the data for those combo boxes just display them.

Or are you reading the elements of the combo boxes from the database.
When you select a value at the first 2 combos, what are your requirements regarding how the 3rd combo would be displayed

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Can you try this and tell me what it prints?

try {
        FileInputStream fis = new FileInputStream("filename");
        ObjectInputStream ois = new ObjectInputStream(fis);
   
        Object obj = ois.readObject();

         System.out.println(obj.getClass());

        ois.close();
} catch (Exception e) {
  System.out.println("Error: "+e.getMessage());
}

Also I would like to know the complete assignment description

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

The file is exist of course. javaAddict I don't understand what you mean with " D:\\A.txt has integers inside it" because the file is about 60 kb. So when I read an integer, it reads two bytes from file. So it is not possible to tell me that there is no integer. Am I right ? I mean FileReader I know that can not understand if the next argument is an integer or character... When we write integer it reads two bytes and for character reads 4 bytes... And it look for bits integer 8x2=16 bits for integer example: 0000..000011 = 3.

Actually no.
You are using the Scanner class. When you call the nextInt method, it reads an integer:
File Contents:

1 2 33

It does not read the bytes of the file.
If you want to read the bytes of the file use a different class.
If you want to read the entire line as String use the nextLine method.
Every file (.avi files, image files) can have their contents represented in bytes.
But the method you are using doesn't read bytes. It expects to find integers.

What is the format of your file and what do you want to?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

After a lot of search, I found the problem. I forgot the DVD with the drivers inside the PC. So after the installation, when it rebooted, it rebooted from the DVD.

After I removed the disc and restarted my computer, it worked OK.