JMetric - Curve.java
Cerca
 











Curve.java

Caricato da: Paoloricciuti
Scarica il programma completo

  1. import com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel;
  2. import java.util.logging.Level;
  3. import java.util.logging.Logger;
  4. import javax.swing.UIManager;
  5. import javax.swing.UnsupportedLookAndFeelException;
  6.  
  7.  
  8. /*
  9.  * To change this template, choose Tools | Templates
  10.  * and open the template in the editor.
  11.  */
  12.  
  13. /*
  14.  * Curve.java
  15.  *
  16.  * Created on 15-lug-2010, 17.25.43
  17.  */
  18. /**
  19.  *
  20.  * @author Paolo
  21.  */
  22. public class Curve extends javax.swing.JFrame {
  23.  
  24.     private Curva c;
  25.  
  26.     /** Creates new form Curve */
  27.     public Curve() {
  28.         try {
  29.             UIManager.setLookAndFeel(new NimbusLookAndFeel());
  30.         } catch (UnsupportedLookAndFeelException ex) {
  31.         }
  32.         initComponents();
  33.         c = new Curva(200, 01);
  34.         this.add(c);
  35.     }
  36.  
  37.     /** This method is called from within the constructor to
  38.      * initialize the form.
  39.      * WARNING: Do NOT modify this code. The content of this method is
  40.      * always regenerated by the Form Editor.
  41.      */
  42.     @SuppressWarnings("unchecked")
  43.     // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  44.     private void initComponents() {
  45.  
  46.         jLabel1 = new javax.swing.JLabel();
  47.         jSpinner1 = new javax.swing.JSpinner();
  48.  
  49.         setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  50.         setTitle("Jmetric - by Paolo Ricciuti (C)");
  51.  
  52.         jLabel1.setText("Numero righe");
  53.  
  54.         jSpinner1.setValue(1);
  55.         jSpinner1.addChangeListener(new javax.swing.event.ChangeListener() {
  56.             public void stateChanged(javax.swing.event.ChangeEvent evt) {
  57.                 jSpinner1StateChanged(evt);
  58.             }
  59.         });
  60.  
  61.         javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  62.         getContentPane().setLayout(layout);
  63.         layout.setHorizontalGroup(
  64.             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  65.             .addGroup(layout.createSequentialGroup()
  66.                 .addContainerGap()
  67.                 .addComponent(jLabel1)
  68.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  69.                 .addComponent(jSpinner1, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE)
  70.                 .addContainerGap(220, Short.MAX_VALUE))
  71.         );
  72.         layout.setVerticalGroup(
  73.             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  74.             .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
  75.                 .addContainerGap(419, Short.MAX_VALUE)
  76.                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  77.                     .addComponent(jLabel1)
  78.                     .addComponent(jSpinner1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  79.                 .addContainerGap())
  80.         );
  81.  
  82.         java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
  83.         setBounds((screenSize.width-416)/2, (screenSize.height-488)/2, 416, 488);
  84.     }// </editor-fold>//GEN-END:initComponents
  85.  
  86.     public boolean isNum(String str) {
  87.         try {
  88.             int x = Integer.parseInt(str);
  89.             if (x != 0) {
  90.                 return true;
  91.             } else {
  92.                 return false;
  93.             }
  94.         } catch (Exception e) {
  95.             return false;
  96.         }
  97.     }
  98.  
  99.     private void jSpinner1StateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jSpinner1StateChanged
  100.         if ((Integer) this.jSpinner1.getValue() != 0) {
  101.             this.c.setLinee((Integer) this.jSpinner1.getValue());
  102.             this.c.repaint();
  103.         }
  104.     }//GEN-LAST:event_jSpinner1StateChanged
  105.  
  106.     /**
  107.      * @param args the command line arguments
  108.      */
  109.     public static void main(String args[]) {
  110.         java.awt.EventQueue.invokeLater(new Runnable() {
  111.  
  112.             public void run() {
  113.                 new Curve().setVisible(true);
  114.             }
  115.         });
  116.     }
  117.     // Variables declaration - do not modify//GEN-BEGIN:variables
  118.     private javax.swing.JLabel jLabel1;
  119.     private javax.swing.JSpinner jSpinner1;
  120.     // End of variables declaration//GEN-END:variables
  121. }
 

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