Hello,
I'm new to
Java and have written the below code while going through the Swing chapter:
package GUI;
import java.awt.*;
import javax.swing.*;
public class MyDrawPanel extends JPanel
{
public void paintComponenets(Graphics g)
{
Image image = new ImageIcon("C:/hyd.jpg","meaningless picture").getImage();
g.drawImage(image, 300,400, this);
g.drawRect(50, 50, 250, 50);
g.setColor(Color.red);
g.fillRect(0, 0, 250, 750);
}
}
But nothing is happening when I use an instance of MyDrawPanel in the main method which also contains a button.
I've checked ActionPerformed(ActionEvent event) and it's working fine.
what is the correct way to metion path of a picture ? (I didn't get it even in api
).
Thanks a lot...
Pramod