Java program that creates a photo album application. Which will load a collectio
ID: 670955 • Letter: J
Question
Java program that creates a photo album application. Which will load a collection of images and displays them in a album layout. The program will allow the user to tag images with metadata:
•Title for the photo
. Limited to 100 characters.
•Description for the photo
. Limited to 300 characters.
•Date taken
•Place taken
Functional Specs
1.Your album should be able to display the pictures sorted by Title, Date, and Place.
2.When the user clicks on a photo, data should be displayed.
3.The user should be able to add or remove pics.
Explanation / Answer
import java.awt.*;
import java.awt.image.*;
import java.io.*;
import javax.imageio.*;
import javax.swing.*;
public class ImageDemo
{
public static void main(String[] args) throws
Exception
{
new ImageDemo(args[0]);
}
public ImageDemo(final String filename)
throws Exception
{
SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
JFrame editorFrame = new JFrame("Image
Demo");
editorFrame.setDefaultCloseOperation
(WindowConstants.EXIT_ON_CLOSE);
BufferedImage image = null;
try
{
image = ImageIO.read(new File
(filename));
}
catch (Exception e)
{
e.printStackTrace();
System.exit(1);
}
ImageIcon imageIcon = new ImageIcon
(image);
JLabel jLabel = new JLabel();
jLabel.setIcon(imageIcon);
editorFrame.getContentPane().add
(jLabel, BorderLayout.CENTER);
editorFrame.pack();
editorFrame.setLocationRelativeTo
(null);
editorFrame.setVisible(true);
}
});
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.