Java Swing简单拆分面板GUI

时间:2017-11-12 17:17:42

标签: java swing jpanel

我试图制作一个简单的分割面板java GUI,其中左侧有自定义绘图,右侧有一个按钮,控件等。但是,当我运行代码时,绘图不会出现。不确定我是否也正确设置了面板。

package set07110;
/**
 * A String array defined as a static instance variable called data;
 */
public static String[] data = { "Achelous", "Ares", "Clytemnestra", "Eurystheus", "Icarus", "Naiads", "Phlegethon", "Sterope",
        "Acheron", "Argo", "Cocytus", "Euterpe", "Io", "Napaeae", "Phosphor", "Stheno", "Achilles", "Argus", };



public static void main(String[] args) { //Print the only two character name


    System.out.println("Task 1");
    System.out.println("Enter Length: ");
    Scanner scan = new Scanner(System.in);
    int qualifyingLength = scan.nextInt();

    for(String string: data) {

        if(!(qualifyingLength == string.length())) {
            System.out.println("Try again");
        }
        else if (qualifyingLength == string.length()) {
            System.out.println("The words are: " + string);
        }
    }
    System.out.println("Task 2");
    int count = 0; //Identify the three characters where the name ends with "seus"
    for (int index = 0; index < data.length; index++) { {
        if (data[index].contains("seus")) {
            count++;
            boolean seus = data[index].contains("seus");
            System.out.println("The words containing seus: " + data[index]);
        }

    }


    }
    //Print the names with 9 letter that end in "a".
    System.out.println("Task 3");
    System.out.println("Enter Length: ");
    int qualifyingLength1 = scan.nextInt();  // enter a number which indicates how much letter
    // do we want in a word
    for(String string: data) {
        int lastChar = (data.length - 1);
        boolean startsWithA = data.charAt(lastChar) == 'a'; //(have to find the last character in a Array of Strings
        // and see if the word ends with the character "a" --> (doesn't work)
        if(qualifyingLength1 == string.length() ) {
            System.out.println("The words are: " + string);
        }

    }
}

0 个答案:

没有答案