Pagina 4 di 7 primaprima ... 2 3 4 5 6 ... ultimoultimo
Visualizzazione dei risultati da 31 a 40 su 69
  1. #31
    Utente di HTML.it
    Registrato dal
    Feb 2002
    Messaggi
    370
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
    Timer timer;
    speed = 100; //La barra sara aggiornata ogni decimo di secondo.
    timer = new Timer(speed, new tCounter());
    timer.start();
    Date date = new Date();
    SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");
    String datams = formatter.format(date);
    datams = "//foto/"+datams;
    faidir(datams,0);
    timer.stop();
    jLabel2.setText("Copia eseguita con successo");
    }

  2. #32
    Utente di HTML.it
    Registrato dal
    Apr 2007
    Messaggi
    906
    Non hai capito. Questo metodo quando viene chiamato?
    Mi sa che il tuo problema sta nel fatto che non hai associato nessun ActionListener al bottone.

  3. #33
    Utente di HTML.it
    Registrato dal
    Feb 2002
    Messaggi
    370
    quando schiaccio il bottone parte questo pezzo

    mi manca forse qualcosa?

  4. #34
    Utente di HTML.it
    Registrato dal
    Apr 2007
    Messaggi
    906
    Per quale arcano motivo dovrebbe partire il pezzo alla pressione del bottone.
    Se non glielo dici tu, il programma non ha mica un intelligenza propria.
    Ti posto un esempio sull'utilizzo di un bottone.
    codice:
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.*;
    
    public class Simple extends JFrame implements ActionListener {
       private JPanel pannello;
       private JLabel label;
       private JButton bottone;
       private int contatore = 0;
    
       public Simple() {
          pannello = new JPanel();
          label = new JLabel("0 click");
          bottone = new JButton("Cliccami");
          bottone.addActionListener(this);
          //La riga sopra significa, ad ogni pressione del bottone chiama il metodo actionPerformed 
          //dell'ActionListener passato come parametro
          pannello.add(label);
          pannello.add(bottone);
          this.setContentPane(pannello);
          this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
          this.pack();
          this.setVisible(true);
       }
    
        public void actionPerformed(ActionEvent e) {
            contatore++;
            label.setText(contatore+" click");
        }
        
        public static void main(String[] args) {
            new Simple();
        }
    }

  5. #35
    Utente di HTML.it
    Registrato dal
    Feb 2002
    Messaggi
    370
    a è questo?

    jButton1.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    jButton1ActionPerformed(evt);
    }
    });

  6. #36
    Utente di HTML.it
    Registrato dal
    Apr 2007
    Messaggi
    906
    Si, allora va bene. In che sendo non ti fa niente? Non ti cambia la progressBar?
    Probabilmente l'operazione di copia e' troppo veloce.

  7. #37
    Utente di HTML.it
    Registrato dal
    Feb 2002
    Messaggi
    370
    non si muove neanche alla fine da 100

  8. #38
    Utente di HTML.it
    Registrato dal
    Feb 2002
    Messaggi
    370
    penso che non istanzi la classe in modo giusto e io non ho idea di come fagli capire che sta li

    vi porto il codice semplificato per cercare di farla andare

    package muovifoto;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.io.*;
    import java.io.File.*;
    import java.lang.String.*;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.text.DecimalFormat;
    import java.text.Format;
    import java.text.SimpleDateFormat;
    import java.util.Date;
    import javax.swing.Timer;
    import javax.swing.*;

    public class muovifoto extends javax.swing.JFrame implements ActionListener{

    /** Creates new form muovifoto */
    public muovifoto() {

    initComponents();

    }

    private void initComponents() {
    jButton1 = new javax.swing.JButton();
    jLabel1 = new javax.swing.JLabel();
    jLabel2 = new javax.swing.JLabel();
    jLabel3 = new javax.swing.JLabel();
    jProgressBar1 = new javax.swing.JProgressBar();

    setDefaultCloseOperation(javax.swing.WindowConstan ts.EXIT_ON_CLOSE);
    jButton1.setText("Scarica foto");
    jButton1.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    jButton1ActionPerformed(evt);
    }
    });

    jLabel1.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 36));
    jLabel1.setText("Scarica le foto");

    org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
    layout.createParallelGroup(org.jdesktop.layout.Gro upLayout.LEADING)
    .add(layout.createSequentialGroup()
    .add(95, 95, 95)
    .add(layout.createParallelGroup(org.jdesktop.layou t.GroupLayout.TRAILING, false)
    .add(org.jdesktop.layout.GroupLayout.LEADING, jProgressBar1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    .add(org.jdesktop.layout.GroupLayout.LEADING, jLabel3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    .add(org.jdesktop.layout.GroupLayout.LEADING, jLabel2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    .add(org.jdesktop.layout.GroupLayout.LEADING, jLabel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    .add(org.jdesktop.layout.GroupLayout.LEADING, jButton1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 229, Short.MAX_VALUE))
    .addContainerGap(76, Short.MAX_VALUE))
    );
    layout.setVerticalGroup(
    layout.createParallelGroup(org.jdesktop.layout.Gro upLayout.LEADING)
    .add(layout.createSequentialGroup()
    .add(46, 46, 46)
    .add(jLabel1)
    .add(50, 50, 50)
    .add(jButton1)
    .addPreferredGap(org.jdesktop.layout.LayoutStyle.R ELATED)
    .add(jLabel3)
    .addPreferredGap(org.jdesktop.layout.LayoutStyle.R ELATED)
    .add(jProgressBar1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
    .addPreferredGap(org.jdesktop.layout.LayoutStyle.R ELATED, 44, Short.MAX_VALUE)
    .add(jLabel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 56, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
    .addContainerGap())
    );
    pack();
    }// </editor-fold>

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {

    int speed = 100; //La barra sara aggiornata ogni decimo di secondo.
    timer = new Timer(speed, this);
    timer.start();
    Date date = new Date();
    SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");
    String datams = formatter.format(date);
    aidir(datams,0);
    timer.stop();
    jLabel2.setText("Copia eseguita con successo");
    }

    private void Copiafile(File orig,File dest){
    //questo dovrebbre aggiorna la variabile passata nella barra e se la stampo funziona ma la barra non si aggiorna e e neanche il text ma neanche alla fine quindi penso manchi qualcosa per mandare in esecuzione giusta la classe

    caricabar = caricabar+c;
    propor = caricabar/totalsize;
    caricaper = propor*100;
    System.out.println((int)caricaper);
    }


    class tCounter implements ActionListener {
    public void actionPerformed(ActionEvent evt) {
    jProgressBar1.setValue((int)caricaper);
    jLabel3.setText("copiate "+numf+" immagine su "+filenumber);
    }
    }

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
    java.awt.EventQueue.invokeLater(new Runnable() {
    public void run() {
    new muovifoto().setVisible(true);

    }
    });
    }

    public void actionPerformed(ActionEvent e) {
    }

    // Variables declaration - do not modify
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JProgressBar jProgressBar1;
    // End of variables declaration
    private int filenumber;
    private double propor;
    private double totalsize;
    private int numf;
    private double caricabar;
    private double caricaper;
    private int speed;
    private Timer timer;
    private String mdatadir;
    }

    grazie

  9. #39
    Utente di HTML.it
    Registrato dal
    Apr 2007
    Messaggi
    906
    Prova a guardare questo tutorial e gli esempi e guarda se riesci ad adattare l'uso della scrollbar al tuo caso.

  10. #40
    Utente di HTML.it
    Registrato dal
    Feb 2002
    Messaggi
    370
    gia guardato ma non ho capito lo stesso come farlo andare giusto

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.