Build Image Viewer Application using Java

preview_player
Показать описание
A simple image viewer app using java for beginners.

Source Code:
----------------------

public class ImageViewer {

public static void main(String[] args) {

JFrame frame = new ImageViewerFrame();

});
}

}

@SuppressWarnings("serial")
//A frame with a label to show an image
class ImageViewerFrame extends JFrame {

JLabel label;
JFileChooser chooser;
JMenuBar menubar;
JMenu menu;
JMenuItem open;
JMenuItem exit;

//Constructor
public ImageViewerFrame() {

setSize(500,500);

//Use a label to display the image
label = new JLabel();
add(label);

//Set up the file chooser
chooser = new JFileChooser();

//set up the menubar
menubar = new JMenuBar();
setJMenuBar(menubar);

menu = new JMenu("File");

open = new JMenuItem("Open");


public void actionPerformed(ActionEvent event) {

//show file chooser dialog

//if file selected, set it as icon of label
if(result == JFileChooser.APPROVE_OPTION) {
}
}
});
}

}
---------------------------------------------------------------------------------

Follow me:
------------------
Рекомендации по теме
Комментарии
Автор

How to call this class from another class... Plz help me

TamilNadodi
Автор

How to add multiple images side by side on a single panel within a single window/frame?? Plz send source code for the same

shashankvray
join shbcf.ru