FAQ | Points | Add... | Recent posts | Search | Register | Log in


programowanie Java - GUI


Post new topic  Reply to topic      Main Page -> Forum Index -> Bin -> Bin Archives -> programowanie Java - GUI
Author
Message
rafal198919
Poziom 10
Poziom 10


Joined: 10 Jan 2009
Posts: 57
Location: Stupsk

Post#1 Post from the author of the topic 30 Dec 2009 16:25   

programowanie Java - GUI


moj program ma polegac na tym ze wpisuje polski wyraz a on powinien mi wyswietlic jego angielski odpowiednik pobrany z pliku dane.txt gdzie jest napisany polski i jego angielski odpowiednik np. kot-cat
oto kod zrodlowy mojego progrogramu

import java.util.* ;
import java.io.* ;

public class slownik{
public static void main(String[] args) throws IOException{
slownik translator = new slownik();
translator.menu();
}

public void menu() throws IOException{
Scanner opcja=new Scanner(System.in);
System.out.printf("Menu:\n 1.Tlumacz\n ");
int i=opcja.nextInt();
switch(i){
case 1: tlumacz() ; break;
default: System.out.printf("Nic nie wybrales!\n\n") ;
}
}

public void tlumacz() throws IOException{
FileReader fr=new FileReader("dane.txt") ;
Scanner linia=new Scanner(fr) ;
Scanner slowo=new Scanner(System.in) ;
LinkedList<String> pol=new LinkedList<String>() ;
LinkedList<String> ang=new LinkedList<String>() ;
String s=new String() ;
int l=0;
while(linia.hasNextLine()){
s=linia.nextLine() ;
String[] polang=s.split(" ") ;
pol.addLast(polang[0]) ;
ang.addLast(polang[1]) ;
l++ ;
}

System.out.printf("Podaj wyraz: \n") ;
s=slowo.nextLine() ;

if(pol.indexOf(s)!=-1) System.out.printf("Tlumaczenie: "+s+" - "+ang.get(pol.indexOf(s))+"\n") ;
if(ang.indexOf(s)!=-1)System.out.println("Tlumaczenie: "+s+" - "+pol.get(ang.indexOf(s))+"\n") ;
if((ang.indexOf(s)==-1)&&(pol.indexOf(s)==-1))System.out.printf("Nie ma takiego slowa w slowniku!\n") ;
System.out.printf("\n");
menu();
}
}



Te GUI miej wiecej tak musi wygladac do tego programu

napisalem troszkie ale jeszcze trzeba to zaprogramowac ten przycisk tlumacz i te pole tekstowe

Programowanie Java skanoawnie i wypisanie tekstu

Dodano po 3 [minuty]:

import java.awt.*;
import javax.swing.*;

public class Slownik extends JFrame
{
public Slownik()
{ super("Slownik");
setSize(320,90);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel p = new JPanel();
p.add( new JButton("Tlumacz") );
p.add( new JTextField("Wpisz slowo do przetlumaczenia"));
Container cp = getContentPane();
cp.add(p);
setVisible(true);
}
public static void main(String []args)
{ new Slownik();
}
}

Moderated by krzychoocpp:
Brak określenia problemu, kod bez znaczników code - kosz.

Back to top
   
Google

Google Adsense


Post# Post from the author of the topic 30 Dec 2009 16:25   





Back to top
   
Post new topic  Reply to topic      Main Page -> Forum Index -> Bin -> Bin Archives -> programowanie Java - GUI
Page 1 of 1


Page generation time: 0.084 seconds


FAQ || Administrator || Moderators || Widgets and banners || Contact
elektroda.pl topic RSS feed