import java.io.*;
import java.awt.Color;
import java.awt.Dimension;
import java.io.FileReader;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
public class Main extends JFrame {
private JTextField tf;
public Main() {
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
// setzt es immer on top
setAlwaysOnTop(rootPaneCheckingEnabled);
// setzt die Position des Jrames
setLocation(550, 80);
// nimmt min. max. close weg
setUndecorated(true);
// JTextArea textArea = new JTextArea();
tf = new JTextField();
// kannst du nicht bearbeiten
tf.setEditable(false);
JScrollPane scrollPane = new JScrollPane(tf);
scrollPane.setPreferredSize(new Dimension(330,30));
add(scrollPane);
pack();
setVisible(true);
tf.setCursor(null);
tf.setBackground(Color.GRAY);
tf.setForeground(Color.green);
tf.setCaretPosition(tf.getText().length());
tf.setHighlighter(null);
// prüfung der .txt starten
new Checker().start();
}
public String readLine(FileReader reader) throws IOException {
String line = null;
for (int readInt = 0; (readInt = reader.read()) != 13 && readInt != -1;) {
String s = String.valueOf((char) readInt);
if (line == null)
line = s;
else
line += s;
}
reader.read();
return (line);
}
public static void main(String[] args) {
new Main();
}
private class Checker extends Thread {
private FileReader reader;
private String text;
private Integer counter;
private Integer ende;
private Integer check;
private Integer check1;
@Override
public void run() {
ende =20;
counter = 0;
check = 0;
check1 = 0;
text = "";
while(true) {
try{
reader = new FileReader("C:\\loi\\data.txt");
for (String incomingLine = null; (incomingLine =
readLine(reader)) != null;) {
if(check == 0){
if (counter == 1){
text = incomingLine;
//counter = 1;
}
else{
text = text;
}
}else{
if (counter == ende){
text = " "+ text;
//counter = 1;
}
else{
text = text.substring(1);
}
}
if(counter==ende||counter==1){
if(check==0){
if(check1==0){
check=0;check1=1;
}else{check=1;}
}else{check=0;}
}
}
reader.close();
if(!text.equals(tf.getText())) {
tf.setText(text);
}
}catch (FileNotFoundException e) {
e.printStackTrace();
}catch (IOException e) {
}
try {
e.printStackTrace();
sleep(100);
if(check==0){counter++;}else{counter--;}
}catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
}