Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-04-2008, 07:33 PM
Member
 
Join Date: Dec 2007
Posts: 6
Lehane_9 is on a distinguished road
getting the value of variable
public void actionPerformed(ActionEvent e)
{

if (!txtBox.getText().equals("")){
int a = 0;

for(int i = 0; i < combo.getItemCount(); i++){
if(combo.getItemAt(i).equals(txtBox.getText())){
a = 1;
break;
}
}
if (a == 1)
JOptionPane.showMessageDialog(null,"Combo has already this item.");

else

combo.addItem(txtBox.getText());

// I want to store the value of txtBox.text(), to an array and then to a file,
if some could show me how to do this it would be appreciated as i have tried for about an hour and a half myself.
thank you in advance!!
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 03-04-2008, 09:26 PM
gibsonrocker800's Avatar
Senior Member
 
Join Date: Nov 2007
Location: New York
Posts: 143
gibsonrocker800 is on a distinguished road
Send a message via AIM to gibsonrocker800
Well, what do you about arrays, and FileWriting?

If you don't know how to use arrays, you should learn how. And, you will need to learn about the FileWriter class. (Or BufferedWriter, or PrintWriter).

Just let us know what you know so we can assist you.
__________________
//Haha javac, can't see me now, can ya?
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 03-05-2008, 02:42 AM
Member
 
Join Date: Dec 2007
Posts: 30
Leprechaun is on a distinguished road
You'll probably want an array list since you don't know how many items you'll be getting.
Quote:
import java.util.ArrayList; // import
ArrayList<String> items = new ArrayList<String>(); // how to declare one
and then each time you find a new item and add it to the combo just add this line with it:
Quote:
items.add(txtBox.getText());
As for writing it to a file, that's kind of complicated...
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Increment a Variable rhm54 New To Java 2 06-14-2008 03:57 AM
Getting variable value from a variable name Java Tip Java Tips 0 02-16-2008 10:26 PM
Variable No. of Arguments Gajesh Tripathi New To Java 2 10-31-2007 03:50 PM
Create a new variable mathias New To Java 1 08-07-2007 07:48 AM
String Variable Eric Advanced Java 1 06-06-2007 05:30 AM


All times are GMT +3. The time now is 02:55 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org