techpreparation-homepage

Home  Interview Questions  Aptitude Questions  Tutorials  Placement Papers  Search  Resume Guide  Soft Skills  Video  Forum  Blog


Technical Interview Questions
Javascript Interview Questions
Oracle Interview Questions
J2EE Interview Questions
C++ Interview Questions
XML Interview Questions
EJB Interview Questions
JSP Interview Questions
                              .........More

Programming Source Codes
Java Source Codes
Html Source Codes
CSS Source Codes
C Source Codes
                              .........More

Soft Skills
Communication Skills
Leadership Skills
                              .........More

Subscribe to our Newsletters
Name:
Email:

 

 

  

Java Source Codes

image viewer bean

import java.awt.*;
import java.io.*;
import javax.swing.*;

public class ImageViewerBean extends JPanel
implements Serializable
{ public void setFileName(String f)
{ fileName = f;
image = Toolkit.getDefaultToolkit().getImage(fileName);
MediaTracker tracker = new MediaTracker(this);
tracker.addImage(image, 0);
try { tracker.waitForID(0); }
catch (InterruptedException e) {}
repaint();
}

public String getFileName()
{ return fileName;
}

public void paint(Graphics g)
{ if (image == null)
{ g.drawRect(0, 0, getWidth() - 1, getHeight() - 1);
}
else
g.drawImage(image, 0, 0, this);
}

public Dimension getPreferredSize()
{ if (image == null)
return new Dimension(MINSIZE, MINSIZE);
return new Dimension(image.getWidth(null),
image.getHeight(null));
}

private static final int MINSIZE = 50;
private Image image = null;
private String fileName = "";
}


<<<----- Return to Java Source Code Questions Page.


 

Have a Question ? post your questions here. It will be answered as soon as possible.

Check Java Interview Questions for more Java Interview Questions with answers

Check Servlet Interview Questions for more Servlet Interview Questions with answers

Check Structs Interview Questions for more Structs Interview Questions with answers