View_Class

    1| import java.awt.*;
    2| import javax.swing.*;
    3| 
    4| public class View_Class extends JFrame
    5| {
    6|     final static long serialVersionUID = 5;
    7| 
    8|     final int iTF = 6;
    9| 
  10|     //Layout system
  11|     Container oCont;
  12|     BorderLayout oBL;
  13|     JPanel oJP1;
  14|     JPanel oJP2;
  15|     GridLayout oGL1;
  16|     FlowLayout oFL1;
  17| 
  18|     //GUI Widgets
  19|     JButton btnCalc;
  20|     JButton btnReset;
  21|     JTextField[] oTF = new JTextField[iTF];
  22|     JLabel lblImage;
  23| 
  24|     public View_Class()
  25|     {
  26|         super("Powerball");
  27|         oCont = getContentPane();
  28|         oBL = new BorderLayout();
  29|         oCont.setLayout(oBL);
  30| 
  31|         //Call initialization methods
  32|         Init_JPanel1_GUI();
  33|         Init_JPanel2_GUI();
  34| 
  35|         setSize(400,300);
  36|         setVisible(true);
  37|     }
  38| 
  39|     private void Init_JPanel1_GUI()
  40|     {
  41|         oJP1 = new JPanel();
  42| 
  43|         oGL1 = new GridLayout(1,2,1,5);
  44|         oJP1.setLayout(oGL1);
  45| 
  46|         btnCalc = new JButton("Select Numbers");
  47|         oJP1.add(btnCalc);
  48| 
  49|         btnReset = new JButton("Reset");
  50|         oJP1.add(btnReset);
  51| 
  52|         oCont.add(oJP1, BorderLayout.NORTH);
  53|     }
  54| 
  55|     private void Init_JPanel2_GUI()
  56|     {
  57|         oJP2 = new JPanel();
  58| 
  59|         oFL1 = new FlowLayout();
  60|         oFL1.setVgap(75);
  61|         oJP2.setLayout(oFL1);
  62| 
  63|         for(int x= 0; x < iTF; x++)
  64|         {
  65|             oTF[x] = new JTextField(5);
  66|             oTF[x].setHorizontalAlignment(SwingConstants.CENTER);
  67|             oJP2.add(oTF[x]);
  68|         }
  69| 
  70|         Icon icoPwball = new ImageIcon(getClass().getResource("pwImage.gif"));v
  71|         lblImage = new JLabel(icoPwball);
  72|         oJP2.add(lblImage);
  73| 
  74| 
  75|         oJP2.setVisible(false);
  76| 
  77|         oCont.add(oJP2, BorderLayout.CENTER);
  78|     }
  79| 
  80| }//end of class