sammy young

Greenhorn
+ Follow
since Oct 29, 2012
Merit badge: grant badges
For More
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
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by sammy young

@ Michael Dunn WHY? Am new in java and this forums, i posted because it has been difficult for me to resolve on my own and i believe i could get solution when i come here, why discouraging me this way? Pleas if you of any simple way for me to handle my problem i will appreciate it.
11 years ago
my question is, i want to drawimage on jlabel or jpanel when an event occur like actionperformed, so in my actionperformed i did somthing like this

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Image imag = new ImageIcon(this.getClass().getResource("img/top_bg.jpg")).getImage();
showPix1.setLayout(new BorderLayout());
showPix1.add(new paintPhotos(imag,20,20), BorderLayout.CENTER);
}

But is not working, can someone help me out here?
11 years ago
Please i have a class that extends jlabel and draw on it using paintComponent as follows this is paintPhotos.java



when i try to draw from a constructor of another class like this (AddScore.java).



the above work fine and draw the image as specified.

but when i try to draw the image from an actionperform event of another class (AddScore.java) like this.



the above statement did not work as the paintcomponent is not working, what am i doing wrong?
11 years ago