Java Probleme mit GridBagLayout

F

Furtano

Gast
Hi,

warum ist alles so mittig ? Soll eigentlich in der oberen linken Ecke anfangen.

Danke :)

fail75opw.png

PHP:
public Hauptprogramm()
	{
		windowWidth = 800;
		windowHeight = 800;

		dieMatrix = new Matrix(matrixWidth, matrixHeight);
		dieNeueMatrix = new Matrix(matrixWidth, matrixHeight);
		userMatrix = new Matrix(matrixWidth, matrixHeight);
		zuSimulieren = new Matrix(matrixWidth, matrixHeight);
		alteMatrix = new Matrix(matrixWidth, matrixHeight);
		zufaellig = false;
		selber = false;

		System.out.println("me");
		eingabe = new JFrame("Verteilung");
		eingabe.setLocation(0, 0);
		eingabe.setSize(windowWidth, windowHeight);
		
		
		JMenuBar menuBar = new JMenuBar();
		eingabe.setJMenuBar(menuBar);
		JMenu fileMenu = new JMenu("Datei");
		menuBar.add(fileMenu);
		JMenu infoMenu = new JMenu("Info");
		menuBar.add(infoMenu);
		
		dpn2 = new DrawPanel(500, 500, zuSimulieren, true);
		dpn2.setVisible(true);
		dpn2.setSize(100,100);
		

		eingabe.setVisible(true);
		
		// zufaelligeVerteilung.addActionListener(this);
		// nichtZufaelligeVerteilung.addActionListener(this);
		//
		GridBagLayout experimentLayout = new GridBagLayout();
		GridBagConstraints c = new GridBagConstraints();
		eingabe.setLayout(experimentLayout);

		c.gridx = 0;
		c.gridy = 0;
		c.weightx = 0.5;
		c.fill = GridBagConstraints.HORIZONTAL;
		
		eingabe.add(verteilungLabel,c);
		c.gridx = 1;
		c.gridy = 0;
		eingabe.add(zufaelligeVerteilung,c);
		c.gridx = 2;
		c.gridy = 0;
		eingabe.add(nichtZufaelligeVerteilung,c);

		c.gridx = 0;
		c.gridy = 1;
		eingabe.add(wieOftLabel,c);
		c.gridx = 1;
		c.gridy = 1;
		eingabe.add(wieOftInput,c);

		c.gridx = 0;
		c.gridy = 2;
		eingabe.add(simulationLabel,c);
		c.gridx = 1;
		c.gridy = 2;
		eingabe.add(simulieren,c);
		c.gridx = 2;
		c.gridy = 2;
		eingabe.add(rundeVor,c);
		c.gridx = 3;
		c.gridy = 2;
		eingabe.add(rundeZurueck,c);
		c.gridx = 0;
		c.gridy = 4;
		eingabe.add(dpn2,c);


		rundeVor.addActionListener(this);
		rundeZurueck.addActionListener(this);
		zufaelligeVerteilung.addActionListener(this);
		nichtZufaelligeVerteilung.addActionListener(this);
		simulieren.addActionListener(this);

		
		

		JMenuItem openItem = new JMenuItem("Öffnen", new ImageIcon(
				"icons/tango/16x16/actions/document-open.png"));
		fileMenu.add(openItem);
		JMenuItem saveItem = new JMenuItem("Sichern", new ImageIcon(
				"icons/tango/16x16/actions/document-open.png"));
		fileMenu.add(openItem);
		JMenuItem exitItem = new JMenuItem("Beenden", new ImageIcon(
				"icons/tango/16x16/actions/document-open.png"));
		JMenuItem autorItem = new JMenuItem("Autor", new ImageIcon(
				"icons/tango/16x16/actions/document-open.png"));
		JMenuItem helpItem = new JMenuItem("Help", new ImageIcon(
				"icons/tango/16x16/actions/document-open.png"));

		fileMenu.add(openItem);
		fileMenu.add(saveItem);
		fileMenu.add(exitItem);
		infoMenu.add(autorItem);
		infoMenu.add(helpItem);

}
 
Zurück
Oben