+ 4
How can i make a image view app in java?
2 Answers
+ 3
/**this is some code example
*/
import java.awt.Image;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
public class ImageViewer extends javax.swing.JFrame {
/**
* Class constructor: ImageViewer
*/
public ImageViewer() {
initComponents();
listFiles(Path); //Lists all the files in the directory on window opening
setLabelIcon(Path,filenames[position]); //sets the label to display the first
//image in the directory on window opening.
PreviousButton.setEnabled(false);
}
/**
*Initialize components
*/
private void initComponents() {
setTitle("Image Viewer");
setDefaultCloseOperation(EXIT_ON_CLOSE);
setLayout(new java.awt.BorderLayout());// The layout is BorderLayout
//setBorder(javax.swing.BorderFactory.createEtchedBorder());
setBackground(java.awt.Color.GRAY);
picLabel = new javax.swing.JLabel(); //Create the Label to display the picture
picLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
picLabel.setHorizont