Black Jack - Start.java
Cerca
 











Start.java

Caricato da: Paoloricciuti
Scarica il programma completo

  1. /*
  2.  * To change this template, choose Tools | Templates
  3.  * and open the template in the editor.
  4.  */
  5.  
  6. /*
  7.  * Start.java
  8.  *
  9.  * Created on 11-mar-2010, 20.13.18
  10.  */
  11.  
  12. package blackjack.graphics;
  13.  
  14. import com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel;
  15. import java.awt.Dimension;
  16. import java.awt.Toolkit;
  17. import javax.swing.ImageIcon;
  18. import javax.swing.UIManager;
  19. import javax.swing.UnsupportedLookAndFeelException;
  20.  
  21. /**
  22.  *
  23.  * @author paolo
  24.  */
  25. public class Start extends javax.swing.JFrame {
  26.  
  27.     /** Creates new form Start */
  28.     public Start() {
  29.         try {
  30.             UIManager.setLookAndFeel(new NimbusLookAndFeel());
  31.         } catch (UnsupportedLookAndFeelException ex) {
  32.             try {
  33.                 UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
  34.             } catch (ClassNotFoundException ex1) {
  35.             } catch (InstantiationException ex1) {
  36.             } catch (IllegalAccessException ex1) {
  37.             } catch (UnsupportedLookAndFeelException ex1) {
  38.             }
  39.         }
  40.         initComponents();
  41.         this.setIconImage(new ImageIcon(getClass().getResource("/blackjack/graphics/images/icon.jpg")).getImage());
  42.         this.jLabel1.setLocation(85, 20);
  43.         this.jLabel1.setIcon(new ImageIcon(getClass().getResource("/blackjack/graphics/images/bjlogo.png")));
  44.     }
  45.  
  46.     /** This method is called from within the constructor to
  47.      * initialize the form.
  48.      * WARNING: Do NOT modify this code. The content of this method is
  49.      * always regenerated by the Form Editor.
  50.      */
  51.     @SuppressWarnings("unchecked")
  52.     // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  53.     private void initComponents() {
  54.  
  55.         jPanel1 = new javax.swing.JPanel();
  56.         jLabel1 = new javax.swing.JLabel();
  57.         jTextField1 = new javax.swing.JTextField();
  58.         jLabel2 = new javax.swing.JLabel();
  59.         jButton1 = new javax.swing.JButton();
  60.         jCheckBox1 = new javax.swing.JCheckBox();
  61.  
  62.         setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  63.         setTitle("BlackJack - by Paolo Ricciuti(C)");
  64.         setResizable(false);
  65.  
  66.         jPanel1.setBackground(new java.awt.Color(204, 0, 0));
  67.  
  68.         jLabel1.setText("jLabel1");
  69.  
  70.         jLabel2.setText("Nome:");
  71.  
  72.         jButton1.setText("Entra!");
  73.         jButton1.addActionListener(new java.awt.event.ActionListener() {
  74.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  75.                 jButton1ActionPerformed(evt);
  76.             }
  77.         });
  78.  
  79.         jCheckBox1.setBackground(new java.awt.Color(204, 0, 0));
  80.         jCheckBox1.setForeground(new java.awt.Color(240, 240, 240));
  81.         jCheckBox1.setSelected(true);
  82.         jCheckBox1.setText("Abilitare musica all'avvio");
  83.  
  84.         javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
  85.         jPanel1.setLayout(jPanel1Layout);
  86.         jPanel1Layout.setHorizontalGroup(
  87.             jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  88.             .addGroup(jPanel1Layout.createSequentialGroup()
  89.                 .addGap(37, 37, 37)
  90.                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
  91.                     .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 173, javax.swing.GroupLayout.PREFERRED_SIZE)
  92.                     .addGroup(jPanel1Layout.createSequentialGroup()
  93.                         .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  94.                             .addComponent(jCheckBox1)
  95.                             .addGroup(jPanel1Layout.createSequentialGroup()
  96.                                 .addComponent(jLabel2)
  97.                                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  98.                                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  99.                                     .addComponent(jButton1)
  100.                                     .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE))))
  101.                         .addGap(10, 10, 10)))
  102.                 .addContainerGap(48, Short.MAX_VALUE))
  103.         );
  104.         jPanel1Layout.setVerticalGroup(
  105.             jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  106.             .addGroup(jPanel1Layout.createSequentialGroup()
  107.                 .addGap(29, 29, 29)
  108.                 .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)
  109.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 41, Short.MAX_VALUE)
  110.                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  111.                     .addComponent(jLabel2)
  112.                     .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  113.                 .addGap(18, 18, 18)
  114.                 .addComponent(jButton1)
  115.                 .addGap(29, 29, 29)
  116.                 .addComponent(jCheckBox1)
  117.                 .addGap(20, 20, 20))
  118.         );
  119.  
  120.         javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  121.         getContentPane().setLayout(layout);
  122.         layout.setHorizontalGroup(
  123.             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  124.             .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  125.         );
  126.         layout.setVerticalGroup(
  127.             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  128.             .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  129.         );
  130.  
  131.         pack();
  132.     }// </editor-fold>//GEN-END:initComponents
  133.  
  134.     private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
  135.         boolean musica=true;
  136.         if(!this.jCheckBox1.isSelected()){
  137.             musica=false;
  138.         }
  139.         Tavolo t= new Tavolo("BlackJack - "+this.jTextField1.getText(), musica);
  140.         Dimension schermo=Toolkit.getDefaultToolkit().getScreenSize();
  141.         int x=schermo.width/2-526;
  142.         int y=schermo.height/2-325;
  143.         this.setVisible(false);
  144.         t.setVisible(true);
  145.         t.setLocation(x, y);
  146.     }//GEN-LAST:event_jButton1ActionPerformed
  147.  
  148.     /**
  149.     * @param args the command line arguments
  150.     */
  151.     public static void main(String args[]) {
  152.         java.awt.EventQueue.invokeLater(new Runnable() {
  153.             public void run() {
  154.                 Start s=new Start();
  155.                 Dimension schermo= Toolkit.getDefaultToolkit().getScreenSize();
  156.                 int x=schermo.width/2-118;
  157.                 int y=schermo.height/2-150;
  158.                 s.setLocation(x, y);
  159.                 s.setVisible(true);
  160.             }
  161.         });
  162.     }
  163.  
  164.     // Variables declaration - do not modify//GEN-BEGIN:variables
  165.     private javax.swing.JButton jButton1;
  166.     private javax.swing.JCheckBox jCheckBox1;
  167.     private javax.swing.JLabel jLabel1;
  168.     private javax.swing.JLabel jLabel2;
  169.     private javax.swing.JPanel jPanel1;
  170.     private javax.swing.JTextField jTextField1;
  171.     // End of variables declaration//GEN-END:variables
  172.  
  173. }
 

Creative Commons License
Il layout di questo sito è concesso sotto licenza Creative Commons.
Per maggiori informazioni sulle licenze dei contenuti del sito, clicca.