javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

The error is simple, it cannot find the cinstructor you are using:
"cannot find symbol constructor Plane (int,int,int,int,int,int,java.awt.Image, java.applet.AudioClip, Player)"

Meaning that the constructor you are using doesn't exist. I haven't looked at your code, but the arguments you enter at the constructor must much the ones that are declared at the class definition.
It is like having a constructor like this:

public ConA(String a, int b) {

}

And try to call it like this:

ConA cA = new ConA(1, 2, 3, "aaaa");

That constructor doesn't exist because the constructor takes as argumnents a String and an int.

So what arguments does the Plane constructor takes and use those.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

I was just trying to stem any confusion. I think we can all drop this topic, doesn't look like the starter is interested.

Agree

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

really? do you like it (both code geass and anime in general?) how many other series have you seen?

I have noticed this thread about anime and since I am also a fan I would like to answer that I have seen in total about 95 anime.
Starting form Astroboy (1960) and the latest I am waiting to see is Gumdam Igloo

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Try using the whole path of the file

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Where exactly do you get those exceptions. A FileNotFoundException means exactly that; the file you are trying to access doesn't exist.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

>Create variables to hold how many times each value occured:

int countOf2s = 0;
int countOf3s = 0;
...

>Create a method that returns a random number from 1 to 6
> inside a for loop (it will be executed 12000) call the above methods 2 times, add their results and depending on the outcome increase by 1 the appropriate variable
> the loop will be repeated and in the end will have the number of occurences stored at the variables
> print those variables

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

This is a 6-month old thread. It is better if you didn't get your answer here to start a new thread.

Also this thread has already enough piece of code to get you started. Start a new Thread with some real questions. People might get the wrong idea with the way you asked for help.
Ask specific questions after showing some code of yours

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

I didn't quite understood what you really want because I think it is very simple:

Vector v = new Vector();
v.add("4 2 5 3 6 0");

or

Vector v = new Vector();
v.add("4,2");
v.add("5,3");
v.add("6,0");

or insert them in any format you like

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

i thought that arrays start at index 0 so thats why i put 999

Yes they do start at 0 but when you do this:
String [] array = new String[999];

You say that the array has length 999 and indexes from 0 to 998

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Your input method seems correct but there are a few things you need to add:

public static void Input(String [] composer, String [] piece)
    {
        int i = 0;
        while( i<composer.length )
        {  
                String comp = JOptionPane.showInputDialog("input composer");
                 if (comp.equals("q"))  {
                       break;  
               } else {
                       composer [i] = comp;
                       piece [i] = JOptionPane.showInputDialog("input piece");
                        i = i+1;
               }
        }
        SortA(composer,piece, i);
    }

The if-statement is used so in case the user enters "q" not to insert that at the arrays.

With the previous code you would never exit the while:
The user enters "q", you put that at the array: composer [i] = JOptionPane.showInputDialog("input composer"); But then you increase the "i" so at the while loop you do not check the current composer entered, but the next element, which is null. Also you do not check the length of the array. If the user continues to enter values the "i" will exceed the length of the array.

That's why the loop has the condition: i<composer.length so not to exceed the limit and if the user enters "q" you call the "break" command which exits the loop.
Also you will need to pass the "i" variable at the sort method, because you don't want to sort the entire array but only the elements given. In the sort method you will use as upper limit the "i" not the length of the array.

Also use this: for (int j = 0; j<composer.length; j++) at the for-loops …

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Can't you use the Vector argument by reference ? :

Vector v = new Vector();
method(v);
System.out.println(v.get(0));

void method(Vector v) {
  v.add("1234");
}

Maybe it cannot be done since I don't know how JME really works or how you have written your code

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

I don't know if this suggestion applies to your problem, but you can try this:

Have the class implement the Comparable interface:

public class ContactListLabel implements  Comparable<ContactListLabel > {

public int compareTo(ContactListLabel label) {
  return nameLabel.compareTo(label.getNameLabel());
}
}

When you get the Contacts from RMS and store them in ContactListLabel objects, can you put them in an array instead of a Vector?
If you can, you can use this: Arrays.sort(Object[] a) to do the sorting.
Or after you have the Vector with all the Contacts put them in an array and sort them with the above method.

