Rod Singh

Greenhorn
+ Follow
since Feb 10, 2012
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Rod Singh

Try Replacing the line:

f.setLayout(null);

with some layout; let's set it to FlowLayout

f.setLayout(new FlowLayout());
13 years ago
13 years ago
Since you are overriding start(), add a public access modifier. In addition, use graph.drawImage() in paint() method -- to display a random image.
13 years ago
Let me try to help you out with an indirect answer for I don't have a direct answer.

In my knowledge, there are two kinds of Inner classes(in a general term): Nested and Local. The nested class is one that is enclosed under a top level type. The local class is one which is declared inside a method or a block; furthermore, the local class is of two kinds: named local class and anonymous local class. All of these can be declared both as a static or as an instance member.

That being stated, practically, I have encountered two examples of inner classes as a recurring pattern: the one as a private static class, and the other as a annonymous inner class. A private static class is where a functionaly needs to be encapsulated in a single class that is used only be a top level class -- the converse is true as well. The idea here is that members of declared nested class are only accessible(or accessed) inside the enclosed class(type) -- not by any other class. With regards to anonymous inner class: event handlers and mock objects are a few examples.

The reason lies in encapsulation and high cohesion concept of Object Oriented Design.
13 years ago
With regards to Windows Task Manager, your .bat script -- which invokes java -- hides the java process. If you would want to explicitly list the java process visible in your process list -- run it explicitly as java -jar "C:/app/app.jar" from the command shell.
13 years ago
CLASSPATH is used for the entire system; In other words, all Java applications on that machine -- use the CLASSPATH. On the other hand, if there is a need to override -- the CLASSPATH -- then -cp (or -classpath) option is used. Moreover, The CLASSPATH option can be added along with -cp option as well.

Using -cp or -classpath option is a preferred option.
13 years ago
I would check the value of header in the line:
msg.addHeader("Custom",header);
13 years ago
You're welcome!
13 years ago

[DELETED]
13 years ago
Modify the line :
int[] numGrade = null;

as
int[] numGrade = new int[20];
13 years ago

Replace the mouseClicked() method, which is in the previous posting with the one given below.



The "increment", and the "reset" is handled in the mouseClicked() method. As per the code-- from my previous posting-- this event handler method is attached with both the buttons.

That being stated, when the button labeled as "increment" is clicked-- the count is creased by 1, and the text field is set with the new value of the count. On the other hand, when the button labeled as "reset" is clicked--the count is reset to 1, and the text field is reset to zero length string--a blank.

I hope you understood it.


13 years ago


What I've just tried to help you out that -- how your Q1 would get access to the TextField item --so that the increment can be displayed. Notice that the MyFrame object is passed to the IncrementResetListener() method.
13 years ago
In c language, you can write a function to calculate length of a string, and let your java program call it using JNI.
13 years ago
The output of the program is correct. If you move the display() into Child's class, the output will be 100. The reason is when the Child's class instance is created it inherits both x-- from the Child Class and from the Parent class. That being said, since display() method is in the Parent class, it will access the x-- the one which is present in the Parent class--not from the Child's class.

With regards to data hiding(encapsulation), the concept is related to access modifiers--coderanch, protected, default, private. In other words, if you assign a "private" access modifier to "int x", then the 'x' can not be accessed from any other class. Here one point is notable: when a class inherits any other class, the inherited class gets all the behaviors and properties of its parent class.
13 years ago