Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners java in using brausing

Have Programming Question? Ask it here!
 
 
 


zeeshan khan
java in using brausing
1 Answer(s)      2 years and 11 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


Advertisement
View Answers

August 19, 2011 at 1:08 PM


import java.io.*;
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");
    openItem.addActionListener(this);
    m.add(openItem);
    exitItem = new JMenuItem("Exit");
    exitItem.addActionListener(this);
    m.add(exitItem);
    mbar.add(m);
    setJMenuBar(mbar);

    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)
      System.exit(0);
  }

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

}


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 java.io.*; import java.awt.
using eval in Java
using eval in Java  using eval in Java
Advertisements
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: http://www.roseindia.net/xml/Listingnode.shtml http://www.roseindia.net/xml/getting
uSING JAVA API
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 4.how 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 SMSClient.java, 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 http://www.roseindia.net/xml/sax...Read 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 hyperlinks.how 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 page.in 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
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 : http://www.roseindia.net/java
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  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
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
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(rs.next... using hibernate.I am having function called displayIps() and displayvalues
Matrix Addition using RMI in Java
Matrix Addition using RMI in Java  Source Code for Matrix Addition using RMI in Java
Without Using Form in Java Script
Without Using Form in Java Script  HOw to Reset the data in javascript without using form tag
Using a JFileChooser - Java Beginners
Using a JFileChooser  Dear Editor, How to select an image from JFileChooser & add the image in mySQL5 database? Thanks in advanced. Regards, Melvin.  Hi Friend, Try the following code: import java.sql.
JSP using java - Java Beginners
JSP using java  hi, In my jsppage has Combo box(contains inpacks,outpacks,system uptime etc) component and options like (bar chart,pie chart etc). I have core java code for (inpacks,outpacks,system uptime etc
creation of table using a Java swing
creation of table using a Java swing  how to create a table dynamically in Java swing
DESKTOP SHARING USING JAVA
DESKTOP SHARING USING JAVA  Sir i have the following code for scren capturing it is capturing in png format but when i am sending it over other m/c it is taking delay of around 16 seconds..i think it is because this line of code
Java using Jsp - Java Beginners
Java using Jsp  hi sir, 1)showExcel.jsp: Show datas in Excel... and executed in netbeans 4.1. but not work in EclipseEE.i m using Tomcat server... in the generated java file Only a type can be imported
read xml using java
read xml using java  <p>to read multiple attributes... to other interacting modules, as communication is only allowed to take place using... is only allowed to take place using this layer. The data stored is composed
Java using arrays - Java Beginners
Java using arrays  Write a program to input a possibly integer n(n<=10);followed by n real values into an array a of size n and the program must perform the following: Display back the values input Sort the values
java chat using java media
java chat using java media   Remove the error of this code plz reply me fast on my mail ID **Deleted by Admin** package chating; //import java.applet.Applet; import java.awt.event.*; import java.awt.*; import
send mail using smtp in java
send mail using smtp in java  How to send mail using smtp in java?   Sending mail in JSP - SMTP
java using jsp - Java Beginners
java using jsp  i already included those jar file into my library in eclipse.i previously send my JSP code.But it shows error like. type Exception report message description The server encountered an internal error
JSP using java - Java Beginners
JSP using java  hi...i has been created one JSp page.in this page have one links name as "Show datas in PDF format".I want to create PDF file which containing datas(from database interaction) when i clicking that link...i m using
how to get harddisk info using S.M.A.R.T using java
how to get harddisk info using S.M.A.R.T using java   how to get harddisk info using S.M.A.R.T using java
Setting the Monitor brightness using Java
Setting the Monitor brightness using Java  I am Facing problem in writing a code to change the Monitor Brightness using Java. This problem is solved using ASP.net how to change in java please give me some suggestions
JSP using java - Java Beginners
JSP using java  I want to generate chart in JSP page.My bar chart code contains the following function String series1 = "bars"; dataset.addValue(Integer.parseInt(values.get(i)),series1,(String)Values1.get(i
java programming using RMI - RMI
java programming using RMI  Write a program using RMI to sell an item to the customer remotely and don't allow the customer to purchase the item if the stock is nil , by displaying an appropriate message
Square pattern in java using for loop
Square pattern in java using for loop  please explain the logic to program the following using for loop in Java: 1 3 5 7 9 3 5 7 9 1 5 7 8 1 3 7 9 1 3 5 9 1 3 5 7
Square pattern in java using for loop
Square pattern in java using for loop  please explain the logic to program the following using for loop in Java: 1 3 5 7 9 3 5 7 9 1 5 7 8 1 3 7 9 1 3 5 9 1 3 5 7
Square pattern in java using for loop
Square pattern in java using for loop  please explain the logic to program the following using for loop in Java: 1 3 5 7 9 3 5 7 9 1 5 7 8 1 3 7 9 1 3 5 9 1 3 5 7
Square pattern in java using for loop
Square pattern in java using for loop  please explain the logic to program the following using for loop in Java: 1 3 5 7 9 3 5 7 9 1 5 7 8 1 3 7 9 1 3 5 9 1 3 5 7
 

 

 

DMCA.com