Advertisement
MaschWaschiene

DemoListSchueler

Mar 19th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.38 KB | None | 0 0
  1. /**
  2.   * Einfuehrung der Listbox  Siehe DemoList2
  3.   * @version 1.0 vom 23.04.2013
  4.   * @author Dornig
  5.   */
  6. import java.awt.*;       // fuer List (AWT -Komponente)
  7. import java.awt.event.*; // fuer ActionListener
  8. import javax.swing.*;    // fuer die einzelnen J-Komponenten
  9. public class DemoListSchueler extends JFrame{
  10.   // swing-Komponenten
  11.   private JPanel pnlCp = new JPanel(null);
  12.   private JButton btnUebernehme = new JButton("Uebernehme");
  13.   private JButton btnCount = new JButton("Count");
  14.   private JButton btnLoescheAlles = new JButton("Loesche Alles");
  15.   private JButton btnLoescheEintrag = new JButton("Loesche Eintrag");
  16.   private JButton btnZeigeEintrag = new JButton("Zeige Eintrag");
  17.   private JTextField tfdName = new JTextField();
  18.   private JTextField tfdItem = new JTextField();
  19.   private JLabel lblNameTfd = new JLabel("Name");
  20.   private JLabel lblNameLst = new JLabel("Name");
  21.   private JLabel lblCount = new JLabel("Elemente: ");
  22.   private JLabel lblError = new JLabel("Fehler");
  23.   private List lstName = new List();  // Achtung: awt-Komponente
  24.   private ButtonListener meinButtonListener = new ButtonListener();
  25.  
  26.   public DemoListSchueler(String titel) {
  27.     super (titel);
  28.     addWindowListener (new WindowAdapter() {
  29.       public void windowClosing(WindowEvent evt) {
  30.         System.exit(0);
  31.       }
  32.     });
  33.     add(pnlCp);
  34.     // Button
  35.     btnUebernehme.setBounds(450,80,100,25);
  36.     btnUebernehme.addActionListener(meinButtonListener);
  37.     pnlCp.add(btnUebernehme);
  38.     btnCount.setBounds(450,120,100,25);
  39.     btnCount.addActionListener(meinButtonListener);
  40.     pnlCp.add(btnCount);
  41.     btnLoescheAlles.setBounds(450,160,140,25);
  42.     btnLoescheAlles.addActionListener(meinButtonListener);
  43.     pnlCp.add(btnLoescheAlles);
  44.     btnLoescheEintrag.setBounds(450,200,140,25);
  45.     btnLoescheEintrag.addActionListener(meinButtonListener);
  46.     pnlCp.add(btnLoescheEintrag);
  47.     btnZeigeEintrag.setBounds(450,320,130,25);
  48.     btnZeigeEintrag.addActionListener(meinButtonListener);
  49.     pnlCp.add(btnZeigeEintrag);
  50.     // Textfeld
  51.     tfdName.setBounds(140,80,150,25);
  52.     pnlCp.add(tfdName);
  53.     tfdItem.setBounds(450,350,130,25);
  54.     pnlCp.add(tfdItem);
  55.     // Label
  56.     lblNameTfd.setBounds(140,60,50,25);
  57.     pnlCp.add(lblNameTfd);
  58.     lblNameLst.setBounds(140,140,50,25);
  59.     lblNameLst.setFont(new Font("MS Sans Serif", Font.PLAIN, 13));
  60.     pnlCp.add(lblNameLst);
  61.     lblCount.setBounds(140,320,150,25);
  62.     //lblCount.setVisible(false);
  63.     pnlCp.add(lblCount);
  64.     lblError.setBounds(450,240,150,25);
  65.     lblError.setVisible(false);
  66.     pnlCp.add(lblError);
  67.     // Listbox
  68.     lstName.setBounds(140,160,140,120);
  69.     pnlCp.add(lstName);
  70.     // JFrame
  71.     setSize(600,450);
  72.     setLocation(30,30);
  73.     setResizable(false);
  74.     setVisible(true);
  75.   } // Ende Konstruktor
  76.   private class ButtonListener implements ActionListener {
  77.     public void actionPerformed(ActionEvent ae) {
  78.       if (ae.getSource() == btnUebernehme) {
  79.  
  80.       }
  81.       if (ae.getSource() == btnCount) {
  82.  
  83.       }
  84.       if (ae.getSource() == btnLoescheAlles) {
  85.  
  86.       }
  87.       if (ae.getSource() == btnLoescheEintrag) {
  88.  
  89.       }
  90.       if (ae.getSource() == btnZeigeEintrag) {
  91.  
  92.       }
  93.     }
  94.   } // Ende ButtonListener
  95.   public static void main(String[] args) {
  96.     DemoListSchueler frmDemoList = new DemoListSchueler("Listbox");
  97.   } // Ende main
  98. } // Ende Klasse DemoListSchueler
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement