|
|
|
![]() |
|
Strumenti |
![]() |
#1 |
Member
Iscritto dal: May 2004
Messaggi: 60
|
java Thread
sto creando una thread sulla classe lettore...ho creato il costruttore del lettore ma non posso utilizzarlo...il compilatore dice: cannot resolve symbol... come posso fare???
CODICE: import com.dalsemi.onewire.OneWireAccessProvider; import com.dalsemi.onewire.adapter.DSPortAdapter; import com.dalsemi.onewire.container.OneWireContainer; import java.util.Enumeration; import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.net.*; import java.net.InetAddress.*; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.lang.*; import java.lang.String.*; import java.io.*; import java.util.StringTokenizer; /* * FormLeggi.java * * Created on 12. maggio 2004, 10:35 */ /** * * @author Anna Jaquinta */ public class Client2 extends javax.swing.JFrame{ //Variabili String host = "127.0.0.1"; static Lettore LettoreReader = null; int port = 2000; static Socket socket; OutputStream oStream; static InputStream iStream; static String servStr = ""; int i = 0; OneWireContainer owd; JLabel code; JTextField ID; static JButton bApriPorta; static JButton bStatoPorta; static String FileName; BufferedReader input = null; int posporta; int posutente; static String currentId = ""; static String comando = ""; static String str = currentId + comando; boolean accessoOk = false; String idlettore = "5B0000018A1B5409"; /** Creates new form FormLeggi */ public Client2(){ code = new JLabel("IButton code: "); JPanel Ibutton = new JPanel(); JPanel codice = new JPanel(); JPanel bottoni = new JPanel(); ID = new JTextField(20); bApriPorta = new JButton("ApriPorta"); bStatoPorta = new JButton("Visualizza stato porta"); bottoni.setLayout(new GridLayout(2,2)); Ibutton.setLayout(new GridLayout(1,1)); codice.setLayout(new GridLayout(2,1)); bottoni.add(bApriPorta); bottoni.add(bStatoPorta); codice.add(code); Ibutton.add(ID); getContentPane().add(bottoni, BorderLayout.SOUTH); getContentPane().add(codice, BorderLayout.WEST); getContentPane().add(Ibutton, BorderLayout.CENTER); GestisciBottone ApriPorta = new GestisciBottone(); GestisciBottone2 VisualizzaStato = new GestisciBottone2(); bApriPorta.addActionListener(ApriPorta); bStatoPorta.addActionListener(VisualizzaStato); bApriPorta.setEnabled(false); bStatoPorta.setEnabled(false); pack(); this.setSize(500,500); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setVisible(true); try{ //creazione socket System.out.println("creo socket"); socket = new Socket(host, port); System.out.println("socket creato"); } catch(Exception e){ System.out.println("errore creazione socket: " + e); } initComponents(); } * @param args the command line arguments */ //main public static void main(String args[]) { class ThreadLettore extends Thread implements Runnable{ public void run(){ //creo costruttore formleggi Client2 f = new Client2(); f.show(); String oldId = ""; String currentId = ""; DSPortAdapter adapter = null; //Lettore LettoreReader = null; String idlettore = "5B0000018A1B5409"; try { // get the default adapter adapter = OneWireAccessProvider.getDefaultAdapter(); //costruttore lettore LettoreReader = new Lettore(adapter); // get exclusive use of adapter adapter.beginExclusive(true); // clear any previous search restrictions adapter.setSearchAllDevices(); adapter.targetAllFamilies(); adapter.setSpeed(adapter.SPEED_REGULAR); } catch (Exception e1) { System.out.println("errore riscontrato: " + e1); try { // end exclusive use of adapter adapter.endExclusive(); // free port used by adapter adapter.freePort(); } catch(Exception e2) { System.out.println("errore riscontrato: " + e2); } } while(true){ try{ currentId = Lettore.leggi("5B0000018A1B5409"); System.out.println("test1" + currentId); //richiamo il metodo scrivi testo. f.ScriviTesto(currentId); } catch(Exception e){ System.out.println("Errore: " + e); } if(!currentId.equals(oldId)){ oldId = currentId; try{ str = "<Ibutton>" + currentId; f.sendToSocket(socket, str); f.ScriviTesto(str); f.accesso(); } catch(Exception e){ System.out.println("Errore: " + e); } } if(!oldId.equals("")){ while(true){ //System.out.println("OLDID" + oldId); f.accesso(); } } } } } } }
__________________
anna182 vivi come se dovessi morire domani, pensa come se non dovessi morire mai!!! ![]() |
![]() |
![]() |
![]() |
#2 |
Senior Member
Iscritto dal: Jul 1999
Città: Torino
Messaggi: 2221
|
Scrivi il messaggio completo dell'errore...qual è la classe che non trova?
|
![]() |
![]() |
![]() |
#3 |
Member
Iscritto dal: May 2004
Messaggi: 60
|
la lettore....
__________________
anna182 vivi come se dovessi morire domani, pensa come se non dovessi morire mai!!! ![]() |
![]() |
![]() |
![]() |
#4 | |
Senior Member
Iscritto dal: Jan 2001
Città: Milano
Messaggi: 5707
|
Re: java Thread
Quote:
la prima riga e' ridondante, la seconda e' scorretta, toglile entrambe ![]() Nel sorgente che hai messo una classe che si chiama Lettore non c'e'. E' in un altro file? |
|
![]() |
![]() |
![]() |
#5 |
Member
Iscritto dal: May 2004
Messaggi: 60
|
si e in un altro file....
__________________
anna182 vivi come se dovessi morire domani, pensa come se non dovessi morire mai!!! ![]() |
![]() |
![]() |
![]() |
Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 16:06.