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.

Probleme mit Anordnung von Checkboxen

Empfohlene Antworten

Veröffentlicht

Hallo Zusammen!

Ich habe ein Problem an dem ich einfach scheitere... Ich komm ums verrecken nicht drauf wo ich danach suchen soll...

Also ich lese eine Datenbank aus und lasse mir die String als Checkboxen auf einem Panel anzeigen dies klappt beim Aufbau der Oberfläche auch wunderbar.

Nun soll beim dieses Panel sich auch dynamisch dem ausgewählten Datum anpassen, dh je nach Datum werden andere Strings anzeigt. Wenn dies nun passiert dann wird der Abstand zwischen den Checkboxen jedes mal größer...

Könnt ihr mir da weiterhelfen :confused:

Hier mein Code!



	private JPanel panel = new JPanel();

	private boolean chb = false;

	private ArrayList<JCheckBox> panelElemente = new ArrayList<JCheckBox>();


	/* ArrayList hat den Vorteil das sie dynamische Arrays sind --> Speicherbedarf */


	public BK_Panel_Checkbox(String panelName){	

		JCheckBox ch_markAlle = new JCheckBox("Alle Markieren");

		ch_markAlle.setFocusPainted(false);

		ch_markAlle.addActionListener(this);

		add(ch_markAlle);


		/* new GridLayout (Anzahl an Spalten, Anzahl an Zeilen) */

		panel.setLayout(new GridLayout(0, 1));

		getViewport().add(panel);

		setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), panelName));

		setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);

		setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);

	}


	public Component add(JCheckBox c){		

		panel.add(c);

		panel.validate();

		panelElemente.add(c);


		panel.setPreferredSize(new Dimension(450, panelElemente.size() * 15));

		return c;

	}


	public void removeChb(){

		for(int index = 1; index < panelElemente.size(); index++){

			panel.remove(panelElemente.get(index));

			System.out.println(panelElemente.get(index));

			panelElemente.remove(index);

		}

	}

MfG

Saban

von welcher klasse erbst du hier?

bzw. schreib mal den puclic class teil auch noch hin

Gruß

Johnny

Hi!



public class BK_Panel_Checkbox extends JScrollPane implements ActionListener{

	...

}

MfG

Saban

Hi!

hilft mir nicht wirklich weiter aber danke trotzdem!

MfG

Saban

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.