English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

how can i put a value from a JFrame to a textfield in another JFrame? For example, the value is in MainGUI JFrame and i want to put the value in MainGUI to the textfield in ComputeGUI JFrame...tnx...

2007-08-23 21:40:06 · 2 answers · asked by ♥♫HiKaRu_ShiDoU♫♥ 3 in Computers & Internet Programming & Design

2 answers

If you want to copy the value at specific times when you'll already have control, then just keep track of the source JTextField when you construct one JFrame, and the target JTextField when you construct the other JFrame. Then you can just copy from one to the other.

If you want to be notified whenever the first JTextField changes, you'll have to add an ActionListener to the first JTextField that will update the second one as necessary.

2007-08-24 01:37:19 · answer #1 · answered by McFate 7 · 2 0

Pass the value "String" into the constructor of ComputeGUI and make a global variable within ComputeGUI equal to the value your passing. Then you can do what you want with the value "String".

public class ComputeGUI extends JFrame {

private String blah;

public ComputeGUI(String val){
blah = val;
}

}

2007-08-24 05:09:25 · answer #2 · answered by Anonymous · 0 0

fedest.com, questions and answers