Advertisement
ManZzup

Untitled

Oct 6th, 2015
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.92 KB | None | 0 0
  1. //swimming competition class, that you made without UI, assume there's a Swimmer class exist already
  2. public class Competition {
  3.     public final List<Swimmer> swimmers = new ArrayList<Swimmer>();
  4.    
  5.     //All the swimming compeition based stuff here
  6.     .....
  7.     public static void main(String[] args) {
  8.         Competition comp = new Competition();
  9.         comp.swimmers.add(new Swimmer());
  10.     }
  11. }
  12.  
  13. //now the Main UI form which starts when your app starts
  14. public class MainFrame extends javax.swing.JFrame{
  15.     ....
  16. }
  17.  
  18. //another third JFrame class or a JDialog class, that has a JButton, when you press it
  19. // you want to create a new Swimmer object and store it in some list
  20. public class AddSwimmerDialog extends javax.swing.JDialog {
  21.     .....
  22.     private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
  23.         //you create the object
  24.         Swimmer s = new Swimmer();
  25.         //now you need to store somewhere
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement