Folge dem Video um zu sehen, wie unsere Website als Web-App auf dem Startbildschirm installiert werden kann.
Anmerkung: Diese Funktion ist in einigen Browsern möglicherweise nicht verfügbar.
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
/**
*
* Beschreibung
*
* @version 1.0 vom 04.04.2011
* @author
*/
public class Grafik extends Frame {
// Anfang Attribute
private JTextField jTextField1 = new JTextField();
private JLabel jLabel1 = new JLabel();
private JButton jButton1 = new JButton();
private JLabel jLabel2 = new JLabel();
private JTextField jTextField2 = new JTextField();
private JButton jButton2 = new JButton();
private JButton jButton3 = new JButton();
// Ende Attribute
public Grafik(String title) {
// Frame-Initialisierung
super(title);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent evt) { dispose(); }
});
int frameWidth = 306;
int frameHeight = 300;
setSize(frameWidth, frameHeight);
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
int x = (d.width - getSize().width) / 2;
int y = (d.height - getSize().height) / 2;
setLocation(x, y);
Panel cp = new Panel(null);
add(cp);
// Anfang Komponenten
jTextField1.setBounds(48, 32, 185, 24);
jTextField1.setText("jTextField1");
cp.add(jTextField1);
jLabel1.setBounds(88, 8, 104, 16);
jLabel1.setText("Telefonnummer");
jLabel1.setFont(new Font("MS Sans Serif", Font.PLAIN, 13));
cp.add(jLabel1);
jButton1.setBounds(96, 72, 75, 25);
jButton1.setText("Suche");
jButton1.setMargin(new Insets(2, 2, 2, 2));
jButton1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
jButton1_ActionPerformed(evt);
}
});
cp.add(jButton1);
jLabel2.setBounds(88, 120, 88, 16);
jLabel2.setText("Anrufnummer");
jLabel2.setFont(new Font("MS Sans Serif", Font.PLAIN, 13));
cp.add(jLabel2);
jTextField2.setBounds(48, 152, 185, 24);
jTextField2.setText("jTextField2");
cp.add(jTextField2);
jButton2.setBounds(96, 192, 75, 25);
jButton2.setText("Suche");
jButton2.setMargin(new Insets(2, 2, 2, 2));
jButton2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
jButton2_ActionPerformed(evt);
}
});
cp.add(jButton2);
jButton3.setBounds(80, 224, 107, 25);
jButton3.setText("Alle Eintraege");
jButton3.setMargin(new Insets(2, 2, 2, 2));
jButton3.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
jButton3_ActionPerformed(evt);
}
});
cp.add(jButton3);
// Ende Komponenten
setResizable(false);
setVisible(true);
}
// Anfang Methoden
public void jButton1_ActionPerformed(ActionEvent evt) {
double Telefon =0;
try {
Telefon = Double.parseDouble(jTextField1.getText());
} catch (NumberFormatException e) {
}
System.out.println(Telefon);
}
public void jButton2_ActionPerformed(ActionEvent evt) {
double Anruf =0;
try {
Anruf = Double.parseDouble(jTextField2.getText());
} catch (NumberFormatException e) {
}
System.out.println(Anruf);
}
public void jButton3_ActionPerformed(ActionEvent evt) {
File file = new File("Mappe11.csv");
FileInputStream fis = null;
BufferedInputStream bis = null;
DataInputStream dis = null;
try {
fis = new FileInputStream(file);
// Here BufferedInputStream is added for fast reading.
bis = new BufferedInputStream(fis);
dis = new DataInputStream(bis);
// dis.available() returns 0 if the file does not have more lines.
while (dis.available() != 0) {
// this statement reads the line from the file and print it to
// the console.
System.out.println(dis.readLine());
String liste;
liste=dis.readLine();
}
// dispose all the resources after using them.
fis.close();
bis.close();
dis.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
// Ende Methoden
public static void main(String[] args) {
new Grafik("Grafik");
}
}
Vergleichen wie oben geschrieben mit contains.Jez soll der String aus dem Textfeld mit dem aus dem String der Csv Datei verglichen und Ausgegeben werden.
if( A.contains( B ) )
{
System.out.println("B: " + B + " gefunden);
}
while (dis.available() != 0) {
String liste = dis.readLine();
// hier das contains einfuegen und falls ja, system out mit liste
}