从Processing导出的java小程序中带有awt的文本字段在浏览器中呈现黑色

从Processing导出的java小程序中带有awt的文本字段在浏览器中呈现黑色,java,applet,awt,textfield,processing,Java,Applet,Awt,Textfield,Processing,我正在构建的web小程序是一个交互式3D显示的建筑3D模型,上面覆盖着按钮和文本输入字段,允许用户登录。 当在处理草图中使用awt文本字段时,它在从处理IDE运行时正确显示和运行,但当草图作为小程序导出并通过任何浏览器加载时,所有文本字段都呈现纯黑色 在本视频中可以看到小程序的运行- 事实上,在尝试登录或创建新用户时,您可能会遇到此问题- 一般来说,在处理过程中很少有GUI库,比如controlP5,在使用awt的TextField之前,我已经尝试过使用所有这些库。原因是:ControlP5的所

我正在构建的web小程序是一个交互式3D显示的建筑3D模型,上面覆盖着按钮和文本输入字段,允许用户登录。 当在处理草图中使用awt文本字段时,它在从处理IDE运行时正确显示和运行,但当草图作为小程序导出并通过任何浏览器加载时,所有文本字段都呈现纯黑色

在本视频中可以看到小程序的运行- 事实上,在尝试登录或创建新用户时,您可能会遇到此问题-

一般来说,在处理过程中很少有GUI库,比如controlP5,在使用awt的TextField之前,我已经尝试过使用所有这些库。原因是:ControlP5的所有UI组件都有相同的问题——它们在浏览器中呈现黑色。其他库(G4P、interfascia等)要么没有用于处理1.51的版本,要么没有提供Textfield类,要么在以清晰的图形显示文本方面存在问题-可能是因为我的案例中使用的P3D显示模式

不幸的是,必须使用Processing 1.5.1,而不是最新的2.0。这是因为到目前为止编写的PeasyCam库和其他代码细节与Processing 2.0不兼容

我愿意接受其他TextField类的建议或任何可能导致AWT内置TextField呈现黑色的提示

下面是使用awt生成文本字段的代码

import java.awt.*;
/// textfields
Panel dummyPanel = new Panel(); // voodoo 
//
Panel usernamePanel = new Panel(); // holder for input field 
TextField usernameField = new TextField(""); 
//
Panel passwordPanel = new Panel(); // holder for input field 
TextField passwordField = new TextField(""); 
//
Panel password2Panel = new Panel(); // holder for input field 
TextField password2Field = new TextField(""); 
//
Panel emailPanel = new Panel(); // holder for input field 
TextField emailField = new TextField("");       
// give all the containers a layout 
setLayout(new BorderLayout()); // main container (window?) 
usernamePanel.setLayout(new BorderLayout()); 
passwordPanel.setLayout(new BorderLayout()); 
password2Panel.setLayout(new BorderLayout()); 
emailPanel.setLayout(new BorderLayout()); 
// add the containers to the main container 

// Now we can set the bounds of the text fields // left, top, width, height 
int borderSize = 100; // for calculating size of fields 
int inputHeight = 20; // height of input field 
usernamePanel.setBounds(618, 85, 1000-618-15, inputHeight); 
passwordPanel.setBounds(618, 135, 1000-618-15, inputHeight); 
password2Panel.setBounds(618, 185, 1000-618-15, inputHeight); 
emailPanel.setBounds(618, 235, 1000-618-15, inputHeight); 
//
usernamePanel.setBackground(new Color(128, 128, 128, 0)); 
passwordPanel.setBackground(new Color(128, 128, 128, 0)); 
password2Panel.setBackground(new Color(128, 128, 128, 0)); 
emailPanel.setBackground(new Color(128, 128, 128, 0)); 
// Don't know why this works but it does. 
// The dummy is held by the main container and doesn't contain anything 
// yet without it, the input field inexplicably expands to contain the output field 
// (try commenting it out). 
// It also needs to be placed in the center. 
dummyPanel.setBackground(new Color(128, 128, 128, 0)); 

add(dummyPanel, BorderLayout.CENTER);
passwordField.setEchoChar('*');
password2Field.setEchoChar('*');
//    
add(usernamePanel); 
add(passwordPanel); 
add(password2Panel);
add(emailPanel); 
usernamePanel.add(usernameField);
passwordPanel.add(passwordField);
password2Panel.add(password2Field);
emailPanel.add(emailField);

让您的小程序与网页对话,并使用HTML文本字段,而不是试图强制AWT进入一个非常非AWT应用程序?@quantx还保存一个版本的代码,并从库中尝试文本字段。