Hallo liebe Gemeinde,
ich bin mit Netbeans und Swing an folgendem Projekt dran:
Im ersten Fenster (IFrame) gibt man eine Teilnehmerzahl ein. Dann geht das Fenster zu, ein Jdialog-Fenster geht auf und soll für die entsprechende Anzahl entsprechend viele Textfelder erzeugen und anzeigen.
Ich habe 3 Dateien erstellt: Einmal den ViewController für das erste Fenster, dann den Teilnehmerdialog für das JDialog, und die Datei Teilnehmer, welche den Namen, die Anzahl, und ne Liste von Teilnehmern enthalten soll.
Ich bin soweit, dass ich vom VIewController durch Getter und Setter in der Teilnehmer Datei, die im ViewController eingegebene Anzahl in der Teilnehmer-Datei entsprechend aktualisieren kann.
Als Nächstes möchte ich nun dieses Int-Attribut mit der Anzahl ins JDialog weitergeben, um dort entsprechend viele Textfelder mit einer For-Schleife erzeugen zu können. Oder aber erst in der Teilnehmer Datei das Array entsprechend der Anzahl zu füllen und das mit einem GridbagLayout zu arbeiten. Ich kriege es aber nicht hin, das Attribut an JDialog weiterzugeben, ohne im JDialog wieder eine neue Instanz von Teilnehmer zu erstellen. Wenn ich eine neue Instanz erstelle, habe ich ja nichts von, da ich ja dann quasi ein neues selbiges Attribut habe, aber nicht das vom ViewController beschriebene.
Hier ist mein Code:
[CODE lang="java" title="ViewController"]
import java.awt.GridBagLayout;
import javax.swing.JOptionPane;
import java.util.ArrayList;
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this template
*/
/**
*
* @author Admin
*/
public class ViewController extends javax.swing.JFrame {
/**
* Creates new form ViewController
*/
public ViewController() {
initComponents();
myTeilnehmer = new Teilnehmer(0);
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
teilnehmerLabel = new javax.swing.JLabel();
teilnehmerFeld = new javax.swing.JTextField();
teilnehmerButton = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jPanel1.setBackground(new java.awt.Color(0, 153, 255));
teilnehmerLabel.setForeground(new java.awt.Color(255, 255, 255));
teilnehmerLabel.setText("Anzahl Prüfungsteilnehmer:");
teilnehmerFeld.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
teilnehmerFeldActionPerformed(evt);
}
});
teilnehmerButton.setText("OK");
teilnehmerButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
teilnehmerButtonActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(327, 327, 327)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(teilnehmerButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(teilnehmerFeld)))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(291, 291, 291)
.addComponent(teilnehmerLabel)))
.addContainerGap(316, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(166, 166, 166)
.addComponent(teilnehmerLabel)
.addGap(34, 34, 34)
.addComponent(teilnehmerFeld, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(42, 42, 42)
.addComponent(teilnehmerButton)
.addContainerGap(226, Short.MAX_VALUE))
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
pack();
}// </editor-fold>
private void teilnehmerFeldActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_teilnehmerFeldActionPerformed
// TODO add your handling code here:
}// GEN-LAST:event_teilnehmerFeldActionPerformed
private void teilnehmerButtonActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_teilnehmerButtonActionPerformed
try {
String eingabe = teilnehmerFeld.getText();
int eingabe2 = Integer.parseInt(eingabe);
if (eingabe2 <= 0 || eingabe2 >= 13) {
JOptionPane.showMessageDialog(rootPane, "Die eingegebene Zahl muss zwischen 0 und 13 liegen!");
} else {
myTeilnehmer.setTeilnehmer(eingabe2);
TeilnehmerDialog teilnehmerDialog = new TeilnehmerDialog(this, true);
setVisible(false);
teilnehmerDialog.setVisible(true);
}
} catch (java.lang.NumberFormatException e) {
JOptionPane.showMessageDialog(rootPane, "Als Eingabe sind nur positive, ganze Zahlen erlaubt!");
}
// TODO add your handling code here:
}// GEN-LAST:event_teilnehmerButtonActionPerformed
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
// <editor-fold defaultstate="collapsed" desc=" Look and feel setting code
// (optional) ">
/*
* If Nimbus (introduced in Java SE 6) is not available, stay with the default
* look and feel.
* For details see
* http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(ViewController.class.getName()).log(java.util.logging.Level.SEVERE, null,
ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(ViewController.class.getName()).log(java.util.logging.Level.SEVERE, null,
ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(ViewController.class.getName()).log(java.util.logging.Level.SEVERE, null,
ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(ViewController.class.getName()).log(java.util.logging.Level.SEVERE, null,
ex);
}
// </editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new ViewController().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JPanel jPanel1;
private javax.swing.JButton teilnehmerButton;
private javax.swing.JTextField teilnehmerFeld;
private javax.swing.JLabel teilnehmerLabel;
// End of variables declaration
private Teilnehmer myTeilnehmer;
}
[/CODE]
[CODE lang="java" title="TeilnehmerDialog"]
import java.awt.Button;
import java.awt.Color;
import java.awt.Container;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.TextField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JPanel;
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JDialog.java to edit this template
*/
/**
*
* @author Admin
*/
public class TeilnehmerDialog extends javax.swing.JDialog implements ActionListener {
Button schliesen;
// TextField text;
/**
* Creates new form TeilnehmerDialog
*/
public TeilnehmerDialog(java.awt.Frame parent, boolean modal) {
super(parent, modal);
initComponents();
GridBagLayout gbl = new GridBagLayout();
setLayout(gbl);
/* GridBagConstraints gbc = new GridBagConstraints();
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(5,5,5,5); //space that a container must levea at ech of its edges (to the border)
gbc.gridx = 0;
gbc.gridy = 0;
gbc.gridwidth = 1;
gbc.gridheight = 1; */
/* text = new TextField(text);
schliesen.addActionListener(this);
gbl.setConstraints(schliesen, gbc);
add(schliesen);
schliesen.setVisible(true); */
//schliesen = new Button("Schließen");
//schliesen.addActionListener(this);
// gbl.setConstraints(schliesen, gbc);
//add(schliesen);
//schliesen.setVisible(true);
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setBackground(new java.awt.Color(204, 204, 204));
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 400, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 300, Short.MAX_VALUE)
);
pack();
}// </editor-fold>
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(TeilnehmerDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(TeilnehmerDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(TeilnehmerDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(TeilnehmerDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the dialog */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
TeilnehmerDialog dialog = new TeilnehmerDialog(new javax.swing.JFrame(), true);
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
System.exit(0);
}
});
dialog.setVisible(true);
}
});
}
@Override
public void actionPerformed(ActionEvent e) {
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
}
// Variables declaration - do not modify
// End of variables declaration
}
[/CODE]
[CODE lang="java" title="Teilnehmer"]
import java.util.ArrayList;
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
/**
*
* @author Admin
*/
public class Teilnehmer {
private int anzahl;
private String name;
private ArrayList<String> teilnehmerliste = new ArrayList<String>();
public Teilnehmer (int a)
{
this.anzahl = a;
}
public void setTeilnehmer (int a) {
this.anzahl = a;
}
public int getTeilnehmer() {
return anzahl;
}
public Teilnehmer (String b) {
this.name = b;
}
public void setTeilnehmerName (String b) {
this.name = b;
}
public String getTeilnehmerName() {
return name;
}
public Teilnehmer (ArrayList<String> c) {
this.teilnehmerliste = c;
}
public void setTeilnehmerListe (ArrayList<String> c) {
this.teilnehmerliste = c;
}
public ArrayList<String> getTeilnehmerListe() {
return teilnehmerliste;
}
}
[/CODE]
Liebe Grüße und Danke im Voraus!
ich bin mit Netbeans und Swing an folgendem Projekt dran:
Im ersten Fenster (IFrame) gibt man eine Teilnehmerzahl ein. Dann geht das Fenster zu, ein Jdialog-Fenster geht auf und soll für die entsprechende Anzahl entsprechend viele Textfelder erzeugen und anzeigen.
Ich habe 3 Dateien erstellt: Einmal den ViewController für das erste Fenster, dann den Teilnehmerdialog für das JDialog, und die Datei Teilnehmer, welche den Namen, die Anzahl, und ne Liste von Teilnehmern enthalten soll.
Ich bin soweit, dass ich vom VIewController durch Getter und Setter in der Teilnehmer Datei, die im ViewController eingegebene Anzahl in der Teilnehmer-Datei entsprechend aktualisieren kann.
Als Nächstes möchte ich nun dieses Int-Attribut mit der Anzahl ins JDialog weitergeben, um dort entsprechend viele Textfelder mit einer For-Schleife erzeugen zu können. Oder aber erst in der Teilnehmer Datei das Array entsprechend der Anzahl zu füllen und das mit einem GridbagLayout zu arbeiten. Ich kriege es aber nicht hin, das Attribut an JDialog weiterzugeben, ohne im JDialog wieder eine neue Instanz von Teilnehmer zu erstellen. Wenn ich eine neue Instanz erstelle, habe ich ja nichts von, da ich ja dann quasi ein neues selbiges Attribut habe, aber nicht das vom ViewController beschriebene.
Hier ist mein Code:
[CODE lang="java" title="ViewController"]
import java.awt.GridBagLayout;
import javax.swing.JOptionPane;
import java.util.ArrayList;
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this template
*/
/**
*
* @author Admin
*/
public class ViewController extends javax.swing.JFrame {
/**
* Creates new form ViewController
*/
public ViewController() {
initComponents();
myTeilnehmer = new Teilnehmer(0);
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
teilnehmerLabel = new javax.swing.JLabel();
teilnehmerFeld = new javax.swing.JTextField();
teilnehmerButton = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jPanel1.setBackground(new java.awt.Color(0, 153, 255));
teilnehmerLabel.setForeground(new java.awt.Color(255, 255, 255));
teilnehmerLabel.setText("Anzahl Prüfungsteilnehmer:");
teilnehmerFeld.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
teilnehmerFeldActionPerformed(evt);
}
});
teilnehmerButton.setText("OK");
teilnehmerButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
teilnehmerButtonActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(327, 327, 327)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(teilnehmerButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(teilnehmerFeld)))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(291, 291, 291)
.addComponent(teilnehmerLabel)))
.addContainerGap(316, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(166, 166, 166)
.addComponent(teilnehmerLabel)
.addGap(34, 34, 34)
.addComponent(teilnehmerFeld, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(42, 42, 42)
.addComponent(teilnehmerButton)
.addContainerGap(226, Short.MAX_VALUE))
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
pack();
}// </editor-fold>
private void teilnehmerFeldActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_teilnehmerFeldActionPerformed
// TODO add your handling code here:
}// GEN-LAST:event_teilnehmerFeldActionPerformed
private void teilnehmerButtonActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_teilnehmerButtonActionPerformed
try {
String eingabe = teilnehmerFeld.getText();
int eingabe2 = Integer.parseInt(eingabe);
if (eingabe2 <= 0 || eingabe2 >= 13) {
JOptionPane.showMessageDialog(rootPane, "Die eingegebene Zahl muss zwischen 0 und 13 liegen!");
} else {
myTeilnehmer.setTeilnehmer(eingabe2);
TeilnehmerDialog teilnehmerDialog = new TeilnehmerDialog(this, true);
setVisible(false);
teilnehmerDialog.setVisible(true);
}
} catch (java.lang.NumberFormatException e) {
JOptionPane.showMessageDialog(rootPane, "Als Eingabe sind nur positive, ganze Zahlen erlaubt!");
}
// TODO add your handling code here:
}// GEN-LAST:event_teilnehmerButtonActionPerformed
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
// <editor-fold defaultstate="collapsed" desc=" Look and feel setting code
// (optional) ">
/*
* If Nimbus (introduced in Java SE 6) is not available, stay with the default
* look and feel.
* For details see
* http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(ViewController.class.getName()).log(java.util.logging.Level.SEVERE, null,
ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(ViewController.class.getName()).log(java.util.logging.Level.SEVERE, null,
ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(ViewController.class.getName()).log(java.util.logging.Level.SEVERE, null,
ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(ViewController.class.getName()).log(java.util.logging.Level.SEVERE, null,
ex);
}
// </editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new ViewController().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JPanel jPanel1;
private javax.swing.JButton teilnehmerButton;
private javax.swing.JTextField teilnehmerFeld;
private javax.swing.JLabel teilnehmerLabel;
// End of variables declaration
private Teilnehmer myTeilnehmer;
}
[/CODE]
[CODE lang="java" title="TeilnehmerDialog"]
import java.awt.Button;
import java.awt.Color;
import java.awt.Container;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.TextField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JPanel;
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JDialog.java to edit this template
*/
/**
*
* @author Admin
*/
public class TeilnehmerDialog extends javax.swing.JDialog implements ActionListener {
Button schliesen;
// TextField text;
/**
* Creates new form TeilnehmerDialog
*/
public TeilnehmerDialog(java.awt.Frame parent, boolean modal) {
super(parent, modal);
initComponents();
GridBagLayout gbl = new GridBagLayout();
setLayout(gbl);
/* GridBagConstraints gbc = new GridBagConstraints();
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(5,5,5,5); //space that a container must levea at ech of its edges (to the border)
gbc.gridx = 0;
gbc.gridy = 0;
gbc.gridwidth = 1;
gbc.gridheight = 1; */
/* text = new TextField(text);
schliesen.addActionListener(this);
gbl.setConstraints(schliesen, gbc);
add(schliesen);
schliesen.setVisible(true); */
//schliesen = new Button("Schließen");
//schliesen.addActionListener(this);
// gbl.setConstraints(schliesen, gbc);
//add(schliesen);
//schliesen.setVisible(true);
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setBackground(new java.awt.Color(204, 204, 204));
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 400, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 300, Short.MAX_VALUE)
);
pack();
}// </editor-fold>
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(TeilnehmerDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(TeilnehmerDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(TeilnehmerDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(TeilnehmerDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the dialog */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
TeilnehmerDialog dialog = new TeilnehmerDialog(new javax.swing.JFrame(), true);
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
System.exit(0);
}
});
dialog.setVisible(true);
}
});
}
@Override
public void actionPerformed(ActionEvent e) {
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
}
// Variables declaration - do not modify
// End of variables declaration
}
[/CODE]
[CODE lang="java" title="Teilnehmer"]
import java.util.ArrayList;
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
/**
*
* @author Admin
*/
public class Teilnehmer {
private int anzahl;
private String name;
private ArrayList<String> teilnehmerliste = new ArrayList<String>();
public Teilnehmer (int a)
{
this.anzahl = a;
}
public void setTeilnehmer (int a) {
this.anzahl = a;
}
public int getTeilnehmer() {
return anzahl;
}
public Teilnehmer (String b) {
this.name = b;
}
public void setTeilnehmerName (String b) {
this.name = b;
}
public String getTeilnehmerName() {
return name;
}
public Teilnehmer (ArrayList<String> c) {
this.teilnehmerliste = c;
}
public void setTeilnehmerListe (ArrayList<String> c) {
this.teilnehmerliste = c;
}
public ArrayList<String> getTeilnehmerListe() {
return teilnehmerliste;
}
}
[/CODE]
Liebe Grüße und Danke im Voraus!