Search code examples
javauser-interfacewindowawt

Java AWT Window not shown


I'm on Ubuntu 15.04 and I have written following program:

import java.awt.Frame;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

public class TimeTable extends Frame {

    private Frame frame;

    public TimeTable(){
        setupGUI();
    }

    private void setupGUI(){
        frame = new Frame("TimeTable");
        frame.setSize(400, 400);
        frame.addWindowListener(new WindowAdapter(){
            public void wndClose(WindowEvent wndEvent){
                System.exit(0);
            }
        });
        frame.setVisible(true);
    }

    public static void main(String[] args){
        TimeTable timetable = new TimeTable();
    }
}

It should be a little GUI (AWT) Test-Window.

I build it with:

>> javac TimeTable.java

And run it with:

>> java TimeTable

The ICON of the AWT APP is shown in my Launcher Sidebar, but the Window doesn't appears on my Desktop.

Why not?


Solution

  • You can install Java on Ubuntu without graphics libraries (headless?).

    Install the standard Java including graphics libraries and it should work. Your code works fine on Windows inside IntelliJ.