Again, I have never used JME and I don't know if you can use this solution, but if sorting is your only problem then it is not very difficult to simplify your solution

----------------------------------------------------------------------------

Another thing you can do is sort them the moment you get them from RMS:

> get contact from RMS
> search the Vector with the objects using the nameLabel and find at which index it needs to be inserted
> do the insertion at the index found.

That way you don't need to call the sort method.

If the Vector has, for example, elements:
"a", "b", "d"

And you get the "c" you will search the Vector to find where the "c" needs to be inserted:
if ("c"<"d") put it where the "d" is, and the "d" will automatically …

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

The setText method does exactly what it says; it SETs the text of the TextArea. So The TextArea will have whatever value you put as argument.

You can either, create a String with all the values and then set that String
OR BETTER:
Use the append method of the TextArea.

Check the API of JTextArea for that method and replace the textArea method with that.

Also next time when you are using a method that doesn't do what you want, check the API of the class

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

yes i have ran it and it works fine .
thanks for improving my code .well i knew it could also have been done in a shorter way than i did , its just that i wanted to be very comfortable with wat i was coding with .

Well, you are correct. first write something that works and then see if you know how to improve it

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Try "right" clicking on the file and select "Properties". You will find the exact location and file name to use at your code

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

You could try this without using the "l","l1" int variables

public class NewClass {
 public static void main (String [] args)
 {
     String str1 = new String("madame");
     boolean b = true ;
     char c1,c2;
     int length = str1.length();
     for ( int i=0;i<(length/2); i++)
     {
         c1 = str1.charAt(i);
         c2 = str1.charAt(length-1 -i);
             if(c1 != c2)
             {      System.out.println("not a palindrome");
                 b = false ; 
                  break;  
             }
     }
 if(b == true)
       System.out.println(" palindrome");
 }
}

Also I think that your original code was correct. Have you tested it?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Use a for loop that multiplies the "i" index with the result.
Like when you calculate the sum of a list of numbers

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

You can have the variable be "global". Here are 2 examples:

class ClassA {
public int variableA = 0;

public ClassA() {

}

public void method() {
   variableA = 2;
}
}
class ClassB {
public ClassB() {

}

public void methodB() {
  ClassA clA = new ClassA();
  clA.method();

  System.out.println(clA.variableA ):
}
}

If you have a variable declared in a method you cannot access it from outside that method because it is out of scope. You need to declare it inside the class. If you declare it "private" you will need a "get" method in order to return its value.
Now if you want to access it from another class you will need of course to create an instance of the class: "ClassA" and call the method that changes its value.

But things are different when you declare it static:

class ClassA {
public static int variableA = 0;

public static void method() {
   variableA = 2;
}
}
class ClassB {
public ClassB() {

}

public void methodB() {
  ClassA.method();

  System.out.println(ClassA.variableA):
}
}
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Alot of information has been given and you should be able to get it working. just do some trial and error that is the best way with programming.

also you can use
BufferedReader to get the users input that is how we were taught at uni.
check the internet there are lots of examples for it. please let us know how you get on

I believe that his problem is printing what is asked based on the "name" input. Trying to get the "name" input using BufferedReader will not help much since he cannot do the simpler things.

So I suggest first to try to get the program work with some fixed value and then decide how to get the input

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Have you tested your code?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

We already know what factorials are and how to compute them. But thanks anyway for the tip

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

buh i have no idea in how 2 do this??

We can only show you the door; you are the one that has to go through it

Meaning that we have already told you which methods to use and how. You need to think the way. You already know the commands. Only the System.out. ..... and the for-loop which was explained are needed. Coding it is easy. But you need to think how to use the commands, we cannot post the solution, just use the command to print what is required.

Also, at first if you don't know how to read the input try using the:
> argument array of the main:
> public static void main (String [] args)

Or put a value to a variable and try work with it

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

The number of characters (* or space) is determined by the length of the name entered (hint: use String length method). Remember that you have to add 2 to this length in order to take into account the space either side of the name.

Also don't forget to add 2 as stated above, and you will need to play with the methods:

System.out.println();
System.out.print();

