javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

This thread has been solved but I would also like to add a small suggestion. If for some reason you want to use ints for boolean expressions, why don't you make a class for it. Call it: BoolInt. Have it have one int private attribute and with the help of public set methods make sure that the only valid values are 1 and 0 (or whatever you want)

class BoolInt {
  public static final int INT_TRUE = 1;
  public static final int INT_FALSE = 0;

  public BoolInt() {
  }

  private int i = INT_FALSE;

  public int getIntValue() {
     return i;
  }

  public boolean getBoolValue() {
     return i==INT_TRUE;
  }

  public void setIntValue(int i) throws Exception {
     // if the user doesn't enter 1 or 0 throw exception
     if (i!=INT_TRUE || i!=INT_FALSE) throw new Exception("your message");

     this.i=i;
  }

  public void setBoolValue(boolean b) {
     i = (b)?INT_TRUE:INT_FALSE
  }
}
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

First of all what errors do you get?
Second, does the 'one' class has a 'newinstance' method? I don't see any so there is your error. You haven't defined a newinstance method.

Maybe you should try this:

try {
            one obj = (one)Class.forName("one").newInstance();
            obj.one();
        } catch (ClassCastException cce) {
            System.out.println("Error: "+cce.getMessage());
        }

And try to have class names begin with capital.
And don't have methods that have the same as the class.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Start coding those method in one class. In another put your main method and call those methods.
What this: "A program that will ask only 3 times for inputting the correct password." has to do with the rest of the requirements.

Start some coding and don't expect us to do all the work. First create those methods and then try to create only parts of the code, test them, and if they work add some more.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Hey, A have a similar question I want do search my form using three input fields and a submit button, than I want to filter my list of patients using method GET. Can you show my how to change this code to do that?

<body>
        <form action='"ShowPatientList.do?imie="+ ' name="patientDetailsForm" method = "GET">
            <p>Imię     <input id ="imie" name = "Imie" value = ""></p>
            <p>Nazwisko <input id ="nazwisko" name = "Nazwisko" value = ""></p>
            <p>Pesel    <input id ="pesel" name = "Pesel" value = ""></p>
            <input id ="subbutton" type = "submit" name="Wyszukiwanie" value = "Szukaj">
            <c:forEach var="patient" items="${allPatients}">
                <p  onmouseover="style.backgroundColor='blue', style.cursor='pointer', style.width='320px'"
                    onmouseout="style.backgroundColor='white'"
                    onclick='method = "GET", window.location="ShowPatientDetail.do?guid="+<c:out value="${patient.guid}"/>'>
                    <c:out value="${patient.name}"/>
                    <c:out value="${patient.surname}"/>
                    <c:out value="${patient.pesel}"/>
                </p>
            </c:forEach>
        </form>
    </body>

Start a new thread with your question.
Also my Struts 1.x are a little rusty so I can not provide much help. What I can tell you is this:
Why do you write the action like this:
'"ShowPatientList.do?imie="+ '

It should be like this:
action="ShowPatientList.do"

The rest of the parameters will be passed with the request once you submit the form. All you have to do with the onclick (which I believe should be onchange) is to submit the form:

document.getElementById("patientDetailsForm").submit();

To do that you need to add an id as well:

<form action="ShowPatientList.do" id="patientDetailsForm" name="patientDetailsForm" method = "GET">
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

if i initialize sNumber as a string,,,
when i come to this line, it would refer to the declared sNumber outside the loop.


int iNumber = integer.parseInteger(sNumber)


so lets say i do this String sNumber=""; (now it is initialized)
when it comes to sNumber , it will refer to the String and not to the new variable i created in the loop #
sNumber = sNumber + All[x]; (which is actually the string that i want to convert to a whole number)

You need to declare and initialize the sNumber outside the loop. Otherwise you will get errors. Inside the loop you change its value by doing this: sNumber = sNumber + All[x]; The sNumber is 'one'. If you declare it in the loop with each loop you will have a new value which will erase the previous parts of the number.

Unbidden Ghost code will work as long as the sNumber is created outside the loop

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Also another thing that I need to mention after reading Unbidden Ghost post.

When you create the All variable you begin with the ',' char. Meaning that the first character would be the dot. So you will go in the loop and try to parse an emty string.

Try to check if the 'sNumber' is empty before parsing it.


Also I believe the problem is quite the opposite. I didn't see anywhere in the code the 'sNumber' declared anywhere. It also need to be declared and initialized outside the loop which is not

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

About this problem:

if(All.charAt(count2)!=dot)
                       { 
                        sNumber = sNumber + All.charAt(count2);/ it wont let me initialize this command, i dont know how to initialize it, so that it would work
                        }

