Benvenuto in Firefox per Android Add-ons.
Aggiungi nuove funzionalità e stili per rendere Firefox per Android veramente tuo.
ChiudiRecensione di Tiger19 per Forestle
Assegnate 3 su 5 stelle
A 3
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
public class AutoVerkauf extends JFrame implements ActionListener, ListSelectionListener{
private Auto[] autos = new Auto[9];
//Kontakt StartSeite:
private String[] liste;
private JLabel ueberschrift = new JLabel(" Luxusautos ");
private JLabel menge = new JLabel("Menge:");
private JTextArea info = new JTextArea(3,25);
private JButton element1 = new JButton("Bestellen");
private JButton element2 = new JButton("Beenden");
//Textfeld:
private JTextField textfeld1 = new JTextField(2);
//Array für Liste:
private static final String[] BESCHREIBUNG = {"", "", "", "", "","","","","",""};
private static final String[] AUTO = {"", "", "", "", "","","","","",""};
private static final String[] BILD = {"G:\\vorgabe\\bild1.jpg", "G:\\vorgabe\\", "G:\\vorgabe\\", "G:\\vorgabe\\", "G:\\vorgabe\\","G:\\vorgabe\\","G:\\vorgabe\\","G:\\vorgabe\\","G:\\vorgabe\\","G:\\vorgabe\\"};
private JList list;
//Bild:
private String dateiname;
private String dateinamewahl;
private Image ibild;
private MeinJPanel panel_bild = new MeinJPanel(200,160,ibild);
//Konstruktor
public AutoVerkauf (String[] l) {
super(" ");
//Kontakt zu StartSeite:
this.liste = l;
//autos
//Container:
Container cp = getContentPane();
//Layout:
cp.setLayout(new FlowLayout(FlowLayout.CENTER));
//Panel:
JPanel panel_ueberschrift = new JPanel();
JPanel panel_list = new JPanel();
JPanel panel_list_untereinander = new JPanel();
JPanel panel_unten = new JPanel();
//Bild:
dateiname = "G:\\vorgabe\\start.jpg";
//Image
Toolkit tk = Toolkit.getDefaultToolkit();
ibild = tk.getImage(dateiname);
panel_bild = new MeinJPanel(310, 400, ibild);
//Layout Überschrift:
panel_ueberschrift.setLayout(new FlowLayout(FlowLayout.CENTER,0,0));
//Panel Liste:
panel_list.setLayout(new FlowLayout(FlowLayout.LEFT,0,0));
panel_list_untereinander.setLayout(new GridLayout(2,1,0,10));
//Layout unten:
panel_unten.setLayout(new FlowLayout(FlowLayout.CENTER,0,10));
//Layout Bild:
panel_bild.setLayout(new FlowLayout(FlowLayout.RIGHT,0,0));
//Panel Überschrift:
ueberschrift.setFont(new Font("Serif", Font.BOLD, 30));
cp.add(panel_ueberschrift);
panel_ueberschrift.add(ueberschrift);
//Liste:
list = new JList(AUTO);
list.setSelectedIndex(0); //In der Liste an welcher Stelle selektieren.
list.setVisibleRowCount(8); //Länge der Liste setzen.
list.setFixedCellWidth(0); //Breite der Liste setzen.
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
//list.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
//list.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
//Scrollbar Liste:
panel_list_untereinander.add(new JScrollPane(list), BorderLayout.CENTER);
list.addListSelectionListener(this);
//Panel Liste:
cp.add(panel_list_untereinander);
panel_list_untereinander.add(info);
//Vereinigung Liste:
panel_list.add(panel_list_untereinander);
//Panel List:
cp.add(panel_list);
//Panel Bild:
cp.add(panel_bild);
//Panel unten:
cp.add(panel_unten);
panel_unten.add(menge);
panel_unten.add(textfeld1);
panel_unten.add(element1);
panel_unten.add(element2);
element1.addActionListener(this);
element2.addActionListener(this);
list.addListSelectionListener(this);
setLocation(200,100);
setSize(705,480);
setVisible(true);
setResizable(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
public void actionPerformed(ActionEvent e){
//Button Beenden:
if (e.getActionCommand().equals("Beenden"))
System.exit(0);
else
System.out.println(e.getActionCommand());
//Button Bestellen:
String ergebnis1 = textfeld1.getText();
System.out.println("unten: " + ergebnis1);
//Info aus der Liste anzeigen:
System.out.println("Auto; " + AUTO[list.getSelectedIndex()]);
}
public void valueChanged(ListSelectionEvent event) {
//Indiies setzen:
//TextArea:
int i = list.getSelectedIndex();
info.setText(BESCHREIBUNG[i]);
//Bild:
dateinamewahl = (BILD[i]);
//Image
Toolkit tk = Toolkit.getDefaultToolkit();
ibild = tk.getImage(dateinamewahl);
panel_bild.setAktBild(ibild);
repaint();
}
class MeinML extends MouseAdapter {
//Maus clicken:
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 1) {
int[] selektierte_indizes = list.getSelectedIndices();
for (int i =0; i< selektierte_indizes.length; i++)
System.out.println(AUTO[selektierte_indizes[i]]);
}
}
}
public static void main(String[] args){
AutoVerkauf fenster = new AutoVerkauf(null);
}
}
Per creare una tua raccolta devi avere un account per Mozilla Add-ons.