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.

JCheckBox in JList

Empfohlene Antworten

Veröffentlicht

Moin Moin,

hab ein Problem mit JList.

Wie kann ich es anstellen, dass in einer JList ein JCheckBox angezeigt wird?

Bisher mach ich es so:

DefaultListModel lm = new DefaultListModel();

JList liste = new JList(lm);

JCheckBox neu = new JCheckBox("CheckBox1:", true);

lm.addElement(neu);

JCheckBox neu2 = new JCheckBox("CheckBox2:", false);

lm.addElement(neu2);

Angezeigt wird aber immer nur: javax.swing.JCheckBox[,0,0,0x0,invalid usw.

Oder mach ich da was falsch?

MfG

Dalton

kann mir da keiner weiterhelfen? :(

Hallo,

das wird nur über einen eigenen ListCellRenderer gehen.

Habe ich selber aber auch noch nie gemacht.

Da hilft die wahrscheinlich nur Google

Gruß Jaraz

genau - du brauchst einen eigenen ListCellRenderer.

In die JList packst du dann als Model nur noch booleans rein und dein ListCellRenderer gibt dann eine entsprechende Checkbox pro boolean zurück (wenn du es richtig programmiert hast - was Fertiges gibt es da nicht).

gut das bringt mich erstmal weiter ... denke ich...

schönen dank erstmal

dalton

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.