开发者

Unable to execute java GUI program with Eclipse 3.6

I am unable to execute java gui program in eclipse 3.6 under ubuntu 11.04. when i click on run as Java Application nothing happens. When i switched to console there just <terminated>

So what to do. I have installed jdk 1.6.0_25

Also there is an openjdk installed in my system. but i don't know how to configure this with eclipse.

Here is the program:

public class AnimWallpaper {

    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated meth开发者_JAVA百科od stub
        UserInterface mainWindow = new UserInterface();
    }
}



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

public class UserInterface extends Frame {

    /**
     * Serial version Id
     */
    private static final long serialVersionUID = 7925308422918335055L;
    public UserInterface(){
        setTitle("Animated Wallpaper");
        setSize(400, 300);

        Container con = new Container();

        con.setBackground(new Color(83, 68, 235));



        add(con);
        addWindowListener(new WindowAdapter() {
            public void closingEvent(WindowEvent e){
                System.exit(0);
            }
        });
    }
}

Both classes are in different file and in same package com.anim

Thanks In advance:)


You need to set your window visible in order for it to show. add the line setVisible(true);

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