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



Home Answers Viewqa Java-Beginners Using a variable filename
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Mona Zak
Using a variable filename
1 Answer(s)      4 years and 2 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
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
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
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
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
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
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
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
Java variable
Java variable   To what value is a variable of the String type automatically initialized
Pointer a variable
Pointer a variable  hii, Pointer is a variable or not ?   hello, Yes, a pointer is a variable
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
environment variable
environment variable  what are the environment variable is need to run j2ee application in eclipse could you explain the details
final variable
final variable  Please give some easiest and understanding example program for final variable
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
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
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
global variable in objective c
global variable in objective c  Declaring global variable in objective c
define string variable in php
define string variable in php  how to define string variable in PHP
static variable in php
static variable in php  How can i call a global variable as a static variable
php variable functions
php variable functions  Setting a variable in a class function, where can I use that variable
 

 

 

DMCA.com