Share on Google+Share on Google+

zeeshan khan
java in using brausing
1 Answer(s)      5 years and 8 months ago
Posted in : Java Beginners

sir, i am beginner java developer ,sir i am creat's the image viewer Jframe but not a created frame plz. halpe me give the image viewer Jframe code


View Answers

August 19, 2011 at 1:08 PM

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

public class SelectFile extends JFrame implements ActionListener {

   JLabel label;
   JMenuItem openItem;
   JMenuItem exitItem;
  public SelectFile() {
    setTitle("Image Viewer");
    setSize(300, 400);

    JMenuBar mbar = new JMenuBar();
    JMenu m = new JMenu("File");
    openItem = new JMenuItem("Open");
    exitItem = new JMenuItem("Exit");

    label = new JLabel();
    Container contentPane = getContentPane();
    contentPane.add(label, "Center");

  public void actionPerformed(ActionEvent evt) {
    Object source = evt.getSource();
    if (source == openItem) {
      JFileChooser chooser = new JFileChooser();
      chooser.setCurrentDirectory(new File("."));

      chooser.setFileFilter(new javax.swing.filechooser.FileFilter() {
        public boolean accept(File f) {
            String name= f.getName().toLowerCase();
            return(name.endsWith(".jpg") || name.endsWith(".png")|| name.endsWith(".gif"));

        public String getDescription() {
          return "GIF Images";

      int r = chooser.showOpenDialog(this);
      if (r == JFileChooser.APPROVE_OPTION) {
        String name = chooser.getSelectedFile().getPath();
        label.setIcon(new ImageIcon(name));
    } else if (source == exitItem)

  public static void main(String[] args) {
    JFrame frame = new SelectFile();;


Related Tutorials/Questions & Answers:
java in using brausing
java in using brausing  sir, i am beginner java developer ,sir i am creat's the image viewer Jframe but not a created frame plz. halpe me give the image viewer Jframe code   import*; import java.awt.
using eval in Java
using eval in Java  using eval in Java
write a programm using java
write a programm using java  print the following using java programming
Using throw in java method
Using throw in java method  using throw with method implies what
survey poll using java
survey poll using java  how to make a survey poll using java? i am using netbeans and glassfish
A Java Program by using JSP
A Java Program by using JSP  how to draw lines by using JSP plz show me the solution by using program
RARP program using java
RARP program using java   hai, how to implement the RARP concept using java
java code using swings
java code using swings  code that should be able to enter data of student details using all swings into the access database using jdbc connectivity
java using Stack - Java Beginners
java using Stack  How convert decimal to binary using stack in java
Image using Java coding
Image using Java coding  Hai, Display image in pdf file using Java coding through Xsl file.. Please help me.. xsl file generate the pdf file
covert the following using java
covert the following using java  how to convert (for eg : 2.89) . this decimal to binary in java
accessing xml using java
accessing xml using java  I need to retrieve some elements in xml file using java   Hi Friend, Please visit the following links:
uSING JAVA API  How to extract Quickbooks online data using Quickbooks api( Rest ApI) write in java code ? 1.register company account 2..register application 3.get apptoken,consumer key,consumer screte can i
SMS using Java
/viewqa/Java-Beginners/15745-Sms-to-mobile-using-java-application.html ) How...SMS using Java  I am having a concern , where is the main class in, if this seems silly please let me know How to execute this java
Read XML using Java
of all i need to read xml using java . i did good research in google and came to know.../xmlParsing/java-xml-parsing-using-sax.shtml XML using Java  Hi All, Good Morning, I have been working
using java files - Java Beginners
using java files  how i use files in java to store as eg. (information about movies as its name) & when user ask about some movie the movie will come with a picture associated with it plz write me a couple of line codes
java using Stack - Java Beginners
java using Stack  How convert decimal to binary using stack in java? whats the java program or code to that. Thank you rose india and java experts  Hi Friend, Try the following code: import java.util.
JSP using java - Java Beginners
JSP using java  sir, In my jsp page contains 3 hyperlinks say (link1 link2 link3).I want to write some java code using servlet for each to forward JSP page to servlet.I m using 3 hyperlinks in my page.My
java code using while loop
java code using while loop  
Java Programming using array
Java Programming using array  I'm creating a programming using array that will accept 10 letters and test if those letters are consonant...','H','J','K','L','M','N','P','Q','R','S','T','V','W','X','Y','Z'}; char ch
java using JSP - Java Beginners
java using JSP  hi...i has been created one JSp this page have one links name as "Show datas in Excel format".I want to create Excel file... using postgres DB.This DB have more than 4 Rows and Columns.  Hi Friend
How to design a form using java?
How to design a form using java?  Please help in designing of form using java for my project
java code for PartialSearch using Map????
java code for PartialSearch using Map????  java code for Partial Search using Map
OOP using Java - Java Beginners
OOP using Java  Can you write a Java statement that creates the object mysteryClock of the Clock type, and initialize the instance variables hr,min...); } } For more information on Java visit to :
OOP Using JAVA - Java Beginners
OOP Using JAVA  OBJECT ORIENTED PROGRAMMING USING JAVA (hope guys u will help me please i need your help,thank you so much) Create a Java program...(); oops.OopType(); } } For more information on Java visit to : http
Video streaming using java
Video streaming using java  I want to create a website based on video streaming.The user has to pay and watch the videos stored in the server.So we have to stream the video in the server side and send that to the client side
Using swing - Java Beginners
Using swing  How can one use inheritance and polymophism while developing GUI of this question. Develop an application that allows a student to open an account. The account may be a savings account or a current account
JSP using java - Hibernate
JSP using java  This is my part of Excal sheet code using jdbc connection. int index=1; while( using hibernate.I am having function called displayIps() and displayvalues
Java using Jsp - Java Beginners
Java using Jsp  hi sir, again i m getting error like. HSSFWorkbook cannot be resolved to a type. HSSFSheet cannot be resolved to a type. HSSFRow cannot be resolved to a type I included Maximum all jar file in eclipse
Without Using Form in Java Script
Without Using Form in Java Script  HOw to Reset the data in javascript without using form tag
Record and Save Video using Java
Record and Save Video using Java  How to record video(webcam) and save it using Java.?? Its really urgent
Java Spring Hibernate Struts Training What does core Java include? java What are some way to learn Java quickly? Is it required to learn Java before learning Java Script? Is it necessary to learn java script before learning PHP? Are HTML5 and Java Script boosts Java career? Is Java object oriented? Fingerprint application with Java Uninstall Oracle Virtual Box JSON to HashMap Free Java online Training I want example of Control Statement in Java ANSI Color Codes with Python Create a Program that Calculates Input What is difference between JDK,JRE and JVM? How to see ubuntu version on server? How to get Page Source in Selenium (WebDriver) using Java? The path to the driver executable must be set by the webdriver.gecko.driver system property parse data from a link in java Java Program Qns using BlueJ How to fix HAX Kernel Module Is Not Installed error? Installing Audacity Looking for code Logic to check track changes & Coments in MSWord, MSWordx, MSExcel, MSExcelx is ON/OFF Installing JDK on Mac SAX Parser exception ERROR 601 (42P00): Syntax error. Encountered Thread java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory How to install Ubuntu 16.04 LTS? HttpServletRequest cannot be resolved to a type in eclipse - Solved Unhandled event loop exception GC overhead limit exceeded Spring Data jpa with apache phoenix Caused by: java.lang.IllegalArgumentException: Not a host:port pair: PBUF o.a.h.h.z.RecoverableZooKeeper - Possibly transient ZooKeeper, quorum= com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager class not found com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager not found How to download and install Java 8 on Windows? How to uninstall JDK 7? How to install gtk-doc-tools package in Ubuntu? How to install Oracle JDK 8 on Ubuntu? ejabberd_ctl.beam not found - Solved How to convert date to UTC format in Java? How to install autoconf, automake and libtool in Ubuntu 15.10? How to convert current date to mm dd yyyy format in Java? How to convert current date to dd mm yyyy format in Java? How to stop window closing in "internalFrameClosing" event. How to find list of all index in Neo4j? file location SASLError using PLAIN: not-authorized how to convert war file into .exe file using java code


Advertisement null