簡體   English   中英

當我點擊運行時什么也沒有發生

[英]When I click Run nothing happens

我的代碼比我添加的代碼多而不是刪除它,現在我的代碼將不再運行。 每次我點擊運行它都會顯示一個綠色的加載欄,然后沒有任何反應。 我想知道這是否與我錯過的代碼有關。

    class AmortizationLayout implements ActionListener {




AmortizationLayout() {
    JPanel jp = new JPanel(new BorderLayout(2,2));
    jp.setPreferredSize( new Dimension( 640, 480 ) );
    JPanel labelFields = new JPanel(new BorderLayout(2,2));
    labelFields.setBorder(new TitledBorder("Welcome"));
    JPanel jl = new JPanel(new GridLayout(0,1,1,1));      
    JPanel jf = new JPanel(new GridLayout(0,1,1,1));
    jp.setVisible(true);
    String[] dropdown = {"Buy", "Sell"};

    JComboBox options = new JComboBox(dropdown);
    JLabel BORS = new JLabel("Buy Or Sell");
    options.setSelectedIndex(0);
    options.addActionListener(this);

    String[] dropdown2 = {"APPLE", "MICROSOFT", "GOOGLE"};
    JComboBox options2 = new JComboBox(dropdown2);
    JLabel S2P = new JLabel("Stock To Purchase");
    options.setSelectedIndex(0);
    options.addActionListener(this);

        jl.add(new JLabel("Price($)" ));
        jf.add(new JTextField(30));
        jl.add(options2);
        jf.add(S2P);
        jl.add(new JLabel("FX Rate " ));
        jf.add(new JTextField(30));
        jl.add(new JLabel("Money to Spend" ));
        jf.add(new JTextField(30));
        jl.add(options);
        jf.add(BORS);




    labelFields.add(jl, BorderLayout.CENTER);
    labelFields.add(jf, BorderLayout.EAST);

    JPanel PCenter = new JPanel(new BorderLayout(2,2));
    PCenter.setBorder(new TitledBorder("Confirmation"));
    JPanel SubT = new JPanel(new FlowLayout(FlowLayout.CENTER));


    JButton btNewTask = new JButton("produce ticket");
    SubT.add(btNewTask );
    PCenter.add( SubT , BorderLayout.NORTH );

    PCenter.add(new JScrollPane(new JTextArea(5,30)));

    jp.add(labelFields, BorderLayout.NORTH);
    jp.add(PCenter, BorderLayout.CENTER);   
}
public static void main(String[] args) throws Exception {
    SwingUtilities.invokeLater(new Runnable(){
        @Override
        public void run() {
            new AmortizationLayout();
        }
    });
}

@Override
public void actionPerformed(ActionEvent arg0) {
    // TODO Auto-generated method stub

}

}

框架不見了。

添加

JFrame frame = new JFrame("Frame");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(jp);
frame.pack();
frame.setVisible(true);

AmortizationLayout

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM