لتجربة الآلاف من الإضافات المتوفرة هنا، نزّل متصفح موزيلا فَيَرفُكس مجانًا. المتصفح الأسرع والأكثر أمانًا في عالم الإنترنت.
Closeمرحبا بك في إضافات فَيَرفُكس.
اختر من بين الآلاف من المميزات والمظاهر الإضافية واجعل فيرفُكس ملكًا لك.
Closeتعليق واحد على Forestle بواسطة Tiger19
مقيمة بـ 3 من 5 نجوم
S3
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
public class StartSeite extends JFrame {
String[] bestellliste = new String[10];
//Konstruktor
public StartSeite (String titel) {
super(titel);
Container cp = getContentPane();
JLabel ueberschrift = new JLabel(" ");
//Überschrift:
setLayout(new FlowLayout(FlowLayout.CENTER));
ueberschrift.setFont(new Font("SansSerif",Font.BOLD,40));
cp.add(ueberschrift);
//Menüleiste:
JMenuBar leiste = new JMenuBar();
JMenu JAuswahl = new JMenu("Auswahl");
JMenu JBestellung = new JMenu("Bestellung");
//Menüeinträge
JMenuItem m1Item1 = new JMenuItem("Autos");
m1Item1.setAccelerator(KeyStroke.getKeyStroke('A', InputEvent.CTRL_MASK));
m1Item1.addActionListener(new AutoListener(bestellliste));
JMenuItem m1Item2 = new JMenuItem("Spielsachen");
m1Item2.setAccelerator(KeyStroke.getKeyStroke('S', InputEvent.CTRL_MASK));
m1Item2.setActionCommand("Spielsachen");
JMenuItem m1Item3 = new JMenuItem("Beenden");
m1Item3.setActionCommand("Beenden");
//Menü Bearbeiten
JMenuItem m2Item1 = new JMenuItem("Warenkorb");
m2Item1.setAccelerator(KeyStroke.getKeyStroke('W', InputEvent.CTRL_MASK));
m2Item1.addActionListener(new WarenkorbListener(bestellliste));
//Menüeinträge binden
JAuswahl.add(m1Item1);
JAuswahl.add(m1Item2);
JAuswahl.addSeparator();
JAuswahl.add(m1Item3);
//Menü:
JBestellung.add(m2Item1);
//Menüs binden
leiste.add(JAuswahl);
leiste.add(JBestellung);
setJMenuBar(leiste);
addWindowListener(new WindowAdapter() {public void windowClosing(WindowEvent e){System.exit(0);}});
m1Item2.addActionListener(new AutoListener (bestellliste));
m1Item3.addActionListener(new BeendenListener());
m2Item1.addActionListener(new WarenkorbListener (bestellliste));
this.setVisible(true);
}
//Listener registrieren:
public class BeendenListener implements ActionListener{
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals("Beenden"))
System.exit(0);
else
System.out.println(e.getActionCommand());
}
}
//Autos bestellen:
public class AutoListener implements ActionListener{
private String[] liste;
public AutoListener (String[] l){
liste = l;
}
public AutoListener (){
}
public void actionPerformed(ActionEvent e) {
AutoVerkauf objekt = new AutoVerkauf(liste);
}
}
//Warenkorb speichern:
public class WarenkorbListener implements ActionListener{
private String[] liste;
public WarenkorbListener (String[] l){
liste = l;
}
public void actionPerformed(ActionEvent e) {
for (int i = 0; i < liste.length; i++)
if (liste [i] == null)
break;
else
System.out.println(liste [i]);
//Speichern der Daten in warenkorb.txt
try {
ObjectOutputStream out;
out = new ObjectOutputStream(new FileOutputStream("warenkorb.txt"));
for(String xy : liste)
{
System.out.println(xy);
out.writeObject(xy);
}
out.flush();
out.close();
} catch( IOException ex ) {
System.out.println( ex );
}
}
}
public static void main (String[] args) {
StartSeite fenster = new StartSeite(null);
fenster.setSize(800,500);
fenster.setLocation(0,0);
fenster.setVisible(true);
fenster.setResizable(true);
}
}
لإنشاء مجموعاتك الخاصة، يجب أن تمتلك حسابا على موقع إضافات موزيلا.