/*
* GridbagDemo.java
*/
package layout;
import java.awt.*;
import javax.swing.*;
public class GridbagDemo extends JFrame {
public GridbagDemo() {
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
setSize(800,600);
setLocationRelativeTo(null);
GridBagConstraints gridBagConstraints;
pnMain = new JPanel();
pnImport = new JPanel();
lbDatei = new JLabel("Importdatei:");
tfDatei = new JTextField();
btFind = new JButton("Dateisuche");
pnInfo = new JPanel();
lbVorgang = new JLabel("Vorgangsart:");
tfArt = new JTextField();
lbDatum = new JLabel("Valutadatum:");
tfDatum = new JTextField();
lbBetrag = new JLabel("Betrag:");
tfBetrag = new JTextField();
lbBeleg = new JLabel("Belegnummer:");
tfBeleg = new JTextField();
lbVorgangX = new JLabel();
pnMain.setLayout(new BoxLayout(pnMain, BoxLayout.Y_AXIS));
pnImport.setLayout(new GridBagLayout());
pnImport.setBorder(BorderFactory.createTitledBorder("Importdaten"));
lbDatei.setPreferredSize(dimLb);
pnImport.add(lbDatei, new GridBagConstraints());
tfDatei.setPreferredSize(dimTf);
pnImport.add(tfDatei, new GridBagConstraints());
btFind.setPreferredSize(dimBt);
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.insets = insetsB;
pnImport.add(btFind, gridBagConstraints);
pnMain.add(pnImport);
pnInfo.setLayout(new GridBagLayout());
pnInfo.setBorder(BorderFactory.createTitledBorder("Verarbeitungs Info"));
lbVorgang.setPreferredSize(dimLb);
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.insets = insetsA;
pnInfo.add(lbVorgang, gridBagConstraints);
tfArt.setPreferredSize(dimTf);
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.insets = insetsA;
pnInfo.add(tfArt, gridBagConstraints);
lbDatum.setPreferredSize(dimLb);
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.insets = insetsA;
pnInfo.add(lbDatum, gridBagConstraints);
tfDatum.setPreferredSize(dimTf);
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 1;
gridBagConstraints.insets = insetsA;
pnInfo.add(tfDatum, gridBagConstraints);
lbBetrag.setPreferredSize(dimLb);
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 2;
gridBagConstraints.insets = insetsA;
pnInfo.add(lbBetrag, gridBagConstraints);
tfBetrag.setPreferredSize(dimTf);
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 2;
gridBagConstraints.insets = insetsA;
pnInfo.add(tfBetrag, gridBagConstraints);
lbBeleg.setPreferredSize(dimLb);
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 3;
gridBagConstraints.insets = insetsA;
pnInfo.add(lbBeleg, gridBagConstraints);
tfBeleg.setPreferredSize(dimTf);
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 3;
gridBagConstraints.insets = insetsA;
pnInfo.add(tfBeleg, gridBagConstraints);
lbVorgangX.setPreferredSize(dimBt);
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.insets = insetsB;
pnInfo.add(lbVorgangX, gridBagConstraints);
pnMain.add(pnInfo);
getContentPane().add(pnMain, BorderLayout.CENTER);
}
public static void main(String args[]) {
new GridbagDemo().setVisible(true);
}
private JButton btFind;
private JLabel lbDatei, lbVorgang, lbDatum, lbBetrag, lbBeleg, lbVorgangX;
private JPanel pnMain,pnImport, pnInfo;
private JTextField tfDatei, tfArt, tfDatum, tfBetrag, tfBeleg;
private Dimension dimLb = new Dimension(100, 14);
private Dimension dimTf = new Dimension(300, 19);
private Dimension dimBt = new Dimension(100, 22);
private Insets insetsA = new Insets(0, 0, 7, 0);
private Insets insetsB = new Insets(0, 7, 0, 0);
}