Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

No Image why??!!!

 
madhu cm
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
import java.awt.BorderLayout;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
class Demo extends JFrame {
JPanel Back;
Demo() {
Back = new BackGround();
this.add(Back);
}
public static void main(String asd[]){
JFrame.setDefaultLookAndFeelDecorated(true);
Demo d = new Demo();
d.setPreferredSize(new Dimension(200,200));
d.setVisible(true);
d.pack();
}
}

class BackGround extends JPanel {
JButton b;
Image img
public BackGround() {
img = Toolkit.getDefaultToolkit().getImage("/home/maddy/JaiGanesh.jpg");
}
}

Hello ranchers .... The above code is to load an image file on the Panel....
But its not loading... i dont know the reason.... is there any method to load image on the panel? And the sentence "Toolkit.getDefaultToolkit().getImage("/home/maddy/JaiGanesh.jpg");
" actually belongs to linux file system..... and had been developed in Linux.... Help me dudes and i want the reason why its not loading....!
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello "madhu cm"-

On your way in you may have missed that JavaRanch has a policy on display names, and yours does not comply with it - please adjust it accordingly, which you can do right here. Thanks for your prompt attention to this matter.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It seems that you're loading the image, but you don't actually show it anywhere.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!