Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

[Win] Table without column expands

Aperta
#3,410 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
38/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Tranquilla
Stack tecnologico
java

Direzione di ricerca

Reproduce with the given TableWithoutColumnTest snippet: a VIRTUAL Table with no columns, MeasureItem setting event.width to table.getClientArea().width. On Windows the table shows a horizontal scrollbar and remembers a max width instead of staying client-wide. Start from the Windows Table/TableItem MeasureItem and client-area/scrollbar path in SWT; done when the snippet never shows a horizontal bar and rows shrink with the client area.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Describe the bug
We want to make a column as wide as the visible area (client area) without showing a horizontal scrollbar (just like a list). For that we set the client area's width in the MeasureItem event. However, this causes the table to show a horizontal scrollbar, and the item's width only can grow when resizing the table, but not shrink.

To Reproduce
Using Snippet 271 for inspiration:

import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;

final class TableWithoutColumnTest {

	public static void main(String[] args) {
		final Display display = new Display ();
		final Shell shell = new Shell (display);
		shell.setLayout(new FillLayout());

		final Table table = new Table (shell, SWT.VIRTUAL | SWT.BORDER | SWT.V_SCROLL | SWT.FULL_SELECTION);
		table.addListener (SWT.SetData, event -> {
			final TableItem item = (TableItem) event.item;
			final int index = table.indexOf (item);
			item.setText ("Item " + index);
		});
		table.addListener(SWT.MeasureItem, event -> {
			event.width = table.getClientArea().width;
		});
		table.setItemCount(100);
		table.setSelection(0);

		shell.setSize (200, 200);
		shell.open ();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch ()) display.sleep ();
		}
		display.dispose ();
	}
}

Expected behavior
The table should never show a horizontal scrollbar and all rows should be as wide as the client area.

Screenshots
Image
Note the horizontal scrollbar. The table remembers the maximum width + x. (Also note the tiny drawing glitch (gray area in the selected row) when starting the resize.)

Environment:

  1. Select the platform(s) on which the behavior is seen:
    • All OS
    • Windows
    • Linux
    • macOS
  1. Additional OS info (e.g. OS version, Linux Desktop, etc)
    Windows 11 25H2, 175% zoom
Lingua principale
Java
Stelle
202
Fork
206
Merge medio
14h 7m
PR unite (30g)
103

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di eclipse-platform/eclipse.platform.swt

Tutte le issue di eclipse-platform/eclipse.platform.swt

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.