# Methode is not applicable?!?!



## SmartGuy (15. Jun 2009)

Ich bekomme bei Methodenzugriffen jeglicher Art folgende Fehlermeldung:
z. B. wenns um die Schriftfarbenänderung geht:

```
The method setForeground(Color) in the type Control is not applicable for the arguments (Color)
```


```
Text ueberblick = new Text(links, SWT.BORDER | SWT.V_SCROLL | SWT.READ_ONLY);
ueberblick.setText("Irgendein Text");
ueberblick.setForeground(Color.BLUE);
```

Weiß jmd, woran das liegt?


----------



## maki (15. Jun 2009)

Sicher dass du die richtige Color Klasse erwischt hast?


----------



## tuxedo (15. Jun 2009)

Hätt' ich jetzt auch drauf gesetzt... Check mal deine Imports. Ist mir auich schon passiert dass ich mich da mit dem Eclipse Autoimport etwas vertan hab ..

- Alex


----------



## SmartGuy (15. Jun 2009)

```
import java.awt.Color;
```
 ?


----------



## maki (15. Jun 2009)

```
import org.eclipse.swt.graphics.Color;
```
!


----------



## Golem386 (15. Jun 2009)

Hi,
zeig uns mal deine Imports! Ich würde schwören, dass du (wie maki gesagt hat) eine andere Klasse importiert, z.B. java.awt.Color.

Die korrekte Klasse ist org.eclipse.swt.graphics.Color.

MfG


----------



## SmartGuy (16. Jun 2009)

klappt mit dem Import auch nicht:

```
import org.eclipse.swt.graphics.Color; 
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;

public class Startfenster {
	Text ueberblick, chatfenster, eingabe;
	Button chateingabe, senden, neuesSpiel, rundruf, lobby;

	public static void main(String[] args) {
		Display display = new Display();
		Shell shell = new Startfenster().createShell(display);
		shell.setSize(600, 400);
		shell.open();

		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}
	}

	public Shell createShell(final Display display) {
		final Shell shell = new Shell(display);
		shell.setText("Startfenster");
		GridLayout gridLayout = new GridLayout();
		gridLayout.numColumns = 2;
		shell.setLayout(gridLayout);

		Composite links = new Composite(shell, SWT.NONE);// BORDER, H_SCROLL and V_SCROLL
		GridLayout grid2 = new GridLayout();
		grid2.numColumns = 2;
		links.setLayout(grid2);

		ueberblick = new Text(links, SWT.BORDER | SWT.V_SCROLL | SWT.READ_ONLY);
		GridData gridDataUeberblick = new GridData(GridData.FILL, GridData.CENTER, true,true);
		gridDataUeberblick.widthHint = 400;
		gridDataUeberblick.heightHint = 200;
		gridDataUeberblick.horizontalSpan = 2;
		gridDataUeberblick.grabExcessVerticalSpace = true;
		gridDataUeberblick.horizontalAlignment = GridData.FILL;
		gridDataUeberblick.verticalAlignment = GridData.FILL;
		gridDataUeberblick.grabExcessHorizontalSpace = true;	
		ueberblick.setText("Ueberblick der Tische");
		ueberblick.setBackground(Color.BLUE);
		ueberblick.setLayoutData(gridDataUeberblick);

		chatfenster = new Text(links, SWT.BORDER | SWT.V_SCROLL | SWT.READ_ONLY);
		GridData gridData3 = new GridData(GridData.FILL, GridData.CENTER, true, true);
		gridData3.widthHint = 400;
		gridData3.heightHint = 75;
		gridData3.horizontalSpan = 2;
		gridData3.grabExcessVerticalSpace = true;
		gridData3.horizontalAlignment = GridData.FILL;
		gridData3.verticalAlignment = GridData.FILL;
		gridData3.grabExcessHorizontalSpace = true;
		chatfenster.setText("Joe: Hey Leute, will denn keiner spielen?\nHalle Berry: nee, kein Bock auf dich\nBob: ich aber. Komm an Tisch 45");
		chatfenster.setLayoutData(gridData3);

		Text eingabe = new Text(links, SWT.BORDER); // BORDER, H_SCROLL, V_SCROLL, MULTI,SINGLE, READ_ONLY and WRAP
		GridData gridData4 = new GridData(GridData.FILL, GridData.CENTER, true, true);
		gridData4.widthHint = 300;
		gridData4.heightHint = 50;
		eingabe.setText("Eingabe...");
		gridData4.horizontalSpan = 1;
		gridData4.widthHint = 260;
		gridData4.heightHint = 20;
		eingabe.setTextLimit(30);// max Anzahl an Zeichen
		eingabe.setLayoutData(gridData4);

		senden = new Button(links, SWT.PUSH);
		// gridData4.widthHint = 30;
		senden.setText("senden");
		senden.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_END));
				
		Composite rechts = new Composite(shell, SWT.NONE);// BORDER, H_SCROLL and V_SCROLL
		GridLayout gridRechts = new GridLayout();
		gridRechts.numColumns = 1;
		rechts.setLayout(gridRechts);
		// rest.setBounds(400,10,380,240);
		GridData buttons = new GridData(GridData.CENTER, GridData.CENTER, true, true);
		buttons.widthHint = 100;
		Button neuesSpiel = new Button (rechts, SWT.PUSH);
		neuesSpiel.setText("Neues Spiel");
		neuesSpiel.setLayoutData(buttons);
		
		Button rundruf = new Button (rechts, SWT.PUSH);
		rundruf.setText("Rundruf");
		rundruf.setLayoutData(buttons);
		
		Text lobby = new Text(rechts, SWT.BORDER|SWT.V_SCROLL|SWT.H_SCROLL|SWT.READ_ONLY); // BORDER, H_SCROLL, V_SCROLL, MULTI,SINGLE, READ_ONLY and WRAP
		GridData gridLobby = new GridData(GridData.FILL, GridData.CENTER, true, true);
		gridLobby.widthHint = 100;
		gridLobby.heightHint = 250;
		gridLobby.grabExcessVerticalSpace = true;
		gridLobby.verticalAlignment = GridData.FILL;
		lobby.setText("Lobby\n\nPlayer1\nRedZac\nFlitzer\nBob\nJoe");
		lobby.setLayoutData(gridLobby);

		shell.addDisposeListener(new DisposeListener() {
			public void widgetDisposed(DisposeEvent arg0) {

			}
		});
		shell.pack();
		return shell;
	}
}
```


----------



## maki (16. Jun 2009)

Was genau heisst "klappt nicht"?


----------



## SmartGuy (16. Jun 2009)

Fehler bei ueberblick.setBackground(Color.BLUE);

-> Color.BLUE cannot be resolved


----------



## maki (16. Jun 2009)

Der Fehler liegt an dir, es gibt kein BLUE in Color.
Vielleciht hilft dir ja getBlue()? 
Api Doku lesen hilft


----------

