Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.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_Applet_Interactive_Jgrasp - Fatal编程技术网

在java中打开单独的窗口,一个是图形小程序,另一个是交互式文本字段

在java中打开单独的窗口,一个是图形小程序,另一个是交互式文本字段,java,applet,interactive,jgrasp,Java,Applet,Interactive,Jgrasp,所以我对Java脚本比较陌生,有时间搞得有点乱,似乎在某个方面有些困难。我在编程课上有一个项目,被分配了一些细节,因为我的老师不需要太多,我想在我的程序中加入一些互动部分。我尝试过扫描仪的使用,总是得到一个只有文本框的白色屏幕,而不是我老师想要显示的图像,没有所说的扫描仪行,我可以有文本框和图形,但无法进行交互 到目前为止,我只得到了图像显示,作为一个人与简单的风景,和一个文本框,是注释了;我的问题是如何让文本框接受用户输入并分配变量以更改图像和数学 谢谢你的帮助 import java.awt

所以我对Java脚本比较陌生,有时间搞得有点乱,似乎在某个方面有些困难。我在编程课上有一个项目,被分配了一些细节,因为我的老师不需要太多,我想在我的程序中加入一些互动部分。我尝试过扫描仪的使用,总是得到一个只有文本框的白色屏幕,而不是我老师想要显示的图像,没有所说的扫描仪行,我可以有文本框和图形,但无法进行交互

到目前为止,我只得到了图像显示,作为一个人与简单的风景,和一个文本框,是注释了;我的问题是如何让文本框接受用户输入并分配变量以更改图像和数学

谢谢你的帮助

import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
import java.util.Scanner;
import java.net.*;
import java.io.Console;

public class Project extends Applet// implements ActionListener
{

/*TextField inputLine = new TextField(50);  

public Project() {
    add(inputLine);
    inputLine.addActionListener(this);

}

public void actionPerformed(ActionEvent event) {
//Scanner user_input = new Scanner(System.in);
    String s = inputLine.getText();
    String sUp = s.toUpperCase();
    inputLine.setText(sUp);


 */ // double X = user_input.nextInt();




public void paint(Graphics g)
{

//Foreground
setForeground(Color.green);
Expo.fillRectangle(g,0,0,1000,1000);

Expo.setColor(g,Expo.lightBlue);
Expo.fillRectangle(g,0,0,1000,200);

Expo.setColor(g,Expo.black);
//Variables
double X = 10;
double Y = 15;
double Z = X + Y;
//Drawn Words
Expo.drawString(g,"Brenden Noonen",10,20); //Heading

//Hair
Expo.setColor(g,Expo.gold);
Expo.fillArc(g,500,50,55,30,0,360);

Expo.setColor(g,Expo.black);
//Math
Expo.drawString(g,"Math: X + Y = Z",10,40);
Expo.drawString(g,"X: 10, Y: 15",10,60);
Expo.drawString(g,X + Y + "=" + Z,10,80);
Expo.drawString(g,"Answer: " + Z,10,100);

//Filled Rectangles Neck
Expo.setColor(g,Expo.lightTan);
Expo.fillRectangle(g,475,75,525,200);

Expo.setColor(g,Expo.black);
//Expo.drawRoundedRect(g,325,500,675,1000);


//Drawn Rectangles Neck
Expo.drawRectangle(g,475,75,525,200);
//Drawn Circles
//Expo.drawCircle(g,500,325,150);

//Filled Circles
Expo.setColor(g,Expo.lightTan);

Expo.fillCircle(g,500,75,50); //Face Fill

Expo.setColor(g,Expo.black);

Expo.fillCircle(g,475,65,5); //Eyes
Expo.fillCircle(g,525,65,5);

//Expo.fillCircle(g,440,265,10); 

Expo.drawCircle(g,500,75,50); //Face Outline

//Drawn Rectangles
Expo.drawRectangle(g,25,550,50,575);

//Filled Rectangles
Expo.fillRectangle(g,75,550,100,575);

//Drawn Circles
Expo.drawCircle(g,125,562,12);

//Filled Circles
Expo.fillCircle(g,165,562,12);

//Drawn Arcs
Expo.drawArc(g,500,95,15,10,90,270); //Mouth
Expo.drawArc(g,475,55,10,5,280,80); //Eyebrows
Expo.drawArc(g,525,55,10,5,280,80);
Expo.drawArc(g,500,80,5,12,60,130);//Nose

//Filled Arcs
//Expo.setColor(g,Expo.lightGray);
//Expo.fillArc(g,440,255,15,15,120,240);

//Drawn Ovals

//Filled Ovals
Expo.setColor(g,Expo.lightGray);
Expo.fillOval(g,475,68,4,2); //Eyes color
Expo.fillOval(g,525,68,4,2);

//Shirt
Expo.setColor(g,Expo.red);
Expo.fillOval(g,500,175,75,30); //shoulders


Expo.setColor(g,Expo.black);
Expo.drawOval(g,500,175,75,30); //top outline

Expo.setColor(g,Expo.red);
Expo.fillRectangle(g,440,175,560,300); //shirt
Expo.fillRectangle(g,440,175,425,220); //arm sides
Expo.fillRectangle(g,560,175,575,220);

//Arms
Expo.setColor(g,Expo.tan);
Expo.fillRectangle(g,428,220,438,380);
Expo.fillRectangle(g,563,220,573,380);

Expo.setColor(g,Expo.black);

//Hair Top
Expo.setColor(g,Expo.gold);
Expo.fillArc(g,500,30,55,15,0,360);

//Jeans
Expo.setColor(g,Expo.darkBlue);
Expo.fillRectangle(g,440,301,560,560);

Expo.setColor(g,Expo.black);
Expo.fillRectangle(g,440,540,560,560);

Expo.setColor(g,Expo.green);
Expo.fillRectangle(g,480,360,520,1000);

Expo.setColor(g,Expo.bronze);

//House
Expo.fillRectangle(g,875,150,975,250); //House base
Expo.setColor(g,Expo.black);
Expo.drawRectangle(g,875,150,975,250);

Expo.setColor(g,Expo.bronze);
Expo.fillPolygon(g,875,150,925,75,975,150); //Roof
Expo.setColor(g,Expo.black);
Expo.drawPolygon(g,875,150,925,75,975,150);

Expo.setColor(g,Expo.yellow);
Expo.fillRectangle(g,925,175,950,200);
Expo.setColor(g,Expo.black);
Expo.drawRectangle(g,925,175,950,200);

//Trees
Expo.setColor(g,Expo.brown);
Expo.fillRectangle(g,225,275,275,125);

Expo.setColor(g,Expo.darkGreen);
Expo.fillCircle(g,250,75,65);
}
}

要点:Java!=JavaScript。两个完全不同的东西,除了名字几乎没有任何共同点。。。问:如何让文本框接受输入?答:通常不是从System.in。相反,您可能需要一个动作侦听器。看这里:我试过Action Listener,但它也创建了白色屏幕。