package foo; /** * * @author mario */ public class Foo extends javax.swing.JFrame { /** Creates new form Foo */ public Foo() { initComponents(); } private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { Bar bar = new Bar(); bar.GetInfos(); } public void WriteToLabel(String mystring) { jLabel1.setText(mystring); } /** * @param args the command line arguments */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { Foo foo = new Foo(); foo.setVisible(true); } }); } // Variables declaration - do not modify private javax.swing.JButton jButton1; private javax.swing.JLabel jLabel1; // End of variables declaration } //======================================================================= package foo; /** * * @author mario */ public class Bar { /** Creates a new instance of Bar */ public void GetInfos() { //here i would like to call foo.WriteToLabel("string") foo.WriteToLabel("123"); } }