How can i make a image view app in java? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

How can i make a image view app in java?

23rd Jun 2019, 8:54 PM
Sayeed Razmenda
Sayeed Razmenda - avatar
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
10th Jul 2019, 3:12 AM
raymond wescott
raymond wescott - avatar