As I said, one changes line the other doesn't. So decide which one goes inside the loop and which doesn't in order to have this result:

/***********\

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Obviously instead of 3 you will have the number of '*' you want to print.
And in the for-loop use the method:

System.out.print("");

The above method doesn't change line.
Of course when the loop is done remember to call the one that changes line in order to continue writing at the next line.

Also you can call this with no arguments:

System.out.println();
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Even if you do come up with an algorithm for that you will still need to make some comparison.So why don't you try this:

public int max(int a, int b, int c) {
  if ((a>=b)&&(a>=c)) {
    return a;
 }
if ((b>=a)&&(b>=c)) {
    return b;
 }
return c;
}

You cannot overload these : "+", "-", "*", "/" in java. You need to write your own functions that do what you want.
I would suggest to try the C# forum

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

I don't believe there is a class that does what you want.

Also I checked the Time class and I don't believe it is what you want. It is used with sql and it represents time like saying now the time is:
"16:05"

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

You might want to create your own class.

The classes Date and Time are used to store what the say: Date and Time.
You need to store duration. (duration of race)
You cannot say that a swimmer swimmed for 'Date' object time.

But you can say this:He started swimming at Date start = new Date() and finished at Date finish = new Date() And their difference is the time he made in milliseconds: long time = end.getTime() - start.getTime()

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster
<form name="theForm" method="post" action="">

Where it says action you need to put the jsp which you want to go after submiting the form. If it is let empty, it is submitted to the same form.
So try this:

<form name="theForm" method="post" action="anotherPage.jsp">

You can also put servlets at the 'action'

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

You can loop backwards the arrays, take the elements and convert them into Strings and concatenate them. Then convert the Strings to numbers and multiply them.

String s;
loop i
  take element i
  convert it to String
  concatenate it to s variable
end loop
convert s to number
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

That does it do, and what it was supposed to do?
Also tell us where is the problematic part of the code.

Also you might want to add some System.out.println and see what are the values of the variables at the parts you are having problems

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

I also like to do small projects just for fun. Especially projects that I can use for my self.
Although I don't find this project very interesting here is what you can do:

> In one package write the classes as explained in the diagram.
> In another package, classes for writing and reading to/from files
> In another package write the GUI

Then call inside the code of the GUI the other classes to perfrom the functionality you want.

Also if you are new to java, then this project is not for you

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster
public void readtext(){
        Adult MyArray[] = new Adult[ 5 ];
        Adult memAd = new Adult (0,"","","","","");
        int counter = 0;
		
        memAd.setMemName(NameTextField.getText());
        memAd.setJoinDate(DateTextField.getText());
        memAd.setMobNum(MobNumTextField.getText());
        memAd.setHomePhNum(HomeNumTextField.getText());

        counter = counter + 1;
		MyArray[counter] = memAd;
    }

You define the array inside the method but it can't be viewed from outside. It is out of scope. The MyArray array cannot be used outside that method. You need to define it outside the method as a class attribute, and use it to the constructor of your table model

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Simple program to read ONE file:

BufferedReader reader = new BufferedReader(new FileReader("filename.txt"));

String line = reader.readLine();
while (line!=null) {
  // line read is not null
// do things with the line
...
..
.


// read the next line and go to the beginning of the while. If it is null
// you exit the while because the file is over

line = reader.readLine();
}

reader.close();

API for File: http://java.sun.com/javase/6/docs/api/java/io/File.html
You will find a method that returns all the contents of a folder. check which of these are files and read them.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

The constructor must have the name of the class:

class MyTableModel {
  public MyTableModel() {

  }
}

Yes, this is because MemNum is a static variable (auto increment) , thinking about it I don't want the user to enter it but I do want it in the table so I will sort that out.

Even if the above is true, I believe that you still need to have the same number of columns. Since the methods getColumnCount, getColumnName will probably generate 4 columns, the values put in the cells will not be correct. Of course you could try this:

private String[] columnNames = {"Name", "Date","Mobile Number","Home Number"};

public Object getValueAt(int row, int col) {
        Adult memAd = data[row];
        switch (col) {
           case 0: return memAd.getMemName();
           case 1: return memAd.getJoinDate();
           case 2: return memAd.getMobNum();
           case 3: return memAd.getHomePhNum();

           case 4: return memAd.getMemStatus();
        }
		return memAd;
    }

but "memAd cannot be resolved"

That has nothing to do with the JTable part. You have to declare the array somewhere where it can be seen, when you try to use it

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Java GUI is just another class. You can create instances of other classes inside and call their methods.
Small, silly example:

class Person {
public String name;
public int age;   

public Person() {
   }
}
class Print {
private Person person;

public Print(Person p) {
   person = p;
}

 public void print() {
   System.out.println(person.name+";"+person.age);
 }
}

And in another class (or in main)

Person pers = new Person();
pers.name = "Name";
pers.age = 10;

Print pr = new Print(pers);
pr.print();
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

That is not a consructor:

public void myDataModel(Adult[] memAd ) { // pass in data array to constructor
	data = memAd;
    }

This is a constructor:

public MyTableModel(Adult[] memAd ) { // pass in data array to constructor
	data = memAd;
    }

I see that at the method: getValueAt you 5 options(col) 0-4 but in the array columnNames you have 4 elements.

Also I am not familiar with Jtables and Models, but since the call you have created IS a AbstractTableModel, maybe you can try this:

Adult [] adults = .......
//put values in the above array
 jTable1.setModel( new  MyTableModel(adults))

Check these links:
http://java.sun.com/javase/6/docs/api/javax/swing/table/AbstractTableModel.html

http://java.sun.com/javase/6/docs/api/javax/swing/table/TableModel.html

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

add2 method is void. So it doesn't return anything. It just adds the argument to the Money object calling it.
When you call it, as you can see, it adds the argument to the dollars and cents of the object that made the call.

Also your minus algorithm is wrong as pointed out by darkagn

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

When you say: "little relevance to any of us".

But probably I misunderstood you, so never mind. Besides the OP already got enough help to solve his/her problem. Continuing this discussion might be meaningless.

Sorry if my attitude sound somehow aggressive.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

@stephen84s
posting links with little relevance to any of us

Sorry to intrude, but what do you mean by that?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

I know the algorithm for pong.

But my brother is better, he knows Ping Pong. Serioulsy, he learned it when he was at University and now he teaches gymnastics at schools

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Try this simple example:

String s = "asjdhk123uhmsmik,z!?";
for (int i=0;i<s.length();i++) {
  char ch = s.charAt(i);
  System.out.println(ch);
}

Also you should always check the API to find more methods that could be useful. In this case, you should have looked the String API

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

x cannot be integer:

<input type="text" name="1">
String value = request.getParameter("1");

"1" is a String

Now if you want the VALUE to be taken as an integer:

<input type="text" name="textName" value="123">
String value = request.getParameter("textName");
int intValue = Integer.parseInt(value);

At the last example, the textfield can have any value you enter when you submit the form. So the above code might throw an NumberFormatException if you don't enter a number, or the request.getParameter("textName") might return null if that tetxFiled didn't send any info with at the request.
So don't forget to make the necessary checks

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster
<td>
<a href="MyFacility.jsp">Test Three Forward</a>
</td>
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

1) This is a 5 month old thread.
2) This thread is marked as solved. I have already found and written the solution, that does what you are trying to describe. Also, since then I have become a lot better in Struts 2 to require any help.
3) Also using <br> to do the formatting isn't a very good solution. It is better to use <div> or at least a <table><tr><td>
4) Write things only in English. No one is going to bother to "read between the lines" and find where the English are

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

http://www.daniweb.com/forums/thread141776.html

It is at the top of the jsp forum

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

hey guys...i have one question.i have file Sample.data, in that file i write "Hello world". how to write code to separate word between "Hello" and "world" and print out it as output seperately.

Start a new thread.

Or better search this forum. Your question has been answered a million times

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

You are missing something basic in Java which is why you should leave JSP and practice more:

if (myvar.equals("compareme")) 
   out.println("string matches"); 
else 
   out.println("string MISMATCH");
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

There is a link at the top of this forum. How can you miss it?

http://www.daniweb.com/forums/thread141776.html

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

I see that you marked the thread solved.
What was the problem?