import java.awt.*;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextArea;
public class BriefPanel extends JPanel {
private GUI gui;
private JPanel briefPanel;
private XmlDatenPanel xmlDatenPanel;
private JTextArea datum, empfaenger, absender, betreff, anrede, text, name, anlagen;
private JLabel ldatum, lempfaenger, labsender, lbetreff, lanrede, ltext, lgrusformel, lname, lanlagen;
private JComboBox grusformel;
private Container cont;
public BriefPanel(){
// Panel fuer Container im center des Frames
briefPanel = new JPanel();
setBackground(Color.orange);
setVisible(false);
// Container erzeugen
cont = new Container();
// Panel mit Container fuellen
briefPanel.add(cont);
GridBagLayout gbl = new GridBagLayout();
// Container mit GridLayout fuellen
cont.setLayout(gbl);
GridBagConstraints gbc = new GridBagConstraints();
// Komponenten werden erstellt
ldatum = new JLabel("Datum:");
datum = new JTextArea("tt.mm.jjjj", 1, 20);
labsender = new JLabel("Absender:");
absender = new JTextArea(1,40);
lempfaenger = new JLabel("Empfänger:");
empfaenger = new JTextArea(1,40);
lbetreff = new JLabel("Betreff:");
betreff = new JTextArea(1,20);
lanrede = new JLabel("Anrede:");
anrede = new JTextArea(1,20);
ltext = new JLabel("Text:");
text = new JTextArea(3,80);
lgrusformel = new JLabel("Grußformel:");
grusformel = new JComboBox();
lname = new JLabel("Unterschrift:");
name = new JTextArea(1,10);
lanlagen = new JLabel("Anlagen:");
anlagen = new JTextArea(1,10);
// fügt Komponenten an Kontainer
addComponent(cont, gbl, ldatum, 0, 0, 3, 1, 0.0, 0.0 );
addComponent(cont, gbl, datum, 0, 1, 2, 1, 0, 0.0 );
addComponent(cont, gbl, labsender, 0, 2, 3, 1, 0, 1.0 );
addComponent(cont, gbl, absender, 0, 3, 2, 1, 0, 1.0 );
addComponent(cont, gbl, lempfaenger, 0, 4, 3, 1, 0, 1.0 );
addComponent(cont, gbl, empfaenger, 0, 5, 2, 1, 0, 1.0 );
addComponent(cont, gbl, lbetreff, 0, 6, 3, 1, 0, 1.0 );
addComponent(cont, gbl, betreff, 0, 7, 3, 1, 0, 1.0 );
addComponent(cont, gbl, lanrede, 0, 8, 3, 1, 0, 1.0 );
addComponent(cont, gbl, anrede, 0, 9, 3, 1, 0, 1.0 );
addComponent(cont, gbl, ltext, 0, 10, 3, 1, 0, 1.0 );
addComponent(cont, gbl, text, 0, 11, 3, 1, 0, 1.0 );
addComponent(cont, gbl, lgrusformel, 0, 12, 3, 1, 0, 1.0 );
addComponent(cont, gbl, grusformel, 0, 13, 2, 1, 0, 1.0 );
addComponent(cont, gbl, lname, 0, 14, 3, 1, 0, 1.0 );
addComponent(cont, gbl, name, 0, 15, 1, 1, 0, 1.0 );
addComponent(cont, gbl, lanlagen, 0, 16, 3, 1, 0, 1.0 );
addComponent(cont, gbl, anlagen, 0, 17, 1, 1, 0, 1.0 );
validate();
}
public void panelSichtbar(){
BriefPanel briefPanel = new BriefPanel();
briefPanel.setVisible(true);
gui.add(briefPanel);
}
/**
*
* @param cont
* @param gbl
* @param c
* @param x
* @param y
* @param width
* @param height
* @param weightx
* @param weighty
*
* Hängt Objekte an GridBagLayout
*/
static void addComponent( Container cont, GridBagLayout gbl, Component c,
int x, int y, int width, int height, double weightx, double weighty ){
GridBagConstraints gbc = new GridBagConstraints();
gbc.fill = GridBagConstraints.BOTH;
gbc.gridx = x;
gbc.gridy = y;
gbc.gridwidth = width;
gbc.gridheight = height;
gbc.weightx = weightx; // verteilung des horizontalen und vertikalen platzes
gbc.weighty = weighty;
gbl.setConstraints( c, gbc );
cont.add( c );
}
}