logonframe:import com.cloudgarden.layout.AnchorLayout;
import com.cloudgarden.layout.AnchorConstraint;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.BorderLayout;/**
* This code was generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a
* for-profit company or business) then you should purchase
* a license - please visit www.cloudgarden.com for details.
*/
public class logonJFrame extends javax.swing.JFrame { private JButton jButton1;
private JTextField jTextField1;
public logonJFrame() {
initGUI();
} /**
* Initializes the GUI.
* Auto-generated code - any changes you make will disappear.
*/
public void initGUI(){
try {
preInitGUI();

jButton1 = new JButton();
jTextField1 = new JTextField();

AnchorLayout thisLayout = new AnchorLayout();
this.getContentPane().setLayout(thisLayout);
this.setSize(new java.awt.Dimension(375,268));

jButton1.setText("jButton1");
jButton1.setVisible(true);
jButton1.setPreferredSize(new java.awt.Dimension(82,20));
jButton1.setBounds(new java.awt.Rectangle(218,124,82,20));
this.getContentPane().add(jButton1, new AnchorConstraint(516,816, 599, 593, 1, 1, 1, 1));
jButton1.addActionListener( new ActionListener() {
public void actionPerformed(ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});

jTextField1.setVisible(true);
jTextField1.setPreferredSize(new java.awt.Dimension(87,20));
jTextField1.setBounds(new java.awt.Rectangle(78,54,87,20));
this.getContentPane().add(jTextField1, new AnchorConstraint(226,449, 309, 213, 1, 1, 1, 1));

postInitGUI();
} catch (Exception e) {
e.printStackTrace();
}
}
/** Add your pre-init code in here  */
public void preInitGUI(){
} /** Add your post-init code in here  */
public void postInitGUI(){
} /** Auto-generated main method */
public static void main(String[] args){
showGUI();



}
public static void showGUI(){
try {
logonJFrame inst = new logonJFrame();
inst.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
/** Auto-generated event handler method */
protected void jButton1ActionPerformed(ActionEvent evt){
//TODO add your handler code here
this.setVisible(false);
try {
MainJFrame inst = new MainJFrame();
inst.setVisible(true);
inst.jTextFieldMain.setText(this.jTextField1.getText());
} catch (Exception e) {
e.printStackTrace();
}
}
}mainframe:import javax.swing.JTextField;
import com.cloudgarden.layout.AnchorConstraint;
import com.cloudgarden.layout.AnchorLayout;
import javax.swing.JTextField;
import java.awt.event.InputMethodListener;
import java.awt.event.InputMethodEvent;
import javax.swing.event.AncestorListener;
import javax.swing.event.AncestorEvent;
import java.awt.BorderLayout;/**
* This code was generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a
* for-profit company or business) then you should purchase
* a license - please visit www.cloudgarden.com for details.
*/
public class MainJFrame extends javax.swing.JFrame { public JTextField jTextFieldMain;
public MainJFrame() {
initGUI();
} /**
* Initializes the GUI.
* Auto-generated code - any changes you make will disappear.
*/
public void initGUI(){
try {
preInitGUI();

jTextFieldMain = new JTextField();

AnchorLayout thisLayout = new AnchorLayout();
this.getContentPane().setLayout(thisLayout);
this.setSize(new java.awt.Dimension(375,268));

jTextFieldMain.setText("jTextFieldMain");
jTextFieldMain.setVisible(true);
jTextFieldMain.setPreferredSize(new java.awt.Dimension(106,20));
jTextFieldMain.setBounds(new java.awt.Rectangle(127,60,106,20));
this.getContentPane().add(jTextFieldMain, new AnchorConstraint(251,634, 334, 346, 1, 1, 1, 1));

postInitGUI();
} catch (Exception e) {
e.printStackTrace();
}
}
/** Add your pre-init code in here  */
public void preInitGUI(){
} /** Add your post-init code in here  */
public void postInitGUI(){
}
/** Auto-generated event handler method */
protected void jTextFieldMainAncestorMoved(AncestorEvent evt){
//TODO add your handler code here
System.out.println("ss");
}
}

解决方案 »

  1.   

    写:System.getProperties().setProperty(key,value);
    读: System.getProperties(key);
      

  2.   

    其实就是把mainframe的jtextfield定义成一个public的,然后在logonframe的点击button事件里面显示mainframe,然后再把logonframe的中的一个jtextfield值传给mainframe中的那个public的jtextfield。
      

  3.   

    我可能是理解错误楼主的意思了,我以为是两个frame中都有个textfield框呢,其实可以在mainframe中定义一个变量例如:
    private String strLogon="";
    public void setstrLogon(String strin){
     this.strLogon = strin;
    }在logonframe中的例如是在点击button时,调用这个方法:
    try {
    MainJFrame inst = new MainJFrame();
    inst.setVisible(true);
    nst.setstrLogon(this.jTextField1.getText());
    } catch (Exception e) {
    e.printStackTrace();
    }
      

  4.   

    写个getStr不就得了
    public String getStr(){
    return yourJTextField.getText();
    }
      

  5.   

    可以用一个frame做另一个frame的监听器
      

  6.   

    简单的说,就是在mainFrame中增加一个对logon的引用,需要时就通过这个引用访问logon 。如下:在mainFrame中增加一个字段和set方法:
    private
       logonFrame logon;
    public 
       void setlogonFrame(logonFrame logon){
          this.logon = logon;
       }mainFrame main=new mainFrame();
    logonFrame logon=new logonFrame();
    main.setlogonFrame(logon);
      

  7.   

    在LogonFrame中用str=new String(text1.getText());语句把植赋给str
    在MainFrame中用 static String s1; 
                  LogonFrame tt1=new LogonFrame(s);
                  s1=tt1.str;这样就可以了,我做的也有这个
      

  8.   

    问题解决了,只是按照topil(认认真真学习,塌塌实实工作) 的方法比较简单,其他的应该也可以,我就没试了,谢谢大家!
      

  9.   

    问题解决了,只是按照topil(认认真真学习,塌塌实实工作)  的方法比较简单,其他的应该也可以,我就没试了,谢谢大家!
      

  10.   

    问题解决了,只是按照topil(认认真真学习,塌塌实实工作)    的方法比较简单,其他的应该也可以,我就没试了,谢谢大家!