I cannot find where you have initialized the sNumber. Maybe you should change at the beginning of your code this:
String Number; to this: String sNumber = "";

Have you consider using StringTokenizer class. Technically is not using arrays. Check the API. It will make separating the numbers much easier:

StringTokenizer strTok = new StringTokenizer(All, ",");

while (strTok.hasMoreTokens()) {
   System.out.println(strTok.nextToken());
}

Edit: Although I don't think that he will approve such solution even if it is within the requirements. He might say he didn't want you to use some ready class and your approach might be better

This exercise is very good for teaching to students the use of arrays. I find it strange that you are not allowed to use them

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

ANSWER THIS QUESTION -- I AM 16 YRS OLD AND I AM LOOKING FOR DIFFERENT PLAUSIBLE APPROACHES.


Telecom Billing

Telecom service providers are participants in a fiercely competitive arena and all the players, irrespective of their location or size, are putting their best efforts in either retaining their subscribers or acquiring new ones. Technology itself is moving at a massive pace forcing all operators to make large scale investments. Today’s telecommunications environment characterized by increasing customer demand for new products and services, emergence of new competitors and a rapidly evolving technological landscape – requires a fast and responsive business model. As telecommunications service providers introduce new services and look for rapid ROI, they face three key challenges, namely, network flexibility, rapid service development, and operational efficiency. Addressing these requires enterprises to explore, evaluate and adopt new processes.
A Telecom Billing system stores billing rate parameters for call rating devices (could be phones, mobiles, internet connectivity etc) associated with a calling station.

Following are the Requirements for Telecom Billing:-

a)CRM – This module accepts the details of the customer and the different services for which the customer is subscribing. Currently assume that the services provided are phones, mobiles and internet connectivity. A single customer can have multiple subscription for the same service. For eg. A customer can have more than one phone numbers subscriber in his name.

Following are the details to be collected as part of the CRM for each subscription of a service:-
i)Bill Date

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Also, you put "pieces" in some of the elements of the array. The rest are unfilled, so they are null. I would suggest to fill all the array with empty Strings "" in order to avoid the NullPointerException.
Then put to the elements you want the "pieces".

And if you want to compare them use the equals method:

if (jPieces[x][y].equals("wPawn")) {

}

Also whenever you move a piece, put an empty String "" at the previous position after you have moved the piece to the new position

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Actually you have a small misunderstanding with that logic. The API says:
"The ordering imposed by a Comparator c on a set of elements S is said to be consistent with equals if and only if "

The API says at some point that the compare method does not have to be consistent with equals. Even if you implement it, you don't have to make sure that when equals returns true the compare method will also return 0.

The API only said:
"The ordering imposed by a Comparator c on a set of elements S is said to be consistent with equals if and only if "
They don't have to have the same behavior. It simply stated that if you want to say that they are consistent, the equals must behave like the compare. If they don't then that is also ok.

Also this: "if the compare function serves the test for equality too"
That is wrong. Just because 2 objects are equal with each other doesn't mean that their compare methods will return 0 and the other way around.

And we do need both.
Equals for determining equality and compare for sorting. Some classes like java.lang.String are consistent. The compare method and equals method have the same results. Others not.

And a practical example why they are different:
Assuming you have a person class with an id and a name:

