• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Displaying an Image on a thick-client

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello All,
I have a very simple app. I just wanna display an JPEG on a frame. I have configured Apache Tomcat and created JNLP file. Everything is working just fine except that the image is not being displayed.

Code Snippet
------------
class MyFrame extends JFrame{
MyFrame(String title){
super(title);
MyDrawPanel drawPanel=new MyDrawPanel();

addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent we){
setVisible(false);
dispose();
System.exit(0);
}
}
);
}
public void paint(Graphics g){
g.drawString("App Home",20,50);

Image img=Toolkit.getDefaultToolkit().getImage("logo.jpg");
g.drawImage(img,20,80,this);


}
}

public class AppHome{
public static void main(String args[]){
MyFrame fr=new MyFrame("title");
fr.setSize(200,300);
fr.setVisible(true);
}
}
I'm creating the JAR file like this:
jar -cvf Home.jar logo.jpg *.class

Anybody pls help, how do I go abt that?

Rgds,
Richa
 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
are you sure it's not something with your path to the logo.jpg? I'm guessing that it's trying to find it at the root, but it's not technically the root path. Or maybe it's a permission issue?
 
reply
    Bookmark Topic Watch Topic
  • New Topic