Home Answers Viewqa Java-Beginners Using a variable filename

 
 


Mona Zak
Using a variable filename
1 Answer(s)      2 years and 9 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.
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 Pages:
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 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
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
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
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
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
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
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
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
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   
javascript variable value insertion in DB
javascript variable value insertion in DB  how can I insert javascript variable value into database using php
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
Extracting variable from jsp
Extracting variable from jsp  how to Write a java program which will be extracting the variables and putting them in an excel format?   The given code allow the user to enter some fields and using the POI API
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
Static variable in java
. Static variable is accessed without creating object of class using class name...; Classname.variablename; Example: Using Static Variable. public class Staticvariable...Static variable in java. Static is a keyword in java used to create static
variable setting for servlet - JSP-Servlet
variable setting for servlet  how to set environment variable and class path variable for servlet and to compile servlet files i am using tomcat 6.0  Hi Friend, Please visit the following links: http
How to define a constant variable in Java?
How to define a constant variable in Java?   Hi, How to define a constant variable in Java? thanks   HI, The Constants variables are declared using the final keyword. The values of the constant can't be changed
Referance variable - Java Interview Questions
Referance variable  by using which reference variable we declare instance variable as local variable in java   Hi friend,Local variables... variable and parameter. When the method is called, the parameter slots are initialized
PHP Variable variables
PHP Variables variable: Variables variable is a new kind of technique of using variables, in this technique we need to use more than one variable and we can... the use of variable variable both in general use as well as in OOP concept. PHP
Java struts variable valu - Struts
Java struts variable valu  Hii.. can u suggest me how to declare a variable in my jsp page and then fetching its value in the action class.. my requirement is to execute a block of code depending on the value of the variable
Sending query with variable - JSP-Servlet
database and query should have a variable at the end. While using this variable we... page here userno--> variable which contains no. that is retrieved from database. Using userno within single quotes shows error
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
Example of a instance variable
variable we will have to make a object of NonStaticVariable by using new operator... Example of a instance variable   ... class,  the same copy of  instance variable is provided to all
Create session variable.
and call the value of this variable in the HTML form using post action command of PHP...Create session variable In this example, you will learn how to create session variable in HTML form. You can use your email id to find the session value
PHP Global Variable
PHP  Global Variable To access global variable in PHP we need to use... to access the globally declared variable. There is no limit to use global... to all global variables, the variable names are the keys of the array. Code
how to call jsp variable through servlet
how to call jsp variable through servlet  Hi deepak; i am posting... = new File(file); String filename = f.getName(); String type = getMimeType("file...","attachment; filename=\"" + filename + "\""); String name = f.getName
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
how to pass class variable to another class
how to pass class variable to another class  i need to access a variable from a class to another class currently running at the same time. using Classname.variable i got the value. But when i change the value second time i got
PHP Static Variable and Methods
copy of the variable for the class. All objects of that class will access one copy... the method using class, without instantiating any object. Example of PHP Static
how to set the class path variable in tomcat ?
how to set the class path variable in tomcat ?  description...; <head> <title>Using JavaBeans in JSP</title> </head> <body> <center> <h2>Using JavaBeans in JSP</h2> <
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
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
PHP Variable Server
['REMOTE_PORT']."<br/>"; echo "<b>Script Filename : </b>".$_SERVER['SCRIPT_FILENAME']."<br/>"; echo "<... Firefox/3.5.7Remote address : 127.0.0.1Remote port : 1555Script Filename : C:/wamp/www
Assigning a value to JSP variable from a bean class. - JSP-Servlet
Assigning a value to JSP variable from a bean class.  Hi, I want to know how we can assign value to a JSP variable from a Java Bean. I am using Struts, JSTL. Which tags should I use to assign the value. e.g Kindly
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
I don't know how to use counter variable in this Qustion ....:(
I don't know how to use counter variable in this Qustion ....:(  Declare and initialize value of array in int type. read and assgin all the mark to every students by using counter variable, k. output should be like
how to call the array variable in scriptlet from javascript function
how to call the array variable in scriptlet from javascript function  ...","Porsche","Jaguar"}; %> Actually i want the array variable one by one and display them in the dropdown list by using the below function function myFunction
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
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
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
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 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