Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Einfuehrung der Listbox Siehe DemoList2
- * @version 1.0 vom 23.04.2013
- * @author Dornig
- */
- import java.awt.*; // fuer List (AWT -Komponente)
- import java.awt.event.*; // fuer ActionListener
- import javax.swing.*; // fuer die einzelnen J-Komponenten
- public class DemoListSchueler extends JFrame{
- // swing-Komponenten
- private JPanel pnlCp = new JPanel(null);
- private JButton btnUebernehme = new JButton("Uebernehme");
- private JButton btnCount = new JButton("Count");
- private JButton btnLoescheAlles = new JButton("Loesche Alles");
- private JButton btnLoescheEintrag = new JButton("Loesche Eintrag");
- private JButton btnZeigeEintrag = new JButton("Zeige Eintrag");
- private JTextField tfdName = new JTextField();
- private JTextField tfdItem = new JTextField();
- private JLabel lblNameTfd = new JLabel("Name");
- private JLabel lblNameLst = new JLabel("Name");
- private JLabel lblCount = new JLabel("Elemente: ");
- private JLabel lblError = new JLabel("Fehler");
- private List lstName = new List(); // Achtung: awt-Komponente
- private ButtonListener meinButtonListener = new ButtonListener();
- public DemoListSchueler(String titel) {
- super (titel);
- addWindowListener (new WindowAdapter() {
- public void windowClosing(WindowEvent evt) {
- System.exit(0);
- }
- });
- add(pnlCp);
- // Button
- btnUebernehme.setBounds(450,80,100,25);
- btnUebernehme.addActionListener(meinButtonListener);
- pnlCp.add(btnUebernehme);
- btnCount.setBounds(450,120,100,25);
- btnCount.addActionListener(meinButtonListener);
- pnlCp.add(btnCount);
- btnLoescheAlles.setBounds(450,160,140,25);
- btnLoescheAlles.addActionListener(meinButtonListener);
- pnlCp.add(btnLoescheAlles);
- btnLoescheEintrag.setBounds(450,200,140,25);
- btnLoescheEintrag.addActionListener(meinButtonListener);
- pnlCp.add(btnLoescheEintrag);
- btnZeigeEintrag.setBounds(450,320,130,25);
- btnZeigeEintrag.addActionListener(meinButtonListener);
- pnlCp.add(btnZeigeEintrag);
- // Textfeld
- tfdName.setBounds(140,80,150,25);
- pnlCp.add(tfdName);
- tfdItem.setBounds(450,350,130,25);
- pnlCp.add(tfdItem);
- // Label
- lblNameTfd.setBounds(140,60,50,25);
- pnlCp.add(lblNameTfd);
- lblNameLst.setBounds(140,140,50,25);
- lblNameLst.setFont(new Font("MS Sans Serif", Font.PLAIN, 13));
- pnlCp.add(lblNameLst);
- lblCount.setBounds(140,320,150,25);
- //lblCount.setVisible(false);
- pnlCp.add(lblCount);
- lblError.setBounds(450,240,150,25);
- lblError.setVisible(false);
- pnlCp.add(lblError);
- // Listbox
- lstName.setBounds(140,160,140,120);
- pnlCp.add(lstName);
- // JFrame
- setSize(600,450);
- setLocation(30,30);
- setResizable(false);
- setVisible(true);
- } // Ende Konstruktor
- private class ButtonListener implements ActionListener {
- public void actionPerformed(ActionEvent ae) {
- if (ae.getSource() == btnUebernehme) {
- }
- if (ae.getSource() == btnCount) {
- }
- if (ae.getSource() == btnLoescheAlles) {
- }
- if (ae.getSource() == btnLoescheEintrag) {
- }
- if (ae.getSource() == btnZeigeEintrag) {
- }
- }
- } // Ende ButtonListener
- public static void main(String[] args) {
- DemoListSchueler frmDemoList = new DemoListSchueler("Listbox");
- } // Ende main
- } // Ende Klasse DemoListSchueler
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement