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
JSveglia - eseguibile.java

eseguibile.java

Caricato da:
Scarica il programma completo

  1. import java.awt.*;
  2. import java.awt.event.*;
  3. import javax.swing.*;
  4. public class eseguibile extends Frame {
  5.         public static int WIDTH = 200;
  6.         public static int HEIGHT = 140;
  7.         public eseguibile(String lab) {
  8.                 super(lab);
  9.                 setLayout(new FlowLayout());
  10.                 setLocation(470,300);
  11.                 setResizable(false);
  12.                 Thread runner = new Thread();
  13.                 JLabel lbl1 = new JLabel("Inserisci il tempo:  ");
  14.                 add(lbl1);
  15.                 lbl1.setOpaque(true);
  16.                 final JTextField tempo = new JTextField(6);
  17.                 add(tempo);
  18.                 tempo.setFocusable(true);
  19.                 JLabel lbl2 = new JLabel("  Decidi per quanto deve durare:  ");
  20.                 add(lbl2);
  21.                 lbl2.setOpaque(true);
  22.                 JButton min = new JButton("Min");
  23.                 add(min);
  24.                 JButton ore = new JButton("Ore");
  25.                 add(ore);
  26.                 JButton giorni = new JButton("Giorni");
  27.                 add(giorni);
  28.                 JButton esci = new JButton("Esci");
  29.                 add(esci);
  30.                 JLabel luca = new JLabel("COPYRIGHT by Luked");
  31.                 add(luca);
  32.                 luca.setOpaque(true);
  33.                 min.addActionListener(new ActionListener() {
  34.                         public void actionPerformed(ActionEvent E) {
  35.                                 String bottone = E.getActionCommand();
  36.                                 if(bottone.equals("Min")) {
  37.                                         int minuti = Integer.parseInt(tempo.getText());
  38.                                         try {
  39.                                                 String motivo = JOptionPane.showInputDialog("Cosa apputare alla fine del timer:");
  40.                                                 setVisible(false);
  41.                                                 int finale = (minuti * 60000);
  42.                                                 Thread.sleep(finale);
  43.                                                 final Frame f1 = new Frame("Timer");
  44.                                                 Panel p = new Panel();
  45.                                                 f1.setSize(180,130);
  46.                                                 f1.setLocation(470,320);
  47.                                                 f1.setVisible(true);
  48.                                                 JLabel fine = new JLabel("Timer concluso corretamente");
  49.                                                 p.add(fine);
  50.                                                 JLabel prova = new JLabel("Appunti salvati:");
  51.                                                 p.add(prova);
  52.                                                 JTextField appunto = new JTextField(5);
  53.                                                 p.add(appunto);
  54.                                                 appunto.setText(motivo);
  55.                                                 JButton end = new JButton("Fine");
  56.                                                 p.add(end);
  57.                                                 JButton rifai = new JButton("Nuovo timer");
  58.                                                 p.add(rifai);
  59.                                                 JLabel copy = new JLabel("               COPYRIGTH  by Luked");
  60.                                                 p.add(copy);
  61.                                                 f1.add(p);
  62.                                                 fine.setOpaque(true);
  63.                                                 rifai.addActionListener(new ActionListener() {
  64.                                                         public void actionPerformed(ActionEvent E) {
  65.                                                                 setVisible(true);
  66.                                                                 f1.setVisible(false);
  67.                                                         }
  68.                                                 });
  69.                                                 end.addActionListener(new ActionListener() {
  70.                                                         public void actionPerformed(ActionEvent E) {
  71.                                                                 String bottone = E.getActionCommand();
  72.                                                                 if(bottone.equals("Fine")) {
  73.                                                                         System.exit(0);
  74.                                                                 }
  75.                                                         }
  76.                                                 });
  77.                                                 f1.addWindowListener(new WindowAdapter() {
  78.                                                 public void windowClosing(WindowEvent e) {
  79.                                                         System.exit(0);
  80.                                                 }
  81.                                             });
  82.                                         }
  83.                                         catch(Exception e) {
  84.                                                 JOptionPane.showMessageDialog(null, "Errore Input", "Error", JOptionPane.ERROR_MESSAGE);
  85.                                         }
  86.                                 }
  87.                         }
  88.                 });
  89.                 ore.addActionListener(new ActionListener() {
  90.                         public void actionPerformed(ActionEvent E) {
  91.                                 String bottone = E.getActionCommand();
  92.                                 if(bottone.equals("Ore")) {
  93.                                         int oore= Integer.parseInt(tempo.getText());
  94.                                         try {
  95.                                                 String motivo = JOptionPane.showInputDialog("Cosa apputare alla fine del timer:");
  96.                                                 setVisible(false);
  97.                                                 int finale = (oore * 3600000);
  98.                                                 Thread.sleep(finale);
  99.                                                 final Frame f1 = new Frame("Timer");
  100.                                                 Panel p = new Panel();
  101.                                                 f1.setSize(180,130);
  102.                                                 f1.setLocation(470,320);
  103.                                                 f1.setVisible(true);
  104.                                                 JLabel fine = new JLabel("Timer concluso corretamente");
  105.                                                 p.add(fine);
  106.                                                 JLabel prova = new JLabel("Appunti salvati:");
  107.                                                 p.add(prova);
  108.                                                 JTextField appunto = new JTextField(5);
  109.                                                 p.add(appunto);
  110.                                                 appunto.setText(motivo);
  111.                                                 JButton end = new JButton("Fine");
  112.                                                 p.add(end);
  113.                                                 JButton rifai = new JButton("Nuovo timer");
  114.                                                 p.add(rifai);
  115.                                                 JLabel copy = new JLabel("               COPYRIGTH  by Luked");
  116.                                                 p.add(copy);
  117.                                                 f1.add(p);
  118.                                                 fine.setOpaque(true);
  119.                                                 rifai.addActionListener(new ActionListener() {
  120.                                                         public void actionPerformed(ActionEvent E) {
  121.                                                                 setVisible(true);
  122.                                                                 f1.setVisible(false);
  123.                                                         }
  124.                                                 });
  125.                                                 end.addActionListener(new ActionListener() {
  126.                                                         public void actionPerformed(ActionEvent E) {
  127.                                                                 String bottone = E.getActionCommand();
  128.                                                                 if(bottone.equals("Fine")) {
  129.                                                                         System.exit(0);
  130.                                                                 }
  131.                                                         }
  132.                                                 });
  133.                                                 f1.addWindowListener(new WindowAdapter() {
  134.                                                 public void windowClosing(WindowEvent e) {
  135.                                                         System.exit(0);
  136.                                                 }
  137.                                             });
  138.                                         }
  139.                                         catch(Exception e) {
  140.                                                 JOptionPane.showMessageDialog(null, "Errore Input", "Error", JOptionPane.ERROR_MESSAGE);
  141.                                         }
  142.                                 }
  143.                         }
  144.                 });
  145.                 giorni.addActionListener(new ActionListener() {
  146.                         public void actionPerformed(ActionEvent E) {
  147.                                 String bottone = E.getActionCommand();
  148.                                 if(bottone.equals("Giorni")) {
  149.                                         int gg = Integer.parseInt(tempo.getText());
  150.                                         try {
  151.                                                 String motivo = JOptionPane.showInputDialog("Cosa apputare alla fine del timer:");
  152.                                                 setVisible(false);
  153.                                                 int finale = (gg * 86400000);
  154.                                                 Thread.sleep(finale);
  155.                                                 final Frame f1 = new Frame("Timer");
  156.                                                 Panel p = new Panel();
  157.                                                 f1.setSize(180,130);
  158.                                                 f1.setLocation(470,320);
  159.                                                 f1.setVisible(true);
  160.                                                 JLabel fine = new JLabel("Timer concluso corretamente");
  161.                                                 p.add(fine);
  162.                                                 JLabel prova = new JLabel("Appunti salvati:");
  163.                                                 p.add(prova);
  164.                                                 JTextField appunto = new JTextField(5);
  165.                                                 p.add(appunto);
  166.                                                 appunto.setText(motivo);
  167.                                                 JButton end = new JButton("Fine");
  168.                                                 p.add(end);
  169.                                                 JButton rifai = new JButton("Nuovo timer");
  170.                                                 p.add(rifai);
  171.                                                 JLabel copy = new JLabel("               COPYRIGTH  by Luked");
  172.                                                 p.add(copy);
  173.                                                 f1.add(p);
  174.                                                 fine.setOpaque(true);
  175.                                                 rifai.addActionListener(new ActionListener() {
  176.                                                         public void actionPerformed(ActionEvent E) {
  177.                                                                 setVisible(true);
  178.                                                                 f1.setVisible(false);
  179.                                                         }
  180.                                                 });
  181.                                                 end.addActionListener(new ActionListener() {
  182.                                                         public void actionPerformed(ActionEvent E) {
  183.                                                                 String bottone = E.getActionCommand();
  184.                                                                 if(bottone.equals("Fine")) {
  185.                                                                         System.exit(0);
  186.                                                                 }
  187.                                                         }
  188.                                                 });
  189.                                                 f1.addWindowListener(new WindowAdapter() {
  190.                                                 public void windowClosing(WindowEvent e) {
  191.                                                         System.exit(0);
  192.                                                 }
  193.                                             });
  194.                                         }
  195.                                         catch(Exception e) {
  196.                                                 JOptionPane.showMessageDialog(null, "Errore Input", "Error", JOptionPane.ERROR_MESSAGE);
  197.                                         }
  198.                                 }
  199.                         }
  200.                 });
  201.                 esci.addActionListener(new ActionListener() {
  202.                         public void actionPerformed(ActionEvent E) {
  203.                                 String bottone = E.getActionCommand();
  204.                                 if(bottone.equals("Esci")) {
  205.                                         System.exit(0);
  206.                                 }
  207.                         }
  208.                 });
  209.         }  
  210.         private Image getImage(String string) {
  211.                 return null;
  212.         }
  213.         public static void main(String [] args) {
  214.                 JOptionPane.showMessageDialog(null, "Consultare il ReadMe:\nprima di utilizzare il programma", "Start", JOptionPane.WARNING_MESSAGE);
  215.                 eseguibile frame = new eseguibile("JSveglia");
  216.             frame.addWindowListener(new WindowAdapter() {
  217.                 public void windowClosing(WindowEvent e) {
  218.                         System.exit(0);
  219.                 }
  220.             });
  221.             frame.setSize(WIDTH, HEIGHT);
  222.             frame.show();
  223.         }
  224. }