Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
Java Ideal weight - DietologiaSwing.java

DietologiaSwing.java

Caricato da: Total
Scarica il programma completo

  1. /*
  2.  *      DietologiaSwing.java
  3.  *
  4.  *      Copyright 2007 Total <total1916@hotmail.it>
  5.  *
  6.  *      This program is free software; you can redistribute it and/or modify
  7.  *      it under the terms of the GNU General Public License as published by
  8.  *      the Free Software Foundation; either version 2 of the License, or
  9.  *      (at your option) any later version.
  10.  *
  11.  *      This program is distributed in the hope that it will be useful,
  12.  *      but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  *      GNU General Public License for more details.
  15.  *
  16.  *      You should have received a copy of the GNU General Public License
  17.  *      along with this program; if not, write to the Free Software
  18.  *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  19.  */
  20.  
  21. import javax.swing.*;
  22. import java.awt.*;
  23. import java.awt.event.*;
  24. import java.text.NumberFormat;
  25.  
  26.  
  27. public class DietologiaSwing {
  28.         public static void main(String [] args) {
  29.                
  30.                 JFrame finestra = new JFrame("Calcolo Peso ideale");
  31.                
  32.                 JPanel mainpanel = new JPanel();
  33.                 mainpanel.setLayout(new BorderLayout());
  34.                
  35.                 JPanel centerpanel = new JPanel();
  36.                 centerpanel.setLayout(new GridLayout(1, 2));
  37.                
  38.                 JPanel dxpanel = new JPanel();
  39.                 dxpanel.setLayout(new GridLayout(1,1));
  40.                
  41.                 JPanel sxpanel = new JPanel();
  42.                 sxpanel.setLayout(new GridLayout(0, 2));
  43.                
  44.                 JMenuBar menubar = new JMenuBar();
  45.                 mainpanel.add(menubar, BorderLayout.NORTH);
  46.                
  47.                
  48.                 JMenu file = new JMenu("file");
  49.                 file.setMnemonic(KeyEvent.VK_F);
  50.                 menubar.add(file);
  51.                
  52.                 JMenuItem exititem = new JMenuItem("exit", KeyEvent.VK_N);
  53.                 file.add(exititem);
  54.                 exititem.addActionListener(new ActionListener() {
  55.                         public void actionPerformed(ActionEvent e) {
  56.                                 System.exit(0);}});
  57.                                
  58.                 JMenu strumenti = new JMenu();
  59.                 strumenti.setText("Strumenti");
  60.                 menubar.add(strumenti);
  61.                
  62.                 JMenuItem tabitem = new JMenuItem("Tabella cost. Grant", KeyEvent.VK_N);
  63.                 strumenti.add(tabitem);
  64.                 tabitem.addActionListener(new ActionListener() {
  65.                         public void actionPerformed(ActionEvent e) {
  66.                                 final JFrame tabcost = new JFrame("Tabella costituzione di Grant");
  67.  
  68.                                 JPanel imgtabpanel = new JPanel();
  69.                                 imgtabpanel.setLayout(new BorderLayout());
  70.                                
  71.                                 JLabel image  = new JLabel(new ImageIcon("logolong.jpg"));
  72.                                 imgtabpanel.add(image, BorderLayout.NORTH);
  73.                                
  74.                                 JLabel imgtab = new JLabel(new ImageIcon("grant.jpg"));
  75.                                 imgtabpanel.add(imgtab, BorderLayout.CENTER);
  76.                                
  77.                                
  78.                                 JButton exit = new JButton("Ritorna al calcolo del peso",new ImageIcon("return.jpg"));
  79.                                 imgtabpanel.add(exit, BorderLayout.SOUTH);
  80.                                 exit.addActionListener(new ActionListener() {
  81.                                         public void actionPerformed(ActionEvent e) {
  82.                                                 tabcost.setVisible(false);
  83.                                         }});
  84.                                                
  85.                                 tabcost.getContentPane().add(imgtabpanel);
  86.                                 tabcost.pack();
  87.                                 tabcost.setResizable(false);
  88.                                 tabcost.setLocationRelativeTo(null);
  89.                                 tabcost.setVisible(true);    
  90.  
  91.                                 }});
  92.                
  93.                 JMenuItem bmiitem = new JMenuItem("Note sul BMI");
  94.                 strumenti.add(bmiitem);
  95.                 bmiitem.addActionListener(new ActionListener() {
  96.                         public void actionPerformed(ActionEvent e) {
  97.                                 final JFrame notbmi = new JFrame("Note sul BMI");
  98.  
  99.                                 JPanel notbmipanel = new JPanel();
  100.                                 notbmipanel.setLayout(new BorderLayout());
  101.                                
  102.                                 JLabel image  = new JLabel(new ImageIcon("logolong.jpg"));
  103.                                 notbmipanel.add(image, BorderLayout.NORTH);
  104.                                
  105.                                 JTextPane bmitxt= new JTextPane();
  106.                                 bmitxt.setContentType("text/html");
  107.                                 bmitxt.setEditable(false);
  108.                                 notbmipanel.add(bmitxt, BorderLayout.CENTER);
  109.                                
  110.                                
  111.                                 String notebmitxt =  "<body bgcolor=\"#FFF870\">  <strong>Note Sul Bmi</strong>"+
  112. "<br><hr>"+
  113. "<br><div align='left'><h4><strong>Tabela di valutazione del bmi</strong></h4></div>"+
  114.  
  115. "<table><tbody><tr>"+
  116.  "     <td><strong><h4>18-25</h4></strong></td>"+
  117.   "    <td><h4>Fattori di rischio minimi</h4></strong> <font size='3'>Il rischio di contrarre malattie cardiovascolari, "+
  118.   "<br>diabete non insulino dipendente, ictus cerebrare, ipertensione e' minimo e sottocontrollo."+
  119.   "<br> A questo livello, non esiste prova scientifica che perdendo peso possano diminuire i fattori di rischio,"+
  120.   "<br> al contrario, si potrebbero presentare altri problemi di salute"+
  121.    "       </td>"+
  122.     "</tr>"+
  123.     "<tr>"+
  124.    "   <td><strong><h4>25-27</h4></strong></td>"+
  125.    "   <td><strong><h4>Rischio basso/moderato</h4></strong>  <font size='3'>Un Bmi uguale a 25 corrisponde al limite oltre "+
  126.    "<br>al quale comincia a verificarsi la possibilità di contrarre malattie associate al peso.Oltre questo limite, "+
  127.    "<br>le cause associate al rischio di malattia sono in leggero aumento. "+
  128.    "<br>Puo' essere opportuno attuare un'alimentazione a basso contenuto di calorie accompagnata da attivita' fisica indispensabile per il mantenimento del peso</td>"+
  129.    " </tr>"+
  130.    " <tr>"+
  131.    "   <td><strong><h4>27-30</h4></strong></td>"+
  132.    "   <td><strong><h4>Rischio moderato/alto</h4></strong>  <font size='3'>Aumentano le probabilita' di sviluppare malattie cardiovascolari,"+
  133.    "<br> diabete non insulino dipendetente, ictus cerebrale, ipertensione. L'attivita' fisica, unita ad un regime alimentare adeguato,"+
  134.    "<br> favorisce il miglioramento delle condizioni cardio-respiratorie e facilita una strategia per perdere peso in modo equilibrato</td>"+
  135.    " </tr>"+
  136.    " <tr>"+
  137.    "   <td><strong><h4>30-35</h4></strong></td>"+
  138.    "   <td><strong><h4>Rischio alto/molto alto</h4></strong>  <font size='3'>Si presentano alte probabilità di sviluppare malattie cardiovascolari, "+
  139.    "<br>diabete non insulino dipendente, ictus cerebrale, ipertensione, e alcuni tipi di tumore. "+
  140.    "<br>E' consigliabile intraprendere tempestivamente comportamenti terapeutici finalizzati a ridurre tali rischi;"+
  141.    "<br> a questo livello è utile una terapia comportamentale finalizzata a raforzare la motivazione dell'individuo e la sua capacità di autocontrollo,"+
  142.    " associata a dieta e attivita' fisica regolare.</td>"+
  143.    " </tr>"+
  144.    " <tr>"+
  145.    "   <td><strong><h4>35-40</h4></strong></td>"+
  146.    "   <td><strong><h4>Rischio molto alto</h4></strong>  <font size='3'>A questo livello è probabile che una o piu delle patologie precedenti sia gia insorta "+
  147.    "<br>con una conseguente ripercussione negativa sullo stato di salute. Una terapia possibile, oltre a quelle consigliate al livello precedente, è la chilurgia. "+
  148.    "<br>Tuttavia, questa soluzione è praticabile solo in pazienti con gravi problemi di obesità e dopo attenta valutazione medica.</td>"+
  149.    " </tr>"+
  150.    " <tr>"+
  151.    "   <td><strong><h4> + 40</h4></strong></td>"+
  152.    "   <td><strong><h4>Rischio altissimo</h4></strong>  <font size='3'>Situazione delicata. Una o piu delle patologie citate sono probabilmente presenti"+
  153.    "<br> e occorrono cure apropiate derivanti da un'attenta valutazione della gravità dello stato di salute.</td>"+
  154.    " </tr>"+
  155.   "</tbody>"+
  156. "</table>"+
  157. "</font></body>";
  158.                                                  
  159.                                 bmitxt.setText(notebmitxt);
  160.                                
  161.                                
  162.                                 JButton exit = new JButton("Ritorna al calcolo del peso",new ImageIcon("return.jpg"));
  163.                                 notbmipanel.add(exit, BorderLayout.SOUTH);
  164.                                 exit.addActionListener(new ActionListener() {
  165.                                         public void actionPerformed(ActionEvent e) {
  166.                                                 notbmi.setVisible(false);
  167.                                         }});
  168.                                                
  169.                                 notbmi.getContentPane().add(notbmipanel);
  170.                                 notbmi.pack();
  171.                                 notbmi.setResizable(false);
  172.                             notbmi.setLocationRelativeTo(null);
  173.                                 notbmi.setVisible(true);    
  174. }});
  175.  
  176.                 JMenuItem infoforitem = new JMenuItem("informazioni formule");
  177.                 strumenti.add(infoforitem);
  178.                 infoforitem.addActionListener(new ActionListener() {
  179.                         public void actionPerformed(ActionEvent e) {
  180.                                 final JFrame infofor = new JFrame("Informazioni forumule");
  181.  
  182.                                 JPanel infoforpanel = new JPanel();
  183.                                 infoforpanel.setLayout(new BorderLayout());
  184.                                
  185.                                 JLabel image  = new JLabel(new ImageIcon("logolong.jpg"));
  186.                                 infoforpanel.add(image, BorderLayout.NORTH);
  187.                                
  188.                                 JTextPane infofortxt= new JTextPane();
  189.                                 infofortxt.setContentType("text/html");
  190.                                 infofortxt.setEditable(false);
  191.                                 infoforpanel.add(infofortxt, BorderLayout.CENTER);
  192.                                
  193.                                 String infoformtxt = "<body bgcolor=\"#FFF870\"><strong>Informazioni Formule</strong>"+
  194.                                                "<br><hr>"+
  195.                                                                    "<br><div align=\"left\"><h4><strong>Note sulle formule utilizzate in questo programma</strong></h4></div>"+
  196.                                                                    "<br><br><b>Formula di broca</b> operazione grossolana semplice ma imprecisa considera solo l'altezza"+
  197.                                    "<br><b>Altezza-100</b> per i maschi, <b>Altezza-104</b> per le femmine"+
  198.                                    "<br><br><b>Forumula di Lorenz</b> assai utilizzata tuttavia non tiene conto dell'eta ne della struttura scheletrica"+
  199.                                    "<br><b>Altezza-100-(Altezza-150)/4</b> per i maschi, <b>Altezza-100-(Altezza-150)/2</b>."+
  200.                                    "<br><br><b>Forumula di Ottaviani-Travia</b> elaborata dal'esperienza professionale di due nutrizionisti Italiani"+
  201.                                    "<br><b>1.012 x Altezza -107.6</b> per i maschi, <b>0.672 x Altezza - 50.95</b>."+
  202.                                    "<br><br><b>Bertheam</b> considera sia l'altezza che l'eta' del'individuo tuttavia è la stessa per maschi e femmine"+
  203.                                    "<br><b>(Altezza-100) x 0.8 + eta/2</b> per i maschi, <b>(Altezza-100) x 0.8 + eta/2</b>."+
  204.                                    "<br><br><b>Forumula di Van der Vael</b> Considera l'altezza e dei parametri fissi rispetto al sesso"+
  205.                                    "<br><b>(Altezza-150) x 0.6 +50</b> per i maschi, <b>(Altezza-150) x 0.75 +50</b>.";
  206.                                 infofortxt.setText(infoformtxt);
  207.                                
  208.                                
  209.                                 JButton exit = new JButton("Ritorna al calcolo del peso",new ImageIcon("return.jpg"));
  210.                                 infoforpanel.add(exit, BorderLayout.SOUTH);
  211.                                 exit.addActionListener(new ActionListener() {
  212.                                         public void actionPerformed(ActionEvent e) {
  213.                                                 infofor.setVisible(false);
  214.                                         }});
  215.                                                
  216.                                 infofor.getContentPane().add(infoforpanel);
  217.                                 infofor.pack();
  218.                                 infofor.setResizable(false);
  219.                             infofor.setLocationRelativeTo(null);
  220.                                 infofor.setVisible(true);    
  221. ;}});
  222.                
  223.                 JMenu info = new JMenu();
  224.                 info.setText("info");
  225.                 menubar.add(info);
  226.                
  227.                 JMenuItem noteitem = new JMenuItem("info");
  228.                 info.add(noteitem);
  229.                 noteitem.addActionListener(new ActionListener() {
  230.                         public void actionPerformed(ActionEvent e) {
  231.                                 final JFrame infof = new JFrame("Info");
  232.  
  233.                                 JPanel infopanel = new JPanel();
  234.                                 infopanel.setLayout(new BorderLayout());
  235.                                
  236.                                 JLabel image  = new JLabel(new ImageIcon("logolong.jpg"));
  237.                                 infopanel.add(image, BorderLayout.NORTH);
  238.                                
  239.                                 JTextPane infotxt= new JTextPane();
  240.                                 infotxt.setContentType("text/html");
  241.                                 infotxt.setEditable(false);
  242.                                 infopanel.add(infotxt, BorderLayout.CENTER);
  243.                                
  244.                                 String informtxt = "<body bgcolor=\"#FFF870\"><strong>Info</strong>"+
  245.                                                "<br><hr>"+
  246.                                                                    "<br><div align=\"left\"><h4><strong>Programma scritto in Java, da Rosso Davide</strong></h4></div>"+
  247.                                                                    "<br>Contact:"+
  248.                                    "<br>total1916@hotmail.it"+
  249.                                    "<br><br>Le informazioni contenute in questo programma sono state prese da fonti attendibili"+
  250.                                    "<br>tuttavia, non sono da considerare tali in quanto l'autore(Rosso Davide) declina ogni responsabilita'"+
  251.                                    "<br>sull'esattezza dei dati."+
  252.                                    "<br>Version 1.0.0";
  253.                                 infotxt.setText(informtxt);
  254.                                
  255.                                
  256.                                 JButton exit = new JButton("Ritorna al calcolo del peso",new ImageIcon("return.jpg"));
  257.                                 infopanel.add(exit, BorderLayout.SOUTH);
  258.                                 exit.addActionListener(new ActionListener() {
  259.                                         public void actionPerformed(ActionEvent e) {
  260.                                                 infof.setVisible(false);
  261.                                         }});
  262.                                                
  263.                                 infof.getContentPane().add(infopanel);
  264.                                 infof.pack();
  265.                                 infof.setResizable(false);
  266.                             infof.setLocationRelativeTo(null);
  267.                                 infof.setVisible(true);    
  268. ;}});
  269.                
  270.                
  271.                
  272.                 // SX BORDER LAYOUT
  273.                
  274.                 JLabel title = new JLabel("Inserisci i dati:");
  275.                 sxpanel.add(title);
  276.                
  277.                 JLabel vuoto = new JLabel("");
  278.                 sxpanel.add(vuoto);
  279.                
  280.                 JLabel etal = new JLabel("eta':");
  281.                 sxpanel.add(etal);
  282.                
  283.                 final JTextField etat = new JTextField( 10);
  284.                 sxpanel.add(etat);
  285.                
  286.                 JLabel altezzal = new JLabel("altezza:");
  287.                 sxpanel.add(altezzal);
  288.                
  289.                 final JTextField altezzat = new JTextField( 10);
  290.                 sxpanel.add(altezzat);
  291.                
  292.                 JLabel circpolsol = new JLabel("circonferenza polso:");
  293.                 sxpanel.add(circpolsol);
  294.  
  295.                 final JTextField circpolsot = new JTextField( 10);
  296.                 sxpanel.add(circpolsot);
  297.                
  298.                 JLabel pesol = new JLabel("peso corporeo:");
  299.                 sxpanel.add(pesol);
  300.  
  301.                 final JTextField pesot = new JTextField( 10);
  302.                 sxpanel.add(pesot);
  303.                
  304.                 JLabel sessol = new JLabel("sesso:");
  305.                 sxpanel.add(sessol);
  306.                
  307.                 //Creo i due radio button e li aggiungo ad un layout che andrà inserito nel mainpanel
  308.                 final JRadioButton femminar = new JRadioButton("F");
  309.                 final JRadioButton maschior = new JRadioButton("M");
  310.                 ButtonGroup groupsex = new ButtonGroup();
  311.                 groupsex.add(femminar);
  312.                 groupsex.add(maschior);
  313.                 JPanel radiogroupsex = new JPanel();
  314.                 radiogroupsex.setLayout(new GridLayout(1,2));
  315.                 radiogroupsex.add(femminar);
  316.                 radiogroupsex.add(maschior);
  317.                 sxpanel.add(radiogroupsex);
  318.                
  319.                 JButton calc = new JButton("Calcola");
  320.                 sxpanel.add(calc);
  321.                
  322.                 JButton reset = new JButton("Cancella");
  323.                 sxpanel.add(reset);
  324.                
  325.                 centerpanel.add(sxpanel);
  326.                
  327.                
  328.                 //DX BORDER LAYOUT
  329.                 JLabel image  = new JLabel(new ImageIcon("logo.jpg"));
  330.                 dxpanel.add(image);
  331.                
  332.                 centerpanel.add(dxpanel);
  333.  
  334.                 reset.addActionListener(new ActionListener() {
  335.                         public void actionPerformed(ActionEvent e) {
  336.                                 etat.setText("");
  337.                                 altezzat.setText("");
  338.                                 circpolsot.setText("");
  339.                                 pesot.setText("");
  340.                         }
  341.                 });
  342.                 calc.addActionListener(new ActionListener() {
  343.                         public void actionPerformed(ActionEvent e) {
  344.                                 Dietologia dietologia = new Dietologia();
  345.                                
  346.                                 String etas = "";
  347.                                 float etad = 0;
  348.                                 try {
  349.                                 etas = etat.getText();
  350.                                 etad = Float.parseFloat(etas);
  351.                          }
  352.                     catch (Exception ex) {}
  353.                        
  354.                         String altezzas = "";
  355.                         float altezzad = 0;
  356.                         try {
  357.                                 altezzas = altezzat.getText();
  358.                                         altezzad = Float.parseFloat(altezzas);
  359.                          }
  360.                     catch (Exception ex) {}
  361.                        
  362.                         String circpols = "";
  363.                         float circpold = 0;
  364.                         try {
  365.                                 circpols = circpolsot.getText();
  366.                                 circpold = Float.parseFloat(circpols);
  367.                          }
  368.                     catch (Exception ex) {}
  369.                    
  370.                     String pesos = "";
  371.                     float pesof = 0;
  372.                         try {
  373.                                 pesos = pesot.getText();
  374.                                         pesof = Float.parseFloat(pesos);
  375.                          }
  376.                     catch (Exception ex) {}
  377.                                
  378.                        
  379.                                
  380.                                 char sesso = 0;
  381.                                 String sex = "";
  382.                                 String sexy = "";
  383.                                
  384.                                 if (femminar.isSelected()){
  385.                                         sesso = 'w';           
  386.                                         sex = "una femmina";   
  387.                                         sexy = "a";
  388.                                 }
  389.  
  390.                                 else if  (maschior.isSelected()){
  391.                                         sesso = 'm';
  392.                                         sex = "un maschio";    
  393.                                         sexy = "o";
  394.                                 }
  395.                                
  396.                                 final JFrame fenetre = new JFrame("Risultato");
  397.  
  398.                                 JPanel fenetrepanel = new JPanel();
  399.                                 fenetrepanel.setLayout(new BorderLayout());
  400.                                
  401.                                 JPanel sudpan = new JPanel();
  402.                                 sudpan.setLayout(new BorderLayout());
  403.                                
  404.                                 JPanel sudpanel = new JPanel();
  405.                                 sudpanel.setLayout(new GridLayout(0,2));
  406.                                 fenetrepanel.add(sudpan, BorderLayout.SOUTH);
  407.                                
  408.                                 JLabel image  = new JLabel(new ImageIcon("logolong.jpg"));
  409.                                 fenetrepanel.add(image, BorderLayout.NORTH);
  410.                                
  411.                                 JTextPane resulttx = new JTextPane();
  412.                                 resulttx.setContentType("text/html");
  413.                                 resulttx.setEditable(false);
  414.                                 fenetrepanel.add(resulttx, BorderLayout.CENTER);
  415.                                
  416.                                
  417.                                
  418.                                 float pesobroca = 1;
  419.                                 pesobroca = dietologia.pesoBroca(altezzad, sesso);
  420.                                 float pesolorenz = 1;
  421.                                 pesolorenz = dietologia.pesoLorenz(altezzad, sesso);
  422.                                 float pesoottavianitravia = 1;
  423.                                 pesoottavianitravia = dietologia.pesoOttavianiTravia(altezzad, sesso);
  424.                                 float pesobertheam = 1;
  425.                                 pesobertheam = dietologia.pesoBertheam(altezzad, sesso, etad);
  426.                                 float pesovandervael = 1;
  427.                                 pesovandervael = dietologia.pesoVanderVael(altezzad, sesso);
  428.                                
  429.                                 float costitution = 0;
  430.                                 costitution = dietologia.costCorpGrant(altezzad, circpold, sesso);
  431.                                 String costituzionecorp = "";
  432.                                 String costituzioneimg = "noimg.jpg";
  433.                                 if (costitution == 1){
  434.                                         costituzionecorp = "Longilinea";
  435.                                         costituzioneimg = "long.jpg";
  436.                                 }
  437.                                 else if(costitution == 2){
  438.                                         costituzionecorp = "Normolinea";
  439.                                         costituzioneimg = "norm.jpg";
  440.                                 }
  441.                                 else if(costitution == 3){
  442.                                         costituzionecorp = "Brevilinea";
  443.                                         costituzioneimg = "brev.jpg";
  444.                                 }
  445.                                
  446.                                 JLabel imagesudl = new JLabel("La tua costituzione corporea secondo Grant e': "+costituzionecorp);
  447.                                 sudpanel.add(imagesudl);
  448.                                
  449.                                 JLabel imagesudim = new JLabel(new ImageIcon(costituzioneimg));
  450.                                 sudpanel.add(imagesudim);
  451.                                
  452.                                 JButton exit = new JButton("Ritorna al calcolo del peso",new ImageIcon("return.jpg"));
  453.                                 sudpan.add(exit, BorderLayout.SOUTH);
  454.                                 exit.addActionListener(new ActionListener() {
  455.                                         public void actionPerformed(ActionEvent e) {
  456.                                                        
  457.                                                 fenetre.setVisible(false);
  458.                                         }
  459.                                 });
  460.                                
  461.                                 sudpan.add(sudpanel, BorderLayout.CENTER);
  462.                                
  463.                                
  464.                                
  465.                                 //istanzio il metodo Bmi
  466.                                 float bmi = 0;
  467.                                 bmi = dietologia.Bmi(pesof, altezzad);
  468.                
  469.                                 //istanzio il metodo spiegaBmi
  470.                                 float spiegabmi = 0;
  471.                                 spiegabmi = dietologia.spiegaBmi(bmi,sesso);
  472.                
  473.                                 //ciclo che permette di visualizzare un stringa in base al return di spiegaBmi
  474.                                 String bmiind = "";
  475.                                 if (spiegabmi == 1){
  476.                                         bmiind = "con una grave obesita'";
  477.                                 }
  478.                                 else if(spiegabmi == 2){
  479.                                         bmiind = "con un grosso problema di obesita'";
  480.                                 }
  481.                                 else if(spiegabmi == 3){
  482.                                         bmiind = "con un grado avanzato di obesita'";
  483.                                 }
  484.                                 else if(spiegabmi == 4){
  485.                                         bmiind = "con un obesita' di primo livello";
  486.                                 }
  487.                                 else if(spiegabmi == 5){
  488.                                         bmiind = "sovrappeso";
  489.                                 }
  490.                                 else if(spiegabmi == 6){
  491.                                         bmiind = "nel pesoforma";
  492.                                 }
  493.                                 else if(spiegabmi == 7){
  494.                                         bmiind = "sottopeso";
  495.                                 }
  496.                
  497.                                 NumberFormat style = NumberFormat.getNumberInstance();
  498.                         style.setMaximumFractionDigits(2);
  499.                         style.setMinimumFractionDigits(2);
  500.                                
  501.                
  502.                                 String resultstring = "<body bgcolor=\"#FFF870\"><p align='center'><font size=\"4\"><b><h2>Risultato</b></h2>"+
  503.                                                           "<br>Il tuo peso ideale secondo il metodo di <b>Broca</b> e': "+String.valueOf(style.format(pesobroca))+
  504.                                                   "<br>il tuo peso ideale secondo il metodo di <b>Lorenz</b> e': "+String.valueOf(style.format(pesolorenz))+
  505.                                                   "<br>il tuo peso ideale secondo il metodo di <b>Ottaviani-Travia</b> e': "+String.valueOf(style.format(pesoottavianitravia))+
  506.                                                   "<br>il tuo peso ideale secondo il metodo di <b>Bertheam</b> e': "+String.valueOf(style.format(pesobertheam))+
  507.                                                   "<br>il tuo peso ideale secondo il metodo di <b>Van der Vael</b> e': "+String.valueOf(style.format(pesovandervael))+
  508.                                                   "<br>il tuo BMI(Body Mass Index) e' pari a: "+String.valueOf(style.format(bmi))+ " indica che sei un/a ragazzo/a: "+
  509.                                                   "<br>--->"+bmiind;
  510.                                                  
  511.                                 resulttx.setText(resultstring);
  512.                                
  513.                
  514.                                 fenetre.getContentPane().add(fenetrepanel);
  515.                                 fenetre.pack();
  516.                                 fenetre.setResizable(false);
  517.                                 fenetre.setLocationRelativeTo(null);
  518.                                 fenetre.setVisible(true);    
  519.                                 }
  520.                         });
  521.                
  522.                 mainpanel.add(centerpanel, BorderLayout.CENTER);
  523.                 finestra.getContentPane().add(mainpanel);
  524.                 finestra.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  525.                 finestra.setResizable(false);
  526.                 finestra.pack();
  527.                 finestra.setLocationRelativeTo(null);
  528.                 finestra.setVisible(true);
  529.         }
  530. }