class Person {
  private int id …
stephen84s commented: Good Explanation +5
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Since you need 5 numbers, create an array of ints with length 5. Then have a for loop. Inside it call the console.nextInt() in order to get each number and put it in the array. With each loop you will fill each element of the array. The index of the loop would be the index of the array. Arrays of length 5 go from 0 to 4.

I am sure your teacher has given you notes about arrays and how to use for loops. Then use any sorting algorithm you have been taught or search at the net and come back with some code

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

no i not study arrays yet.my mentor said.i need to create a program a long method without using the methods or package in arrays like array.sort.

BUT my mentor said I need to input 5 numbers or integers...thats only my problem.im stuck or i get confused what to do next.what should i add to my program sir.

Your mentor never said not to use arrays, He said that you need to input 5 numbers.
Also what he meant was not to use any java methods that do the sorting for you. Yes there is method where you enter numbers and it sorts them. But your mentor said not to use that method (array.sort)

You'd better ask him if you can use arrays:

int [] numbers = new int[5];

// or better

int N = 5;
int [] numbers = new int[N];

Also in your code you are reading 3 numbers. Reading 5 wouldn't be a problem. Just call the method you are using 5 times instead of 3. And you have 3 variables. How difficult it is to figure out to use 5 variables instead.

BUT it is NOT a good idea to use that approach with 5 numbers. The ifs that you will have to use are approximately 5! = 5x4x3x2x1 = 120 (I think), if you choose to expand the code you have.

For more than 3 numbers you need arrays and sorting algorithm.

So you'd better check …

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Check the API of ArrayList. Never assume that classes and methods do what you think they do. The argument you have specified is the initial capacity of the ArrayList, not the size.

Check the constructors of the ArrayList class.

From the API:

Each ArrayList instance has a capacity. The capacity is the size of the array used to store the elements in the list. It is always at least as large as the list size. As elements are added to an ArrayList, its capacity grows automatically. The details of the growth policy are not specified beyond the fact that adding an element has constant amortized time cost.

An application can increase the capacity of an ArrayList instance before adding a large number of elements using the ensureCapacity operation. This may reduce the amount of incremental reallocation.

Every time you add an element, the size of the list increases. When the size reaches its initial capacity, the list increases its capacity by a default value. Then you keep on adding elements and if you reach again its capacity, it will again increase.

Meaning that if you have the initial capacity to be small (in your case 2) and you add 1000 elements, then you will have many increases which takes time.
If you use a large initial capacity(2000) then the add method calls will be fast. Not many increases would be needed, but you would have wasted a lot of space.

In general for small applications …

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

I never said that he should replace the Color.white with Color.BLUE. I said that since he has in his code this: "Color.white" it should be easy to figure out that this: "Color.BLUE" is also applicable.
And that he can place that code "Color.BLUE" wherever he wants. I didn't look whether it was background or foreground color. It is irrelevant.
I wanted to point out how he can use different colors in any case whether you want to change the background or the foreground.

In the same way he did this:

cell.setBackgroundColor(Color.white);

He can do this:

phrase1=new Phrase(18,new Chunk(DisplayString,FontFactory.getFont(FontFactory.HELVETICA, 10,Font.NORMAL, [B]Color.BLUE[/B])));

Edit: For the above codes I assume that we were talking about the Color in this package: java.awt.Color

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster


I hope..
He did not mean about the back ground colour he is interested in changing his text colour

So refer the below code and suggest a solution if u have ....

Am i right...?


phrase1=new Phrase(18,new Chunk(DisplayString,FontFactory.getFont(FontFactory.HELVETICA, 10,Font.NORMAL, [B]new Color(80,80,80))));[/B]

I never said that he should replace the Color.white with Color.BLUE. I said that since he has in his code this: "Color.white" it should be easy to figure out that this: "Color.BLUE" is also applicable.
And that he can place that code "Color.BLUE" wherever he wants. I didn't look whether it was background or foreground color. It is irrelevant.
I wanted to point out how he can use different colors in any case whether you want to change the background or the foreground.

In the same way he did this:

cell.setBackgroundColor(Color.white);

He can do this:

phrase1=new Phrase(18,new Chunk(DisplayString,FontFactory.getFont(FontFactory.HELVETICA, 10,Font.NORMAL, [B]Color.BLUE[/B])));
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster
PdfPCell cell = new PdfPCell();
 Phrase phrase1 = null;
phrase1=new Phrase(18,new Chunk(DisplayString,FontFactory.getFont(FontFactory.HELVETICA, 10,Font.NORMAL, new Color(80,80,80))));
cell.setPhrase(phrase1);
cell.setBackgroundColor(Color.white);
if(IsColor.equals("Y"))
	cell.setBackgroundColor(new Color(247,243,247));
table.addCell(cell);

In the above code, new Color(80,80,80) is reflected as white color and setBackgroundColor(new Color(247,243,247) is reflected as pink color. I'm asking that, if i add a blue color instead of white color, what i'm going to write instead of new Color(80,80,80) one.

I would assume: Color.BLUE In the code you wrote you do this:

cell.setBackgroundColor([B]Color.white[/B]);

So why didn't you try different colors? Maybe if you would have looked at the API:
http://java.sun.com/j2se/1.5.0/docs/api/java/awt/Color.html
You would have seen all the different colors you can use. Also you could have found out what the constructor does: new Color(80,80,80) For Blue you can also try this:
(r,g,b) = (0,0,255)

And yes your question was very vague, because as you pointed out there are many different java applications. And that code should have been in your first post.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

" I had already describe what my requirement was. Why you always go to swing application? I'm not using any swing application. Is font colors only applicable to swing application or what? I'm asking simple one that how can we change the font colors in simple java application program. I already give an example to compate with html. U are failed to understand the threads properly. Read the thread again and give the answer properly if u can.

In what kind of java application you are referring to?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster


Hi,

Exactly you catch my point. In html or javascript we can easily apply font colors by using <font> tag. But, i asking that how can we apply font colors in java to the specific text like "Contract". I need this text Contract appear as a blue.

If you aware of it, then please help along with code.


Thanks & Regards,

Jayavardhan. T

Like I asked: "Do you want to change the color of text in a Swing application?"
If yes, then I told you to look at the API of the components you are using to display your text.
You seem to know how to do it with html. But you failed to provide any useful information of what you want to do. Your question is very vague. And this thread has been getting too long with no useful information.
Can you post code showing where you want the color to be changed?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

- Sorry wrong input -

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

The fonts of what? If you are referring to Swing then I believe that the classes have set methods for that. Look at their APIs

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Don't forget that if you need to compare Strings use the equals method. The code provided will not work because this: "==" does not work when comparing Strings.

Also another mistake to your code Taywin is that you have getAnswer non static. You cannot call it the way you have it.

Please don't post again erroneous code

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

pls solve my problem urgently
1 *
***
*****
***
*
2 *****
** **
* *
** **
*****

Why ?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Then I guess it cannot be done that way. You don't need to use that code inside a jsp. You usually do that in a servlet.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

How are you suppose to retrieve the value if you don't execute the page req first. This is where you set the attribute.

You say "i couldnt retrieve from req.jsp page in retr.jsp page "
Of course you didn't . When you opened the retr, you had't put anything in the request. Did you call the req.jsp in order to get the request from?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

I didn't mean that you put both lines in the same file.
One line goes to one file and the other to the other.
Try your code to see if it works, with the suggestion I gave you.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

I haven't tried that code. You need to check it yourself.

But I would suggest this, if you want to have more chances of succeeding.

<% request.setAttribute("[B]info[/B]", "info from page1"); %>

....

<%=request.getAttribute("[B]info[/B]")%>
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

First check some html and javascript tutorials because that code is totally wrong. It needs to rewritten from the beginning.
I would suggest this:
http://www.w3schools.com/default.asp
First learn about html and then move to javascript

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Check the announcement at the top of this forum:
Starting "Java" [Java tutorials / resources / faq]
It has plenty of resources to choose from

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Have you declared the variables username, password?
Perhaps you need to show more code.
Also the above code is html code, not a scriplet. Does it compile.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Just a suggestion for you to check. It might not work:

var url = 'showDetails.jsp?abc =' + detailsForm.sltdUser.value;
alert(url); // works fine
window.open(url);
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Thanks
I am researching spinners and JFormmatedTextFields. maybe the 3 args I need can be
produced for the Date(xxxx,xx,xx) format

Don't use that constructor. If you have a String with this format or similar:
dd/MM/yyyy or yyyyMMdd ot MM-dd-yyyy use the simpleDateFormat.

That Date constructor is been deprecated and it is better not to use it anymore.
You can check the Calendar class, but I don't use it much

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Check the constructor of the class java.util.Date at the API. I doubt the there is one that takes as argument the String that you are trying to pass
txtFieldArray.getText()

Check the API of java.util.Date as well as the class: java.text.SimpleDateFormat
And you will get your answers:
http://java.sun.com/j2se/1.5.0/docs/api/java/text/SimpleDateFormat.html

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

What book are you using. From where you get your resources?

Also you don't need to put all the "authorities" in the session. You know those. Just pass the authority of the specific user:

String authOfUserLoggedIn = (String)session.getAttribute("authority");

if ("some_authority1".equals(authOfUserLoggedIn )) {
// user is authority1 // go to right page
} else if ("some_authority2".equals(authOfUserLoggedIn )) {
// user is authority2 // go to right page
} else if ("some_authority3".equals(authOfUserLoggedIn )) {
// user is authority3 // go to right page
} else {

}

When the user logs in just pass his "authoriy". (Taken from the database for example). You already know the other roles. You defined them. You don't need to pass them in the session.
What changes, every time the code executes, is the user that logs in.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Have you tried to check the error messages you get?

The first piece of code will result to a NullPointerException since you don't initialize the array. If you didn't accidentally forgot to do that, then forget what you are doing and try to learn basic java first.

At the second piece of code, you are using the session instance: session.getAttribute and the you check if it is null. If there is any chance that session would be null then this would give you an exception first: session.getAttribute

Not to mention that you never put this into the array:

if(athority[i].equals("CreateNewPostJava.jsp"))

You do this:

authority[0] = "signIn.html";
           authority[1] = "signUp.html";
           athority[2] = "Post.html";

How do you expect it to be equal.

You also put the array into the session with key: "Url" But at the second code you use a different key.


So in conclusion, stop what you are doing, learn some basic java first (how to creare arrays for example) and then buy a book and study about jsp and servlet. Because from that code, I doubt it that you spend some serious time in learning the basics about web design

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

What you posted is unreadable. Use code tags. Click the button: (code) and place your code inside

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Show some code, give more information and use:

request.setAttribute("key", object);

request.getAttribute("key");
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Try looking at the API for JOptionPane class. Focus on the static methods that start from show.....

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Use the classes java.util.Date with the java.textSimpleDateformatter, or/and java.util.Calendar

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

I assume that the according.jsp is an empty jsp that has only DB code and nothing else.
Then when you are done, you can write code using the <forward> tag to redirect to the initial page. You can also send the data saved and display them. This time you can also make the fields readonly.

The above might solve your problem but it is not correct. Instead of going to the according.jsp go to a servlet, do the insert there and then redirect to the inital page using the RequestDispatcher. Also you can send a flag indicating that the first form has been filled and no more is needed.


initialPage.jsp

String form1Saved = request.getParameter(form1Saved);

<%
if (form1Saved==null) {
%>
  display the form with buttons and fields
<%
} else {
%>
   // display only the data send from the servler
<%
}
%>

Or you can skip the above if-statement and simply have the form pre-filled with data send from the servlet:

// surname send from servlet. If this is the first time the page loads then 
// surname would be null
String surname = request.getParameter("surname");
if (surname==null) surname="";

<form action="nameOfServlet1"> // or your jsp
  <input type="text" name="surname" value="<%=surname%>" />

  <input type="submit" name="submit1" value="Submit" />
</form>

OR
Use Ajax, preferably with jQuery which makes it easier

And check the tutorial about MVC connectivity on top of the jsp forum

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Try to run the query first at the sql prompt and see if it works then takes it and put it at your statement. Post the errors that you get.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

hai,

searchform.jsp
<input type = "text" name ="record">
2. click search button
3. action = "searchresult.jsp"


searchresult.jsp

String value = request.getParameter("record");
// connect databases;
// give sql query :

String sql = select * from empdetails where empno = '"+value+"';

ResultSet rs = st.executeQuery(sql);
while(rs.next())
{
String empname = rs.getString("empname");
String empid = rs.getString("empid");
// etc
out.println(empname);
out.println(empid);
}

Totally wrong. Don't do database connections inside jsp. Use servlets instead

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

As for your algorithm I would drop the 2 for loops and use if statements that compare their coordinates to see if the shape's coordinates are inside/between the selected shapes:

if (selection.getX1() <= shape.getX1() && selection.getX2() >= shape.getX2())

The above will tell you if the X coordinates of the shape are inside the selection, assuming that x1<x2 always.
Do the same for the y coordinates

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Loop the array and print only those that are not zero. Also I would suggest to initialize the array: shapeIndexes to have all -1 as initial elements. With the way you initialize it, it begins with zeros. So if it happens that the selected shape is the first element of shapeObjects array, the shapeIndexes array will have the index 0, but you wouldn't know the difference between that zero and the one that the array initially had.
If you make that change then at your loop make sure to print only those indexes that are not -1

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

How do you want it to be passed? I mean if don't click a button, you must perform an action to send the data. If the user enters a value at the input field, then the user must also do something to send the data. What do you want the user to do to send the data? There are plenty other ways; the question is why don't you want a button and with what you want to replace the button?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

So search for examples on how to read and write to a file. There are plenty in this forum.
Also where are you having problems with?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

What do you mean each cell element. What do you want to do with the Jtable at the GUI ?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Actually, If I may add, it does not print the memory address. That is the hashcode of the object.
When you call the System.out.println(anObject) what it actually does is call the toString method: System.out.println(anObject.toString()) Since you haven't overridden the toString method it uses the one from the super class the Object. Check the API.

If in your Noce class you had this it would work:

class Node {
  private String data;

  public String toString() {
     return data;
  }
}
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

You can pass to the KeyPad constructor the element you want to change.

JLabel label = new JLabel("THIS IS THE LABEL");
Keypad key1 = new Keypad(label);
public class Keypad extends JPanel{
 
private JButton b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12;

[B]private JLabel label;
public Keypad(JLabel lbl) {
   this.label = lbl;
}[/B]

{
	public void actionPerformed(ActionEvent event)
	{
		if(event.getSource() == b1)
			label.setText("1");
		}
}
}

Although If I were to do this myself, I would do exactly what leiger has suggested

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

there is Inheritance mean subtype polymorphism or there not have same job ??

What ?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

The only thing I see commented is the JColorChooser not the JFileChooser.
Can you make that clear? I am talking about the first few lines of the openFile method.
All the JFileChooser are there. Do they work?