Advertisement
ManZzup

Untitled

Oct 6th, 2015
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.69 KB | None | 0 0
  1. public class MainFrame extends javax.swing.JFrame{
  2.         private Competition comp = new Competition();
  3.     public MainFrame instance = null;
  4.  
  5.     //we set the instance to current instance of MainFrame in constructor
  6.     public MainFrame(){
  7.         instance = this;
  8.     }
  9.  
  10.     public Competition getCompetition(){
  11.         return comp;
  12.     }
  13. }
  14.  
  15. public class AddSwimmerDialog extends javax.swing.JDialog {
  16.         .....
  17.         private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
  18.                 //you create the object
  19.                 Swimmer s = new Swimmer();
  20.                 //now you need to store somewhere
  21.                 MainFrame.instance.getCompetition().swimmers.add(s);
  22.         }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement