Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/341.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
运行应用程序(JAVA)时,框架变为空白_Java_Swing_Joptionpane - Fatal编程技术网

运行应用程序(JAVA)时,框架变为空白

运行应用程序(JAVA)时,框架变为空白,java,swing,joptionpane,Java,Swing,Joptionpane,所以,在这里一些人的帮助下,我能够编译并运行这些代码。但现在,又出现了另一个问题。运行应用程序时,面板为空白。我是个新手,我知道我在做傻事。我整晚都坐在这里试图让它完全工作,但不知道我还需要做什么才能让它工作 import java.awt.*; import java.applet.*; import java.awt.event.*; import java.awt.Graphics; import javax.swing.JOptionPane; import javax.swing.J

所以,在这里一些人的帮助下,我能够编译并运行这些代码。但现在,又出现了另一个问题。运行应用程序时,面板为空白。我是个新手,我知道我在做傻事。我整晚都坐在这里试图让它完全工作,但不知道我还需要做什么才能让它工作

 import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import java.awt.Graphics;
import javax.swing.JOptionPane;
import javax.swing.JApplet;
import java.awt.event.*;

public class telephoneKeypad extends javax.swing.JFrame
{


    public void telephoneKeypad()
    {
        Panel pnlKeyPad = new Panel();
          GridLayout gridLayout1 = new GridLayout();
          Button btnZero = new Button();
          Button btnOne = new Button();
          Button btnTwo = new Button();
          Button btnThree = new Button();
        Button btnFour = new Button();
          Button btnFive = new Button();
          Button btnSix = new Button();
          Button btnSeven = new Button();
          Button btnEight = new Button();
          Button btnNine = new Button();
          Button btnStar = new Button();
          Button btnHash = new Button();

        TextField tfNumber = new TextField();
          Button btnDial = new Button();
          BorderLayout borderLayout1 = new BorderLayout();
          Panel pnlNumberEntry = new Panel();
          FlowLayout flowLayout1 = new FlowLayout();





            btnOne.setLabel("1");
            btnTwo.setLabel("2");
            btnThree.setLabel("3");
            btnFour.setLabel("4");
            btnFive.setLabel("5");
            btnSix.setLabel("6");
            btnSeven.setLabel("7");
            btnEight.setLabel("8");
            btnNine.setLabel("9");
            btnStar.setLabel("*");
            btnZero.setLabel("0");
            btnHash.setLabel("#");
            btnDial.setLabel("Dial");

            pnlNumberEntry.setLayout(flowLayout1);
            pnlKeyPad.setLayout(gridLayout1);
            this.setLayout(borderLayout1);
            this.add(pnlNumberEntry, BorderLayout.NORTH);
            pnlNumberEntry.add(tfNumber, null);
            pnlNumberEntry.add(btnDial, null);
            this.add(pnlKeyPad, BorderLayout.CENTER);
            pnlKeyPad.add(btnOne, null);
            pnlKeyPad.add(btnTwo, null);
            pnlKeyPad.add(btnThree, null);
            pnlKeyPad.add(btnFour, null);
            pnlKeyPad.add(btnFive, null);
            pnlKeyPad.add(btnSix, null);
            pnlKeyPad.add(btnSeven, null);
            pnlKeyPad.add(btnEight, null);
            pnlKeyPad.add(btnNine, null);
            pnlKeyPad.add(btnStar, null);
            pnlKeyPad.add(btnZero, null);
            pnlKeyPad.add(btnHash, null);
        }

            public static void main(String args[])
                {
                telephoneKeypad kpad = new telephoneKeypad();
                kpad.setBounds(500, 500, 500, 500);
                kpad.setVisible(true);
    }
 }

您声明构造函数错误-
公用无效电话键盘()
而不是
公用电话键盘()

您仍然需要在面板上工作,但这将实际运行您的构造函数,而不是默认构造函数


另外,类名通常以大写字母开头。

您声明构造函数错误-
public void telephoneKeypad()
而不是
public telephoneKeypad()

您仍然需要在面板上工作,但这将实际运行您的构造函数,而不是默认构造函数


另外,类名通常以大写字母开头。

谢谢,我不知道我怎么忘了从中删除“void”。现在我所要做的就是改变这些面板的大小,我就准备好了@乔希,鉴于你似乎忽略了你最后一条线索上的每一条线索,我认为你离“设定”还很远。但是,如果你不理我,我看不出有任何帮助的必要(谢谢,我不知道我怎么会忘了从中删除“void”。现在我所要做的就是改变这些面板的大小,我就准备好了!@Josh如果你似乎忽略了你最后一条线上的每一个细节,我会说你离“set”很远。但是如果你忽略我,我看不出有任何帮助的意义(