|
|
|
![]() |
|
Strumenti |
![]() |
#1 |
Junior Member
Iscritto dal: May 2013
Messaggi: 1
|
programma java gestione videoteca awt
salve, ho riscontrato notevoli difficolta nella stesura del codice di questo programma:import java.io.*;
import java.awt.*; import java.awt.event.*; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; import java.util.StringTokenizer; class Videotecaframe { public static void main (String argv[]){ Frame f= new Frame("Ricerca film"); Panel p= new Panel(); TextField titolo= new TextField (50); TextArea ro = new TextArea(); Button cerca = new Button("Cerca"); p.add(new Label("Titolo:",Label.CENTER)); p.add(titolo); p.add(ro); p.add(cerca); f.add(p); f.setSize(400,300); f.setLocation(100, 100); f.setVisible(true); f.addWindowListener(new GestoreFinestra()); ro.setText(); } public void stampa(){ } public void actionPerformed (ActionEvent e) { String bottone = e.getActionCommand(); String titololetto= titolo.getText(); FileReader f = null; BufferedReader fIN=null; String linea; String s; Film c; StringTokenizer st = new StringTokenizer(s,":"); StringTokenizer ss= new StringTokenizer(s,";"); if (bottone.equals("Cerca")){ try{ f= new FileReader("films.txt"); fIN = new BufferedReader (f); } catch(IOException e1) { System.out.println("Errore nell'apertura"); System.exit(1); } c=new Film();} try { s=fIN.readLine(); while (s!=null){ if( ss.equals("titolo")) { if(st.valueOf(titololetto)) c.titolo = st.nextToken(); c.genere = st.nextToken(); c.annouscita = st.nextToken(); c.regista = st.nextToken(); c.protagonista = st.nextToken(); c.noleggiato = st.nextToken(); c.stampa(); s= fIN.readLine(); } } } catch (IOException e1){ System.out.println("Errore nell'apertura"); System.exit(1); } try { f.close(); } catch (IOException e1){ System.out.println("Errore nella chiusura del file"); System.exit(1); } }} Mi sono fermato alla ricerca del film, visto che nn sono convinto che sia scritta bene, praticamente devo inserire il nome di un film e tramite un file di testo(contenente molti film) devo stampare su un'area di testo i soli dati relativi al film inserito... solo che nn so come andare avanti... ![]() |
![]() |
![]() |
![]() |
Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 08:59.