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");
}
}
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");
}
}
读: System.getProperties(key);
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();
}
public String getStr(){
return yourJTextField.getText();
}
private
logonFrame logon;
public
void setlogonFrame(logonFrame logon){
this.logon = logon;
}mainFrame main=new mainFrame();
logonFrame logon=new logonFrame();
main.setlogonFrame(logon);
在MainFrame中用 static String s1;
LogonFrame tt1=new LogonFrame(s);
s1=tt1.str;这样就可以了,我做的也有这个