ich will meine GUI in mehrere Dateien aufteilen damit der Code nicht zu lang wird nur leider wird nix angezeigt
Hauptteil
es ist ermal nur son bischen weil ich noch am anfang bin
Hauptteil
Code:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.table.*;
public class Hausverwaltung extends JFrame{
JFrame Fenster;
Dimension fensterpos = Toolkit.getDefaultToolkit().getScreenSize();
public Hausverwaltung()
{
Fenster = new JFrame();
Fenster.setTitle("Hausverwaltung V1.0");
Fenster.setLocation(20,30);
Fenster.getContentPane().setLayout(new BorderLayout());
JTabbedPane verwaltungstabbed = new JTabbedPane();
JButton berechnungsbutton;
verwaltungstabbed.addTab("Kontobewegungen",new Kontobewegungen());
Fenster.getContentPane().add(verwaltungstabbed,BorderLayout.CENTER);
Fenster.getContentPane().add(berechnungsbutton = new JButton("Berechnung"),BorderLayout.SOUTH);
Fenster.setSize(800,600);
Fenster.setVisible(true);
}
public static void main(String[] args){
new Hausverwaltung();
}
}
Code:
import java.awt.*;
import javax.swing.*;
public class Kontobewegungen extends JPanel{
static void addComponent(Container cont,GridBagLayout gbl,Component c,int x,int y,int width,int heigt,double weightx,double weighty,int positiontop,int positionleft,int positionbottom,int positionright)
{
GridBagConstraints gbc = new GridBagConstraints();
gbc.fill = gbc.BOTH;
gbc.gridx = x;
gbc.gridy = y;
gbc.gridwidth = width;
gbc.gridheight = heigt;
gbc.weightx = weightx;
gbc.weighty = weighty;
gbc.insets = new Insets(positiontop,positionleft,positionbottom,positionright);
gbl.setConstraints( c, gbc );
cont.add( c );
}
public Kontobewegungen()
{
JPanel Kontopanel = new JPanel();
GridBagLayout kontolayout = new GridBagLayout();
JLabel titel;
Kontopanel.setLayout(kontolayout);
addComponent(Kontopanel,kontolayout,titel = new JLabel("Kontobewegungen",JLabel.CENTER) ,0,0,GridBagConstraints.REMAINDER,0,0,0,5,5,5,5);
}
}