Advertisement
ManZzup

Untitled

Oct 6th, 2015
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.95 KB | None | 0 0
  1. public class MainFrame extends javax.swing.JFrame{
  2.        
  3. }
  4.  
  5. //create this class to store data
  6. public class Dataset{
  7.     private static Dataset instance = new Dataset();
  8.     private Competition comp = new Competition();
  9.    
  10.     //private the constructor to make it a singleton
  11.     private Dataset(){
  12.        
  13.     }
  14.    
  15.     public static getInstance(){
  16.         return instance;
  17.     }
  18.     public Competition getCompetition(){
  19.                 return comp;
  20.         }
  21.    
  22. }
  23.  
  24. //another third JFrame class or a JDialog class, that has a JButton, when you press it
  25. // you want to create a new Swimmer object and store it in some list
  26. public class AddSwimmerDialog extends javax.swing.JDialog {
  27.         .....
  28.         private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
  29.                 //you create the object
  30.                 Swimmer s = new Swimmer();
  31.                 //now you need to store somewhere
  32.         Dataset.getInstance().getCompetition().swimmers.add(s);
  33.         }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement