windowbuilder中的脚本(Eclipse、Java)

windowbuilder中的脚本(Eclipse、Java),java,eclipse,eclipse-plugin,windowbuilder,Java,Eclipse,Eclipse Plugin,Windowbuilder,所以我刚开始使用eclipse和java脚本,我也是一名新的程序员。我开始了这个随机取名字的项目。代码是这样写的: public static void gods() { System.out.println("You have to play this God:"); String[] gods = {"Agni", "Ah Muzen Cab", "Ah Puch"

所以我刚开始使用eclipse和java脚本,我也是一名新的程序员。我开始了这个随机取名字的项目。代码是这样写的:

public static void gods() {
        System.out.println("You have to play this God:");
        String[] gods =
                {"Agni",
                "Ah Muzen Cab",
                "Ah Puch",
                "Amaterasu",
                "Anhur",
                "Anubis",
                "Ao Kuang",
                "Aphrodite",
                "Apollo",
                "Arachne",
                "Ares",
                "Artemis",
                "Athena",
                "Awilix",
                "Bacchus",
                "Bakasura",
                "Bastet",
                "Bellona",
                "Cabrakan",
                "Chaac",
                "Change",
                "Chiron",
                "Chronos",
                "Cupid",
                "Fenrir",
                "Geb",
                "Guan Yu",
                "Hades",
                "He Bo",
                "Hel",
                "Hercules",
                "Hou Yi",
                "Hun Batz",
                "Isis",
                "Janus",
                "Kali",
                "Khepri",
                "Kukulkan",
                "Kumbhakarna",
                "Loki",
                "Medusa",
                "Mercury",
                "Ne Zha",
                "Neith",
                "Nemesis",
                "Nox",
                "Nu Wa",
                "Odin",
                "Osiris",
                "Poseidon",
                "Ra",
                "Rama",
                "Ratatoskr",
                "Ravana",
                "Scylla",
                "Serqet",
                "Sobek",
                "Sol",
                "Sun Wukong",
                "Sylvanus",
                "Thanatos",
                "Thor",
                "Tyr",
                "Ullr",
                "Vamana",
                "Vulcan",
                "Xbalanque",
                "Xing Tian",
                "Ymir",
                "Zeus",
                "Zhong Kui"};
        List<String> names = Arrays.asList(gods);
        int index = new Random().nextInt(names.size());
        String name = names.get(index);
        System.out.print(name + " ");
    }


    public static void roles() {
        String[] roles = {" Solo", " Jungle", " Mid", " ADC", " Support"};
        List<String> names = Arrays.asList(roles);
        int index = new Random().nextInt(names.size());
        String name = names.get(index);
        System.out.print(name + " ");}

public void Randomize() {
    System.out.println("Here you have your god:");
        gods();
    System.out.println("Here you have your role:"); 
        roles();}
附言:这是我拍摄它时的样子:

公务舱{

private JFrame frame;


/**
 * Launch the application.
 */
public static void main(String[] args) {
    EventQueue.invokeLater(new Runnable() {
        public void run() {
            try {
                Plswork window = new Plswork();
                window.frame.setVisible(true);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
}

/**
 * Create the application.
 */
    initialize();
}

/**
 * Initialize the contents of the frame.
 */
private void initialize() {
    frame = new JFrame();
    frame.getContentPane().setFont(new Font("Comic Sans MS", Font.PLAIN, 18));
    frame.getContentPane().setBackground(Color.MAGENTA);
    frame.setBounds(100, 100, 450, 300);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().setLayout(null);

    JButton btnNewButton = new JButton("Sebbe");
    btnNewButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            System.out.println("You have to play this God:");
            String[] gods =
                    {"Agni",
                    "Ah Muzen Cab",
                    "Ah Puch",
                    "Amaterasu",
                    "Anhur",
                    "Anubis",
                    "Ao Kuang",
                    "Aphrodite",
                    "Apollo",
                    "Arachne",
                    "Ares",
                    "Artemis",
                    "Athena",
                    "Awilix",
                    "Bacchus",
                    "Bakasura",
                    "Bastet",
                    "Bellona",
                    "Cabrakan",
                    "Chaac",
                    "Change",
                    "Chiron",
                    "Chronos",
                    "Cupid",
                    "Fenrir",
                    "Geb",
                    "Guan Yu",
                    "Hades",
                    "He Bo",
                    "Hel",
                    "Hercules",
                    "Hou Yi",
                    "Hun Batz",
                    "Isis",
                    "Janus",
                    "Kali",
                    "Khepri",
                    "Kukulkan",
                    "Kumbhakarna",
                    "Loki",
                    "Medusa",
                    "Mercury",
                    "Ne Zha",
                    "Neith",
                    "Nemesis",
                    "Nox",
                    "Nu Wa",
                    "Odin",
                    "Osiris",
                    "Poseidon",
                    "Ra",
                    "Rama",
                    "Ratatoskr",
                    "Ravana",
                    "Scylla",
                    "Serqet",
                    "Sobek",
                    "Sol",
                    "Sun Wukong",
                    "Sylvanus",
                    "Thanatos",
                    "Thor",
                    "Tyr",
                    "Ullr",
                    "Vamana",
                    "Vulcan",
                    "Xbalanque",
                    "Xing Tian",
                    "Ymir",
                    "Zeus",
                    "Zhong Kui"};
            List<String> names = Arrays.asList(gods);
            int index = new Random().nextInt(names.size());
            String name = names.get(index);
            System.out.print(name + " ");
        }
    });
    btnNewButton.setBounds(167, 117, 89, 23);
    frame.getContentPane().add(btnNewButton);
}



    public void actionPerformed(ActionEvent e) {
    }
}
私有JFrame;
/**
*启动应用程序。
*/
公共静态void main(字符串[]args){
invokeLater(新的Runnable(){
公开募捐{
试一试{
Plswork窗口=新Plswork();
window.frame.setVisible(true);
}捕获(例外e){
e、 printStackTrace();
}
}
});
}
/**
*创建应用程序。
*/
初始化();
}
/**
*初始化框架的内容。
*/
私有void初始化(){
frame=新的JFrame();
frame.getContentPane().setFont(新字体(“Comic Sans MS”,Font.PLAIN,18));
frame.getContentPane().setBackground(Color.MAGENTA);
机架立根(100450300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(null);
JButton btnNewButton=新JButton(“Sebbe”);
addActionListener(新ActionListener(){
已执行的公共无效操作(操作事件e){
System.out.println(“你必须扮演这个上帝:”);
弦[]神=
{“烈火”,
“阿木赞出租车”,
“阿普”,
“天照”,
“安胡尔”,
“阿努比斯”,
“奥光”,
“阿芙罗狄蒂”,
“阿波罗”,
“蜘蛛网”,
“战神”,
“阿耳特弥斯”,
“雅典娜”,
“Awilix”,
“巴克斯”,
“巴卡苏拉”,
“巴斯特”,
“贝洛娜”,
“卡布拉坎”,
“查克”,
“改变”,
“凯龙”,
“Chronos”,
“丘比特”,
“芬利尔”,
“Geb”,
“关羽”,
“地狱”,
“何波”,
“Hel”,
“大力神”,
“后羿”,
“Hun Batz”,
“伊斯兰国”,
“杰纳斯”,
“卡利”,
“Khepri”,
“库尔坎”,
“Kumbhakarna”,
“洛基”,
“美杜莎”,
“水星”,
“娜扎”,
“Neith”,
“复仇女神”,
“氮氧化物”,
“女娲”,
“奥丁”,
“欧西里斯”,
“波塞冬”,
“Ra”,
“拉玛”,
“ratoskr”,
“拉瓦纳”,
“锡拉”,
“Serqet”,
“索贝克”,
“索尔”,
“孙悟空”,
“西尔瓦努斯”,
“塔纳托斯”,
“雷神”,
“提尔”,
“乌勒”,
“瓦玛纳”,
“火神”,
“Xbalanque”,
“星天”,
“Ymir”,
“宙斯”,
"钟魁",;
列表名称=Arrays.asList(goods);
int index=new Random().nextInt(names.size());
字符串名称=names.get(索引);
系统输出打印(名称+“”);
}
});
btnNewButton.setBounds(167117 89 23);
frame.getContentPane().add(btnNewButton);
}
已执行的公共无效操作(操作事件e){
}
}

理想情况下,您应该在问题中直接包含最少的相关源代码,而不是链接到外部源代码。外部链接最终会消失,当这种情况发生时,你的问题就不再有意义了。Java和Javascript是两种完全不同的语言,不要混淆它们。这里只提供Java.Off-topic:Smite FTW!理想情况下,您应该在问题中直接包含最少的相关源代码,而不是链接到外部源代码。外部链接最终会消失,当这种情况发生时,你的问题就不再有意义了。Java和Javascript是两种完全不同的语言,不要混淆它们。这里只提供Java.Off-topic:Smite FTW!
private JFrame frame;


/**
 * Launch the application.
 */
public static void main(String[] args) {
    EventQueue.invokeLater(new Runnable() {
        public void run() {
            try {
                Plswork window = new Plswork();
                window.frame.setVisible(true);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
}

/**
 * Create the application.
 */
    initialize();
}

/**
 * Initialize the contents of the frame.
 */
private void initialize() {
    frame = new JFrame();
    frame.getContentPane().setFont(new Font("Comic Sans MS", Font.PLAIN, 18));
    frame.getContentPane().setBackground(Color.MAGENTA);
    frame.setBounds(100, 100, 450, 300);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().setLayout(null);

    JButton btnNewButton = new JButton("Sebbe");
    btnNewButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            System.out.println("You have to play this God:");
            String[] gods =
                    {"Agni",
                    "Ah Muzen Cab",
                    "Ah Puch",
                    "Amaterasu",
                    "Anhur",
                    "Anubis",
                    "Ao Kuang",
                    "Aphrodite",
                    "Apollo",
                    "Arachne",
                    "Ares",
                    "Artemis",
                    "Athena",
                    "Awilix",
                    "Bacchus",
                    "Bakasura",
                    "Bastet",
                    "Bellona",
                    "Cabrakan",
                    "Chaac",
                    "Change",
                    "Chiron",
                    "Chronos",
                    "Cupid",
                    "Fenrir",
                    "Geb",
                    "Guan Yu",
                    "Hades",
                    "He Bo",
                    "Hel",
                    "Hercules",
                    "Hou Yi",
                    "Hun Batz",
                    "Isis",
                    "Janus",
                    "Kali",
                    "Khepri",
                    "Kukulkan",
                    "Kumbhakarna",
                    "Loki",
                    "Medusa",
                    "Mercury",
                    "Ne Zha",
                    "Neith",
                    "Nemesis",
                    "Nox",
                    "Nu Wa",
                    "Odin",
                    "Osiris",
                    "Poseidon",
                    "Ra",
                    "Rama",
                    "Ratatoskr",
                    "Ravana",
                    "Scylla",
                    "Serqet",
                    "Sobek",
                    "Sol",
                    "Sun Wukong",
                    "Sylvanus",
                    "Thanatos",
                    "Thor",
                    "Tyr",
                    "Ullr",
                    "Vamana",
                    "Vulcan",
                    "Xbalanque",
                    "Xing Tian",
                    "Ymir",
                    "Zeus",
                    "Zhong Kui"};
            List<String> names = Arrays.asList(gods);
            int index = new Random().nextInt(names.size());
            String name = names.get(index);
            System.out.print(name + " ");
        }
    });
    btnNewButton.setBounds(167, 117, 89, 23);
    frame.getContentPane().add(btnNewButton);
}



    public void actionPerformed(ActionEvent e) {
    }
}