import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.UIManager;
import javax.swing.border.EtchedBorder;
import javax.swing.*;
public class RWindow extends JFrame implements ActionListener
{
JTextArea infoBereich = new JTextArea();
JScrollPane infoScrollLeisten = new JScrollPane(infoBereich);
JFileChooser fc = new JFileChooser();
JPanel panel = new JPanel();
Font schriftArtTextArea = new Font("Courier New",Font.PLAIN,12);
boolean Directory = false;
private File file;
private JButton bu = new JButton("File öffnen");
private JTextField versionNameTF = new JTextField("cro-20.zip");
private JTextField publishDateTF = new JTextField("12/05/2006");
private JTextField colorTF = new JTextField("16 Farben");
private JTextField wwwTF = new JTextField("http://www.chemical-reaction.de/");
private JTextField installationTF = new JTextField("Use our attached ascii viewer");
private JTextArea beschreibungTA = new JTextArea("greetings, description of ascii and aim of it \nHello,\n fellas how are you?");
JScrollPane beschreibungSPane = new JScrollPane(beschreibungTA);
public RWindow()
{
super("rip Mc dick");
add(panel, BorderLayout.CENTER);
panel.setLayout(null);
panel.add(infoScrollLeisten);
infoScrollLeisten.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
infoScrollLeisten.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
infoBereich.setFont(schriftArtTextArea);
infoBereich.setBackground(Color.black);
infoBereich.setForeground(Color.white);
infoBereich.setBorder( new EtchedBorder(Color.lightGray,Color.darkGray));
infoScrollLeisten.setBounds(0,0,577,700);
bu.setBounds(600, 670, 100, 25);
// Eingabefelder für die .txt datei vorlage
versionNameTF.setBounds(600,180,300,30);
publishDateTF.setBounds(600,220,300,22);
colorTF.setBounds(600,242,300,22);
installationTF.setBounds(600,264,300,22);
wwwTF.setBounds(600,330,300,30);
beschreibungTA.setBounds(600,400,300,270);
bu.addActionListener(this);
panel.add(bu);
panel.add(versionNameTF);
panel.add(publishDateTF);
panel.add(colorTF);
panel.add(wwwTF);
panel.add(installationTF);
panel.add(beschreibungTA);
}
public void actionPerformed(ActionEvent aevt)
{
infoBereich.setText("");
dateiLesen();
}
public void dateiLesen()
{
try
{
File tmp = new File(System.getProperty("user.dir"));
fc.setCurrentDirectory(tmp);
int selection = fc.showOpenDialog(this);
if(selection == JFileChooser.APPROVE_OPTION)
{
file = fc.getSelectedFile();
}
String line;
BufferedReader datei_text = new BufferedReader(new InputStreamReader(new FileInputStream(file),"CP437"));
while((line = datei_text.readLine())!= null )
{
infoBereich.append(line + "\r\n");
}
datei_text.close();
}
catch (FileNotFoundException e)
{
System.out.println("Datei nicht gefunden");
}
catch (IOException e)
{
System.out.println("Fehler: "+e.getMessage());
}
}
public static void main(String args[] )
{
UIManager.put("swing.boldMetal", Boolean.FALSE);
RWindow Fenster = new RWindow();
Fenster.setSize(1024,768);
Fenster.setLocationRelativeTo(null);
Fenster.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Fenster.setResizable(true);
Fenster.setVisible(true);
}
}