Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

GridBagLayout plz. Help !!!

Empfohlene Antworten

Veröffentlicht

Hi ich habe folgendes prob ich möchte gerne mit Swing und dem GridBagLayout eine oberfläche bastelln aber ürgend wie funtzt das ganze nicht :-(

Hier mal die sourcen.

setJMenuBar(jmb);

jp = new JPanel();

jp.setLayout(new GridBagLayout());

GridBagConstraints gbc;

JButton button = new JButton("test");

gbc = makegbc(0,0,1,2);

jp.add(button, gbc);

//add(button);

//jp.setLayout();

getContentPane().add(jp);

und die Funktion:

private GridBagConstraints makegbc(int x, int y, int width, int height)

{

GridBagConstraints gbc = new GridBagConstraints();

gbc.gridx = x;

gbc.gridy = y;

gbc.gridwidth = width;

gbc.gridheight = height;

gbc.insets = new Insets(1,1,1,1);

return gbc;

}

wäre super wenn mir eine helfen könnte dafür ne lösung zu finden oder mir sagt was ich falsch mache. :-)

Gruß Badgott

hier ein kleines Beispiel, vielleicht bringt dich das weiter. Ich habe leider noch nichts mit dem GridBagLayout gemacht, sorry.

GridBagLayout gbl = new GridBagLayout();

GridBagConstraints gbc = new GridBagConstraints();

setLayout(gbl);

List list = new List();

gbc.gridx = 0;

gbc.gridy = 0;

gbc.gridwidth = 1;

gbc.gridheight = 1;

gbc.weightx = 100;

gbc.weighty = 100;

gbc.fill = GridBagConstraints.BOTH;

gbl.setConstraints(list, gbc);

add(list);

jo nur wei kombienire ich das mit Swing Pane menü ect...?

Probier mal

JPanel pane = new JPanel()

hier der Text den ich dir gegeben habe

pane.add(gbl);

getContentPane().add(pane);

wenn es wieder nicht geht dann schreib mir nochmal dann teste ich es bei mir.

hmmm ürgend was haste bei add Falsch :-(

JPanel pane = new JPanel();

GridBagLayout gbl = new GridBagLayout();

GridBagConstraints gbc = new GridBagConstraints();

setLayout(gbl);

List list = new List();

gbc.gridx = 0;

gbc.gridy = 0;

gbc.gridwidth = 1;

gbc.gridheight = 1;

gbc.weightx = 100;

gbc.weighty = 100;

gbc.fill = GridBagConstraints.BOTH;

gbl.setConstraints(list, gbc);

add(list);

pane.add(gbl);

getContentPane().add(pane);

Fehler:

Start.java [241:1] cannot resolve symbol

symbol : method add (java.awt.GridBagLayout)

location: class javax.swing.JPanel

pane.add(gbl);

^

1 error

Errors compiling crtFrm.

ich bin noch dran, aber muss es unbedingt in Swing sein?

Die Datei geht jetzt.


import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

class Gui extends JFrame
{
public static void main(String[] arg)
{
new Gui();
}

public Gui()
{
JPanel pane = new JPanel();
getContentPane().add(pane);

GridBagLayout gbl = new GridBagLayout();
GridBagConstraints gbc = new GridBagConstraints();
pane.setLayout(gbl);

List list = new List();

gbc.gridx = 0;
gbc.gridy = 0;
gbc.gridwidth = 1;
gbc.gridheight = 1;
gbc.weightx = 100;
gbc.weighty = 100;
gbc.fill = GridBagConstraints.BOTH;
gbl.setConstraints(list, gbc);

pane.add(list);

setLocation(132, 65);
setSize(470,535);
setVisible(true);
}
}
[/PHP]

aber jetzt geht es, oder?

ok geht super thx for help :-)

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.