Die letzte Zeile generiert einen Fehler! Könnt ihr mir helfe

Status
Nicht offen für weitere Antworten.

NochNixBlicker

Bekanntes Mitglied
Code:
/**
 * 26.07.2008
 * Erik  Schulz
 */
package meinPaket;

import javax.swing.JFrame;
import javax.swing.JTextField;
import javax.swing.JMenu;
import javax.swing.JMenuBar;

public class HalloWelt extends JFrame
{

	private static final long serialVersionUID = 1L;
	
	public HalloWelt()
	{
	JTextField text = new JTextField("Hallo Welt");
	this.getContentPane().add(text);
	}

	/**
	 * @param args
	 */
	public static void main(String[] args)
	{
		// TODO Auto-generated method stub
		HalloWelt window = new HalloWelt();
		window.setTitle("GIZEH 1.0");
	//	window.setSize(MAXIMIZED_BOTH)
		window.setResizable(true);
		window.setVisible(true);
		window.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
		
		JMenuBar hauptmenu = new JMenuBar();
		JMenu fileMenu = new JMenu ("&Datei");
		JMenu additionalenu = new JMenu ("&Extras");
		JMenu questions = new JMenu ("&?");
		
		hauptmenu.add( fileMenu );
		hauptmenu.add( additionalenu);
		hauptmenu.add( questions );
		HalloWelt.setJMenuBar( hauptmenu );
	}
}
 
> HalloWelt.setJMenuBar( hauptmenu );

->

window.setJMenuBar( hauptmenu );


-------

> window.setVisible(true);

besser erst ganz zum Schluss
 
Hiho,

mach aus

Code:
HalloWelt.setJMenuBar(hauptmenu);

Das hier:

Code:
window.setJMenuBar(hauptmenu);

Aso:

benutze mal noch ein

Code:
window.setSize(int, int);

Und für Shortcuts bei JMenu nimm:

Code:
fileMenu.setMnemonic(KeyEvent.VK_D);

anstatt "&Datei"! Das ging bei Delphi soweit ich weiß aber nicht bei Java! 😉

Weiteres gibts hier zu lesen.

bye Saxony
 
Status
Nicht offen für weitere Antworten.

Zurück
Oben