Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MainFrame extends javax.swing.JFrame{
- }
- //create this class to store data
- public class Dataset{
- private static Dataset instance = new Dataset();
- private Competition comp = new Competition();
- //private the constructor to make it a singleton
- private Dataset(){
- }
- public static getInstance(){
- return instance;
- }
- public Competition getCompetition(){
- return comp;
- }
- }
- //another third JFrame class or a JDialog class, that has a JButton, when you press it
- // you want to create a new Swimmer object and store it in some list
- public class AddSwimmerDialog extends javax.swing.JDialog {
- .....
- private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
- //you create the object
- Swimmer s = new Swimmer();
- //now you need to store somewhere
- Dataset.getInstance().getCompetition().swimmers.add(s);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement