ciao a tutti!!!
ho creato un programma dove inserisco nel database la velocità di scorrimento dell'immagine...
il Problema è che ogni volta che clicco su una nuova immagine la velocità di scorrimento aumenta sempre di più...
cioè + clicco e + aumenta la velocità....questo è il cod:
dove sblaglio????codice:private void List(){ try { Class.forName("org.sqlite.JDBC"); } catch (Exception exc) { exc.printStackTrace(); } try { conn = DriverManager.getConnection("jdbc:sqlite:basi.sqlite"); pstmt = (PreparedStatement) conn.prepareStatement("SELECT * FROM lista where nome = ?"); String s1 = (String) lista.getSelectedValue(); pstmt.setString(1, s1); rs = pstmt.executeQuery(); while (rs.next()) { QueryResult temp = new QueryResult(rs.getInt("id"),rs.getString("nome"), rs.getInt("velocita"), rs.getInt("size")); String substring = rs.getString("nome").substring(rs.getString("nome").lastIndexOf('.')+1); int selectedIndex = getCurrentSelectedIndex2(); int vel = temp.velocita; int size = temp.size; final Timer timer2; timer2 = new Timer(vel, new ActionListener() { public void actionPerformed(ActionEvent ae) { currentAnimation.setY(currentAnimation.getY() - 1); pa.repaint(); } }); if (substring.equals("jpg")) { currentAnimation = new Immagine(); ImageIcon ball_IMG_ICON = new ImageIcon(img1); animation = ball_IMG_ICON.getImage(); prepareImage(animation, null); currentAnimation.setX(30); currentAnimation.setY(+250); pa.add(new JLabel(ball_IMG_ICON)); pa.setLocation(0, 0); pa.setVisible(true); buttonPlay.setIcon(imgPlay); buttonPlay.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { timer2.start(); buttonPause.setVisible(true); buttonPlay.setVisible(false); } }); buttonPause.setIcon(imgPause); buttonPause.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { timer2.stop(); buttonPlay.setVisible(true); buttonPause.setVisible(false); } }); } } } } catch (Exception exc) { exc.printStackTrace(); } }![]()
![]()
non riesco a capire...se mi potreste aiutare!!!!!

Rispondi quotando