Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Spring Framework | Web Services | BioInformatics | Java Server Faces | Jboss 3.0 tutorial | Hibernate 3.0 | XML

Tutorial Categories: Ajax | Articles | JSP | Bioinformatics | Database | Free Books | Hibernate | J2EE | J2ME | Java | JavaScript | JDBC | JMS | Linux | MS Technology | PHP | RMI | Web-Services | Servlets | Struts | UML

Fresher Job


 

Search Host

Monthly Fee($)
Disk Space (MB)
Register With us for Newsletter!
Visit Forum! Post Questions!
Jobs At RoseIndia.net!

Have tutorials?
Add your tutorial to our Java Resource and get tons of hits.

We offer free hosting for your tutorials. and exposure for thousands of readers. drop a mail
roseindia_net@yahoo.com
 
   

Tutorials

Java Server Pages

JAXB

Java Beans

JDBC

MySQL

Java Servlets

Struts

Bioinformatics

Java Code Examples

Interview Questions

 
Join For Newsletter

Powered by groups.yahoo.com
Visit Group! Post Questions!

Web Promotion

Web Submission

Submit Sites

Manual Submission?

Web Promotion Guide

Hosting Companies

Web Hosting Guide

Web Hosting

Linux

Beginner Guide to Linux Server

Frameworks

Persistence Framework

Web Frameworks

Free EAI Tools

Web Servers

Aspect Oriented Programming

Free Proxy Servers

Softwares

Adware & Spyware Remover

Open Source Softwares

AWT code for popUpmenu
Expert:Gopi
Respected Sir/Madam,
I am writing a program in JAVA/AWT.My requirement is, a Form consists of a "TextBox" and a "Button". When user clicks the Button a "popUp" window should appear for selecting a "file" from any of the location of the "computer".Now the user selects a particuler file from that menu and the 'path of that file' should automatically loaded in to the "Text Box" of the form.Any help will be greatly appreciated.Please send me the code.

ThanQ.
Answers
import java.awt.BorderLayout;
import java.awt.Button;
import java.awt.FileDialog;
import java.awt.Frame;
import java.awt.TextField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

public class Demo
{
public static void main(String[] args)
{
final Frame frame = new Frame("Demo");
final TextField textField = new TextField();
textField.setEditable(false);
Button button = new Button("Open");
button.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent actionEvent)
{
FileDialog fileDialog = new FileDialog(frame," Open",FileDialog.LOAD);
fileDialog.setVisible(true);
String directory = fileDialog.getDirectory();
if(directory != null)
textField.setText(directory + fileDialog.getFile());
}
});
frame.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent windowEvent)
{
frame.dispose();
}
});
frame.setLayout(new BorderLayout());
frame.add(BorderLayout.CENTER,textField);
frame.add(BorderLayout.SOUTH,button);
frame.setSize(200,100);
frame.setResizable(false);
frame.setVisible(true);
button.requestFocusInWindow();
}
}

-Ramesh A.V



Read for more information.


http://www.roseindia.net/java/example/java/awt/pop-up.shtml



Thanks.

More Questions
Post Answers
 
Ask Question Facing Programming Problem?
Useful Links
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification

Tell A Friend
Your Friend Name
Search Tutorials

 

 
 
Browse all Java Tutorials
Java JSP Struts Servlets Hibernate XML
Ajax JDBC EJB MySQL JavaScript JSF
Maven2 Tutorial JEE5 Tutorial Java Threading Tutorial Photoshop Tutorials Linux Technology
Technology Revolutions Eclipse Spring Tutorial Bioinformatics Tutorials Tools SQL
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2007. All rights reserved.