簡體   English   中英

為什么此Java代碼顯示錯誤?

[英]Why is this java code showing error?

package mygridLayout;
import java.awt.*;
import javax.swing.*;
public class MyGridLayout
{
    JFrame f;
    MyGridLayout()
            {
                f = new JFrame();

                JButton b1 = new JButton("1");
                JButton b2 = new JButton("2");
                JButton b3 = new JButton("3");
                JButton b4 = new JButton("4");
                JButton b5 = new JButton("5");
                JButton b6 = new JButton("6");
                JButton b7 = new JButton("7");
                JButton b8 = new JButton("8");
                JButton b9 = new JButton("9");

                f.add(b1);
                f.add(b2);
                f.add(b3);
                f.add(b4);
                f.add(b5);
                f.add(b6);
                f.add(b7);
                f.add(b8);
                f.add(b9);

                f.setLayout(new GridLayout(3,3));

                f.setSize(300,300);
                f.setVisible(true);
            }
    public static void main(String[] args)
    {
        new MyGridLayout();
    }
}

錯誤:找不到或加載主類mygridlayout.MyGridLayout C:\\ Users \\ Home \\ AppData \\ Local \\ NetBeans \\ Cache \\ 8.2 \\ executor-snippets \\ run.xml:53:Java返回:1建立失敗(總時間:0秒)

  1. 在項目瀏覽器中右鍵單擊您的項目
  2. 點擊屬性
  3. 點擊運行
  4. 確保您的主類是您想要成為切入點的主類。 (確保使用完全限定的名稱,即mypackage.MyClass)
  5. 單擊確定。
  6. 清理構建項目
  7. 運行項目:)

如果只想運行文件,請右鍵單擊包瀏覽器中的類,然后單擊“運行文件”,或者單擊( Alt + RF )或( Shift + F6

暫無
暫無

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

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