阅读背景:

与public static void的java奇怪错误

来源:互联网 
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;

import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

public class MainWindow {

    private JFrame frame;

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

    /**
     * Create the application.
     */
    public MainWindow() {
        initialize();
    }

    /**
     * Initialize the contents of the frame.
     */
    private void initialize() {
        frame = new JFrame();
        frame.setBounds(100, 100, 450, 300);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        JPanel panel = new JPanel();
        frame.getContentPane().add(panel, BorderLayout.CENTER);
        panel.setLayout(new GridLayout(4, 6, 0, 0));

        public static void main(String[] args) throws FileNotFoundException {
            Scanner scanner = new Scanner(new File("/Users/Patrick/Desktop/voorbeeld.csv"));
            scanner.useDelimiter(",");
            while(scanner.hasNext()){
                JTextField field = new JTextField();
                field.setText(scanner.next()+"|");
                panel.add(field);


            }
            scanner.close();

        }
    }
}
import java.awt.EventQueue;

import javax.swing



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: