Menüpunkt mit GWT erstellen

O

Owii

Hallo,

ich fange gerade mit Java an und hab mir folgendes Ziel momentan gesetzt um einfach mal "los zu programmieren" ... leider ist es nicht so einfach wie gedacht ...

Mein momentanes Ziel:
- Ein Menü mit GWT erstellen was sich bei Mouseover ausklappt (geschaft)
- Ein ImageBundle erzeugen (glaube ich geschaft)
- Das Menü soll die Grafiken aus dem ImageBundle benutzen

Momentan wird ein Menü erzeugt was wie folgt aussieht (besteht momentan aber aus Text und nicht aus Grafiken)

Knopf (Geht bei Mouseover auf)
- Item1
- Item2

Ich habe jetzt aber einfach keine Ahnung wie ich da jetzt die Grafiken ins Menü bekomme!

http://google-web-toolkit.googlecode.com/svn/javadoc/2.0/com/google/gwt/user/client/ui/MenuBar.html
http://google-web-toolkit.googlecod...om/google/gwt/user/client/ui/ImageBundle.html

Ich habe jetzt schon echt 3 Tage lang ALLES probiert, nur das richtige scheinbar nicht ... was mache ich falsch? bzw. mache ich etwas richtig?

Der Code:
Java:
package com.mycompany.project.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.AbstractImagePrototype;
import com.google.gwt.user.client.ui.ImageBundle;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.MenuBar;
import com.google.gwt.user.client.ui.MenuItem;
import com.google.gwt.user.client.Command;
@SuppressWarnings("deprecation")

public class ImageBundleTest implements EntryPoint {
	
	public void onModuleLoad() {
		
		RootPanel rootPanel = RootPanel.get();
		rootPanel.setSize("100%", "100%");
		
		MenuBar menuBar = new MenuBar(false);
		menuBar.setAutoOpen(true);
		rootPanel.add(menuBar, 29, 38);
		MenuBar menuBar_1 = new MenuBar(true);
		menuBar_1.setAutoOpen(true);
		
		MenuItem mntmText = new MenuItem("Knopf", false, menuBar_1);
		
		MenuItem mntmItem = new MenuItem("Item1", false, (Command) null);
		mntmItem.setHTML("Item1");
		menuBar_1.addItem(mntmItem);
		
		MenuItem mntmItem_1 = new MenuItem("Item 2", false, (Command) null);
		mntmItem_1.setHTML("Item 2");
		menuBar_1.addItem(mntmItem_1);
		mntmText.setHTML("a");
		menuBar.addItem(mntmText);	
		
	}
	
	public interface Software_de extends ImageBundle {
		
		// headerImages
		
		public AbstractImagePrototype backgroundHeader();
		public AbstractImagePrototype headerImage();
		   
		// headerNavigation_2	  
		   
		public AbstractImagePrototype topNavigation2_1_Closed();
		public AbstractImagePrototype topNavigation2_1_Open();
		public AbstractImagePrototype topNavigation2_2_Closed();
		public AbstractImagePrototype topNavigation2_2_Open();
		public AbstractImagePrototype topNavigation2_3_Closed();
		public AbstractImagePrototype topNavigation2_3_Open();
		public AbstractImagePrototype topNavigation2_4_Closed();
		public AbstractImagePrototype topNavigation2_4_Open();
		
		// Create Images?
		
		Software_de software = GWT.create(Software_de.class);
		AbstractImagePrototype inset_backgroundHeader = software.backgroundHeader();
		AbstractImagePrototype inset_headerImage = software.headerImage();
		AbstractImagePrototype inset_topNavigation2_1_Closed = software.topNavigation2_1_Closed();
		AbstractImagePrototype inset_topNavigation2_1_Open = software.topNavigation2_1_Open();
		AbstractImagePrototype inset_topNavigation2_2_Closed = software.topNavigation2_2_Closed();
		AbstractImagePrototype inset_topNavigation2_2_Open = software.topNavigation2_2_Open();
		AbstractImagePrototype inset_topNavigation2_3_Closed = software.topNavigation2_3_Closed();
	    AbstractImagePrototype inset_topNavigation2_3_Open = software.topNavigation2_3_Open();
		AbstractImagePrototype inset_topNavigation2_4_Closed = software.topNavigation2_4_Closed();
		AbstractImagePrototype inset_topNavigation2_5_Open = software.topNavigation2_4_Open();		
	}
}
 
Moin,

ohne jetzt großartig auf Deinen Code einzugehen, hast Du Dir diesen Absatz mal durchgelesen in der API:

Code:
    /**
    * Notice that the Resource annotation is not present, 
    * so the method name itself is assumed to match the associated 
    * image filename.
    *
    * One of btn_submit_icon.png, btn_submit_icon.gif, or 
    * btn_submit_icon.jpg must be located in the same package 
    * as MyImageBundle.
    */

Eventuell solltest das mal so versuchen...

Gruß,
Xan
 
Zurück