Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Trouble understanding passing values

 
Vinny Delane
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I seem to have two major problems leaning Java. I am using only a single window. I call a medthod from 'main' like addButtons(contentPane); it works, but if I call it from:

private void writeButtons(){
//read the string of all three buttons
String button0 ="";
String button1 ="";
String button2 ="";
String filestring ="";
Container contentPane;

contentPane = getContentPane();
button0 = JOptionPane.showInputDialog(null, "Enter Left buttons name");

button1 = JOptionPane.showInputDialog(null, "Enter Center buttons name");

button2 = JOptionPane.showInputDialog(null, "Enter Right buttons name");
//write them to the root directory filename.
try {
FileWriter writer = new FileWriter("c:/buttons.txt");
//JOptionPane.showMessageDialog(null, button0 + "\n" + button1 + "\n" + button2);
filestring = ( button0 + "\n" + button1 + "\n" + button2);
writer.write(filestring);
writer.close();
} catch(IOException ex) {
ex.printStackTrace();
}
addButtons(contentPane); /* here is the PAIN */
}
 
Justin Fox
Ranch Hand
Posts: 802
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have no idea what is going on, what are you trying to do?

read button names from a file?

then create them?

-Justin-
 
Garrett Rowe
Ranch Hand
Posts: 1296
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It would probably help if you showed the code for the addButtons() method. And when positng code, please use code tags. It increases the legibility of the code and increases the chance that someone who knows the answer to your question won't skip over your post.
 
Jeff Albertson
Ranch Hand
Posts: 1780
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to feel your "PAIN".
It would help if you could explain.

What would help the most is a minimal example program deomstrating your problem that forum members could run. This cuts down on the wild speculation we have to go thought when you write about an unspecified method of yours that doesn't work. Can you see our point of view?
 
Vincent Delane
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry guys i;m new, but love this Java.

1. I have to read a file from disk to and array to "name" the buttons.
2. I've done the read and writes.
3. I've checked the file and array and it is correct
4. The problem is how do I "refresh' the buttons new text??

ex. button 1 = vinny
button 2 = laura
button 3 = samantha

NOW i use the option menu and change the C:/buttons.txt file
rachel
tony
ginger

I read the buttons again but they do not refresh. If i quit the program
and start again the 'new' names appear.
 
Jeff Albertson
Ranch Hand
Posts: 1780
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you post a minimal, complete example program that demonstrates your problem?
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic