Evo resio sam priprtreme za glavni problem :)
sad izgleda sve onako kako sam hteo ima li neko da mi da predlog kako da uradim da kad unesem neki niz da ga uporedi sa istim nizom u tekstu koji je u frejmu?
na primer kad unesem rec za trazenje "multi" da mi u tekstu ispod ispise :
default=
multi(0)disk(0)rdisk(0)partition(1)\WINDOWS
evo kompletnig koda programa
Code:
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.io.FileReader;
import java.io.BufferedReader;
public class search extends JFrame
{
public String Sadrzaj = "" ;
public String txt = "ovde ispod je sadrzaj fajla boot.ini ?";
public JTextField name = new JTextField(12);
public JTextArea message = new JTextArea(txt, 22, 50);
{
FileReader Stream;
BufferedReader File;
String TextLine;
try {
Stream = new FileReader("c:\\boot.ini");
File = new BufferedReader(Stream);
TextLine = File.readLine() ;
while (TextLine != null)
{
TextLine = File.readLine();
System.out.println(TextLine);
Sadrzaj = Sadrzaj + TextLine + "\n";
}
}
catch(Exception e)
{
System.out.println("fajl je prazan ili ne postoji!" );
String message = "fajl je prazan ili ne postoji!";
};
System.out.println("ovo radi :)");
String message = "ovo radi :)";
}
public search()
{
message.setEditable(false);
JButton enter = new JButton("E N T R E E");
enter.addActionListener(new action());
JPanel p = new JPanel();
p.setLayout(new FlowLayout());
p.add(new JLabel("unesite trazenu rec"));
p.add(name);
p.add(enter);
p.add(message);
this.setContentPane(p);
}
public static void main(String[] agruments) {
search sal = new search();
sal.setSize(650,450);
sal.show();
sal.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public class action implements ActionListener
{
public void actionPerformed(ActionEvent a)
{
String last = name.getText();
int size = last.length();
// message.setText( Sadrzaj );
try {
if (size == 0)
throw new NullPointerException();
}
catch (Exception e)
{
message.setText("Nazalost niste uneli ni jednu rec\n\n" + Sadrzaj );
return;
}
message.setText("trazili ste rec \"" + last + "\" koja sadrzi " + size + "slova\n\n" + Sadrzaj);
}
}
}
[Ovu poruku je menjao ctpaba dana 26.09.2005. u 19:50 GMT+1]
CTPABA uber alles
www.ctpaba.org