import javax.swing.SwingUtilities; import java.awt.BorderLayout; import javax.swing.JPanel; import javax.swing.JFrame; import javax.swing.JButton; import java.awt.Rectangle; public class B extends JFrame { private static final long serialVersionUID = 1L; private JPanel jContentPane = null; private JButton jButton = null; private A a; /** * This is the default constructor */ public B(A classeA) { super(); a=classeA; initialize(); } /** * This method initializes jButton * * @return javax.swing.JButton */ private JButton getJButton() { if (jButton == null) { jButton = new JButton(); jButton.setBounds(new Rectangle(55, 37, 128, 60)); jButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { A a=new A(); a.getJTextField().getText(); System.out.println("actionPerformed()"+a.getJTextField().getText()+"fffffff"); // TODO Auto-generated Event stub actionPerformed() } }); } return jButton; } public static void main(String[] args) { // TODO Auto-generated method stub SwingUtilities.invokeLater(new Runnable() { public void run() { B thisClass = new B(); thisClass.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); thisClass.setVisible(true); } }); } /** * This method initializes this * * @return void */ private void initialize() { this.setSize(300, 200); this.setContentPane(getJContentPane()); this.setTitle("JFrame"); } /** * This method initializes jContentPane * * @return javax.swing.JPanel */ private JPanel getJContentPane() { if (jContentPane == null) { jContentPane = new JPanel(); jContentPane.setLayout(null); jContentPane.add(getJButton(), null); } return jContentPane; } }
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question