Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!

Alexander McDougall

Greenhorn
+ Follow
since Jan 08, 2013
Alexander likes ...
Android Java Spring
Johannesburg
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
5
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Alexander McDougall

Hi Darryl,

I experienced a similar problem to Sameer Khazi in his original post.

I realised that the code I provided is used together with another class.

The class that extends JPanel is called each time a user clicks a button. This other class
creates a JFrame, creates a button, adds a listener to the button, creates a panel, adds the button and panel to the frame,
and when the user clicks on the button, the code in the actionPerformed method is executed, which in
this case is frame.repaint(). This causes the paintComponent method to be called. I did not need to add a
main method to the original code I posted.

Thanks for the reply.

Regards

Alex
5 years ago
Hi there,

I am currently experiencing the same problem.

This is the code:



I checked in a previous post that you need:

super.paintComponent(g);

in the paintComponent method.

Any one able to help?

Regards

Alex
5 years ago
Hi,

Thanks for all the help.

I checked the versions for javac and java, both are Java 1.7.

I checked through the various steps that you provided. I then checked the classpath. I do have an older version of the java compiler running on my machine. I had to change the classpath to point to the directory I am currently using. There is another directory set up for the older version.

It is running now without having to make any changes. The autoboxing does work as well. I tried to pass it in as an int, and as an Integer object and both worked.

Regards

Alex
5 years ago
Hi,

I am running version 1.7 of Java
5 years ago
Hi there,

I have an error with String.format.

The following is the error that I get:

error: cannot find symbol
String s = String.format("%, d", 1000000000);
symbol: method format(string, int)
location: class String

I have done a search on the error and have not come up with a solution, any help would be appreciated.

Regards
5 years ago