简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM