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



Home Answers Viewqa Java-Beginners Using a variable filename

Have Programming Question? Ask it here!
 
 
 


Mona Zak
Using a variable filename
1 Answer(s)      3 years and 7 months ago
Posted in : Java Beginners


Dear sir, my program a JFrame containes of 3 JTextFields and 2 different JButtons intend to sends data to 2 Input files. The program should work like that: when I enter a data to the JTextFields and click button1, the data should write to data1.txt file. and when enter other data and click button2, it should go to data2.txt file. Can you please help me with what to do to make each JButton performs its action with its own file.
Thank you very much.

Advertisement
View Answers

September 14, 2010 at 3:56 PM


Hi!!!I am providing you the logic of your program.At first you add action listeners with your buttons.Now in the method actionPerformed() you must have a mean to detect which button has been clicked(either by making the buttons global variable and using the code e.getSource()==<reference variable of the button> or by associating two distinct action commands with the two buttons and using the code e.getActionCommand().equals(<action command>)).After detecting the butoon continue with your logic for the specified button.


Related Tutorials/Questions & Answers:
Using a variable filename - Java Beginners
Using a variable filename  Dear sir, my program a JFrame containes... the buttons global variable and using the code e.getSource()== or by associating two distinct action commands with the two buttons and using the code
using variable loop
using variable loop  program to print alphabets from a-z along with ASCII codes of each alphabets in two columns using a character variable loop...can anyone help me
Advertisements
Using Unicode Variable Names - Java Tutorials
Using Unicode Variable Names 2001-11-23 The Java Specialists' Newsletter [Issue 036] - Using Unicode Variable Names Author: Dr. Heinz M. Kabutz... members are currently subscribed from 56 countries Using Unicode Variable
Printing Session Id Using Variable
Printing Session Id Using Variable  Hi, I am a learner in PHP language. Could any one guide me, how to print session Id using variable in PHP. Thanks
using session variable determine the no of pages viewd by the user
using session variable determine the no of pages viewd by the user  using session variable determine the no of pages viewd by the user   Hi Friend, Please visit the following link: http://www.roseindia.net/tutorial
Swap two numbers without using third variable
Swap two numbers without using third variable In this section we are going to swap two variables without using the third variable. For this, we have used... from the command prompt. Instead of using temporary variable, we have done some
How to set a variable value using velocity
How to set a variable value using velocity       This Example shows you how to set variable value using velocity. The method used in this example are described below:- 1
Printing username,email Id using session variable.
Printing User Name, Email Id and Address using session variable Using $session() function, we can print user name, email id and address of the user.  <?php session_start (); #session start $email= "raj@rediffmail.com
Converting a Filename to a URL
Converting a Filename to a URL       A file object is used to a give a filename. Creating the File... MalformedException. After this we will convert this URL to a file object by using getFile
Local Variable and Instant Variable
Local Variable and Instant Variable  difference between Local Variable and Instant Variable   Difference between local variable and instance variable Instance variable is declared within a class but not within
How to get filename in JTextArea in following case?
How to get filename in JTextArea in following case?  Hi, i'm... java.awt.*; import javax.swing.*; import java.awt.event.*; class FileName extends... pane; FileName(){ setLayout(null); JTextAreaOutputDirectory=new
Determining if a Filename path is a file or a directory
Determining if a Filename path is a file or a directory       You can solve this problem very easily... or a directory in it. We are using a following methods to solve this problem
Java get Filename without Extension
Java get Filename without Extension   ... the filename without extension. For this, the file name or the directory name...() {   String fileName="C:\\anu\\My\\Hello.txt";   File file = new File(fileName
unable to display image using html tag in servlet.(image src is in a variable.....). i am using netbeans IDE. plz..........do help
unable to display image using html tag in servlet.(image src is in a variable.....). i am using netbeans IDE. plz..........do help  import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException
Pointer a variable
Pointer a variable  hii, Pointer is a variable or not ?   hello, Yes, a pointer is a variable
Java variable
Java variable   To what value is a variable of the String type automatically initialized
Converting jsp variable to java variable
Converting jsp variable to java variable  Hi how to convert java script variable to java variable on same jsp page
Application Variable
Application Variable  I have multiple JSP's that are connected to a Database specifically MSSQL, I connect to the DB using a property file containing... anyone show a simple sample code of storing the connection data in a variable so
Passing variable
Passing variable  How to pass variable to HTTP object in HTMl or PHP
final variable
final variable  Please give some easiest and understanding example program for final variable
environment variable
environment variable  what are the environment variable is need to run j2ee application in eclipse could you explain the details
environment variable
environment variable  what is environment variable in java?   Environment variables are used by the Operating System to pass configuration information to applications
Static Variable
Static Variable  What is the basic use of introducing static variable... that a certain object/variable is resident in memory and accessed each time an instance..., it means that the static variable is shared among all instances of the class
How to resolve this error The filename, directory name, or volume label syntax is incorrect
How to resolve this error The filename, directory name, or volume label syntax is incorrect  Image is stored in physical directory like this String...\website\screenshots\amit1220120625_110414.PNG (The filename, directory name, or volume
variable for cookie.setDomain - JSP-Servlet
variable for cookie.setDomain  I want to create a variable to use inside the following statement: cookie.setDomain(".mydomain.com"); Users will be hitting different sites using the same code for all. Any suggestions would
how to assign javascript variable value to a jsp variable
how to assign javascript variable value to a jsp variable  how to assign javascript variable value to a jsp variable
Variable Names
Java Notes Variable Names Basic variable naming conventions Choosing good names is probably..., these variable naming conventions are almost always used. Here is what
javascript variable value insertion in DB
javascript variable value insertion in DB  how can I insert javascript variable value into database using php
JavaScript display variable in alert
variable is declared by using var keyword.This variable can hold any type of value...JavaScript display variable in alert  How to display variable in alert box? I am using javascript.   <html> <head> <script
define string variable in php
define string variable in php  how to define string variable in PHP
global variable in objective c
global variable in objective c  Declaring global variable in objective c
php variable functions
php variable functions  Setting a variable in a class function, where can I use that variable
static variable in php
static variable in php  How can i call a global variable as a static variable
Flex Variable Scope
Scope of the variable defines the accessibility of the variable across the application. The global variable has global access to the application and local variable is restricted to the block of code only. The variable defined outside
JSP Variable in Javascript
variable using alert box. Understand with Example  In this section, we... the value of string variable using the alertbox on loading the function.  ... JSP Variable in Javascript   
how to inherit static variable
how to inherit static variable   how to inherit static variable or methods in Java?? Please explain the entire process of inheriting the variable. Thanks in advance
php search variable
php search variable  Search variable in PHP
variable function in php
variable function in php  Can any one tell me how to write a variable function in PHP?   Go through the PHP Variable function tutorial ... PHP Variable Function
php variable scope
php variable scope  How can i access a variable from scope of another function
php variable in javascript
php variable in javascript  Access php variables in Javascipt or Jquery rather than php echo $variable
variable types in php - PHP
variable types in php  Do i need to explicitly specify the variable type in PHP
variable function in php
variable function in php  Can any one tell me how to write a variable function in PHP
STATIC VARIABLE DECLARATION
STATIC VARIABLE DECLARATION  why cannot the static variable declare inside the method
variable declaration in c and c++
variable declaration in c and c++  Comparison and an example of variable declaration in C and C
What is the importance of static variable?
What is the importance of static variable?  hi, What is the importance of static variable? thanks
What is use of a abstract variable?
What is use of a abstract variable?   Hi, What is use of a abstract variable? thanks
What is use of a abstract variable?
What is use of a abstract variable?   Hi, What is use of a abstract variable? thanks
Serialize the static variable
Serialize the static variable  hello, Can we serialize the static variable?   hii Yes we can serialize the static variable. if u don't want to serialize, u need to declare the variable as transient
php a href variable
php a href variable  href variable PHP.. please explain
php define variable
php define variable  How to define a simple and a global variable in PHP
Advertisements
 

 

 

DMCA.com