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



Home Answers Viewqa Swing-AWT AWT code for popUpmenu
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Gopi
AWT code for popUpmenu
2 Answer(s)      6 years and 4 months ago
Posted in : Swing AWT



Advertisement
View Answers

July 23, 2008 at 4:54 PM


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


July 23, 2008 at 6:59 PM




Related Tutorials/Questions & Answers:
AWT code for popUpmenu - Swing AWT
AWT code for popUpmenu  Respected Sir/Madam, I am writing a program... the code. ThanQ.   import java.awt.BorderLayout; import... for more information. http://www.roseindia.net/java/example/java/awt/pop
provide code - Swing AWT
provide code  Dear frnds please provide code for two player CHESS GAME.....using swings,awt concepts   Hi friend, import java.awt.*; import java.awt.event.*; import java.util.*; import javax.swing.*; public
Advertisements
source code - Swing AWT
source code  source code for a program to shutdown, restart, log off the pc after clicking jbutton on jpanel or a jframe by user. thanks in advance
java code - Swing AWT
to open the lock  Hi Friend, Try the following code: class
java code - Swing AWT
java code  Hello .anyone can plz tell me code for this .First create a button wen it is clicked its enters into another window asking for Name .After...   Hi Friend, Try the following code: import java.io.*; import
java code - Swing AWT
java code  i want to open a new dialog box after clicking "upload" button, it should have a text field, browse button to browse the file from directory  Hi Friend, Try the following code: 1)OpenDialog.java import
Java Code - Swing AWT
Java Code  How to Display a Save Dialog Box using JFileChooser and Save the loaded Image from Panel in any Location.  Hi Friend, Try the following code: import java.io.*; import java.awt.*; import java.util.
game programming code - Swing AWT
game programming code  write a snake program using swings with step by step explanation?. please send me this source code to my mail id with step by step explanation
Need source code - Swing AWT
Need source code  Hai, I need a source code for developing the project, title is "Face Recognition" and the backend as My-sql.... Thanks & Regards
Need source code - Swing AWT
Need source code  Hai, I need a idea and code for developing the project "Face Recognition" with the backend as My-sql.... Thanks & Regards
Need source code - Swing AWT
Need source code  Hai friends, How can I, view all the datas from the mysql database table in the jframe........  Hi Friend, Try the following code: import java.awt.*; import java.sql.*; import
Need source code - Swing AWT
Need source code  Hai, In java swing, How can upload and retrieve the images from the mysql database?   Hi Friend, To upload and insert image in database, try the following code: import java.sql.*; import
AWT
AWT  How to set size of button in awt
awt
Java AWT Applet example  how to display data using JDBC in awt/applet
awt
JDBC and AWT to display data  how to display data using JDBC in awt/applet
awt
JDBC in awt applet  how to display data using JDBC in awt/applet
awt
JDBC in awt  how to display data using JDBC in awt/applet
"Urgent" convert this code to GUI - Swing AWT
"Urgent" convert this code to GUI   please convert for me this code to GUI THE CODES ARE BELOW, CLASS ATMCaseStudy is the driver class that runs all the other classes. its very urgent. //CLASS CashDispenser public class
please convert for me this code to GUI - Swing AWT
please convert for me this code to GUI    THE CODES ARE BELOW, CLASS ATMCaseStudy is the driver class that runs all the other classes. its very urgent. // class ATM import javax.swing.*; import java.awt.*; public
please convert for me this code to GUI - Swing AWT
please convert for me this code to GUI  THE CODES ARE BELOW, CLASS ATMCaseStudy is the driver class that runs all the other classes. its very urgent. // class ATM import javax.swing.*; import java.awt.*; public class ATM
how to include a session class in java awt code - JavaMail
how to include a session class in java awt code  Hi... i have been developing a mini online shopping tool using java awt and websphere MQ as middleware technology.. Iam facing problem in handling MQ calls ...so i need
code to display images using 2d array - Swing AWT
code to display images using 2d array  HI !! I have an image file... to display this using java code. I am relatively new to coding such requirements. Can anyone please tell me how to go about it ? Explanation of the code
java awt calender
java awt calender  java awt code for calender to include beside a textfield
AWT & SWING
AWT & SWING  What is diffennce between AWT & SWING
AWT programmes - Swing AWT
AWT programmes  I need few programs for menus in AWT. how to open a filed dialog window, and how to save a image in the save window when we press... has all AWT programms which must open,save and make changes to a particular
awt - Swing AWT
awt  dear sir my proble is , i have applet code which is stock market chart this code made using "AWT" . in this chart one textbox when user.../java/awt/ Thanks
Java AWT Package Example
Java AWT Package Example       In this section you will learn about the AWT package of the Java. Many running examples are provided that will help you master AWT package. Example
Advertisements
 

 

 

DMCA.com