프로그램을 별도로 호출하고 실행하는 메뉴를 만들기 위해 JOptionPane
을 사용하고 있습니다 (애플릿과 메뉴는 필요하지 않습니다. init()
메서드를 호출하려고했지만 "비 정적 메서드 init()은 정적 명령문에서 참조 할 수 없습니다." 애플릿은 노래를 재생하는 데 사용됩니다이 프로그램에서이 애플릿을 어떻게 호출합니까?
코드 :
첫 번째 프로그램 : *
import javax.swing.JOptionPane;
public class MexicoProject
{
public static void main(String[] args)
{
String[] choice = {"History", "Trivia", "Intro", "Anthem", "Quit"};
String Menu;
do
{
Menu = (String)JOptionPane.showInputDialog(null, "Welcome, this program will teach you about the history of Mexico.\nPick one of the options below.",
"Mexico History", JOptionPane.QUESTION_MESSAGE, null, choice, choice[0]);
if (Menu == null)
JOptionPane.showMessageDialog(null, "Pick something!");
else
{
switch (Menu)
{
case "History":
MexicoHistory.History();
break;
case "Trivia":
Quiz();
break;
case "Intro":
FrenchIntro.Intro();
break;
case "Anthem":
MexicoAnthem.Init();
break;
case "Quit":
JOptionPane.showMessageDialog(null, "Goodbye!");
break;
default:
JOptionPane.showMessageDialog(null, "Something went wrong! Try again!");
}
}
} while (Menu != "Quit");
}
public static void History()
{
}
public static void Quiz()
{
}
}*
번째 프로그램 : 당신이하려는
import java.applet.*;
import java.net.*;
public class MexicoAnthem extends Applet
{
Button button;
public void Init()
{
BorderLayout layout = new BorderLayout();
setLayout(layout);
Font font = new Font("TimesRoman", Font.BOLD, 32);
setFont(font);
button = new Button("Play Sound");
add("Center", button);
resize(250, 250);
}
public boolean action(Event evt, Object arg)
{
if (evt.target instanceof Button)
{
URL codeBase = getCodeBase();
play(codeBase, "MexicanNationalAnthem.wav");
}
return true;
}
}
"이 애플릿을이 프로그램에 호출하십시오"....정말로 사람들이 당신의 제목에서 의미있는 것을 얻을 것이라고 생각합니까? –
그게 무슨 뜻입니까? – user3350704
제목이 무엇을 의미합니까? 문제의 의미있는 요약을 제공하는 의미있는 제목을주십시오. 예 : 애플릿을 Swing 어플리케이션에 임베드하는 방법. 또는; "정적이 아닌 메서드를 정적 문에서 참조 할 수 없음"등의 의미 –