File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Trouble understanding passing values Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Trouble understanding passing values" Watch "Trouble understanding passing values" New topic

Trouble understanding passing values

Vinny Delane

Joined: May 08, 2006
Posts: 2
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);
} catch(IOException ex) {
addButtons(contentPane); /* here is the PAIN */
Justin Fox
Ranch Hand

Joined: Jan 24, 2006
Posts: 802
i have no idea what is going on, what are you trying to do?

read button names from a file?

then create them?


You down with OOP? Yeah you know me!
Garrett Rowe
Ranch Hand

Joined: Jan 17, 2006
Posts: 1296
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.

Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peter
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
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

Joined: May 09, 2006
Posts: 2
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

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

Joined: Sep 16, 2005
Posts: 1780
Can you post a minimal, complete example program that demonstrates your problem?
I agree. Here's the link:
subject: Trouble understanding passing values
jQuery in Action, 3rd edition