Java问题,如果你可以帮助我 [英] Java problems if you could help me
本文介绍了Java问题,如果你可以帮助我的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经创建了一个登录屏幕,我希望图像不要缓冲这么多,也请你帮助我,我也很乐意,如果我登录时文本消失,当我唱歌失败时。如果你可以将文字颜色的颜色改为白色。非常感谢
我尝试过:
I have created a login screen i would like the image not to buffer so much, also could you please help me also i would love if the text would vanish when i log into it and when i sing unsuccessfully. also if u could change the color of the text color to white. thanks a lot
What I have tried:
import java.applet.Applet;
import java.awt.Event;
import java.awt.Font;
import java.awt.Image;
import java.awt.Graphics;
import java.awt.TextField;
import java.awt.image.BufferedImage;
import java.awt.Button;
import java.awt.Color;
import java.util.Scanner;
public class Loginagain extends Applet
{
Image img ;
String username = "123DUD" ;
String password = "123Fun" ;
String userinput ;
String passinput ;
String result = "" ;
String fnameinput ;
String snameinput ;
String ageinput ;
String emailinput ;
TextField fname ;
TextField sname ;
TextField email ;
TextField age ;
TextField user ;
TextField pass ;
Button submit ;
Button login ;
public void init()
{
setSize(500, 500) ;
img = getImage(getCodeBase(), "me.gif") ;
fname = new TextField(20) ;
sname = new TextField(20) ;
email = new TextField(20) ;
age = new TextField(20) ;
submit = new Button ("Submit") ;
user = new TextField(20) ;
pass = new TextField(20) ;
login = new Button("Login") ;
add(fname) ;
add(sname) ;
add(email) ;
add(age) ;
add(user) ;
add(pass) ;
add(submit) ;
add(login) ;
}
public boolean action (Event evt, Object arg)
{
if(evt.target == submit)
{
fnameinput = fname.getText() ;
snameinput = sname.getText() ;
ageinput = age.getText() ;
emailinput = email.getText() ;
}
if(evt.target == login)
{
userinput = user.getText() ;
passinput = pass.getText() ;
if(userinput.equals(username) &&passinput.equals(password))
{
result= "Login Successful";
img = getImage(getCodeBase(), "Fun.gif") ;
}
else
{
result= "Username/Password is Incorrect" ;
img = getImage(getCodeBase(), "DUD.gif") ;
}
repaint() ;
return true ;
}
return false;
}
public void paint(Graphics g)
{
g.drawImage(img, 0, 0, this) ;
fname.setBounds(170, 115, 200, 22) ;
sname.setBounds(170, 145, 200, 22) ;
age.setBounds(170, 175, 200, 22 ) ;
email.setBounds(170, 205, 200, 22) ;
submit.setBounds(220, 230, 100, 22) ;
user.setBounds(170, 380, 200, 22) ;
pass.setBounds(170, 405, 200, 22) ;
login.setBounds(220, 430, 100, 22);
g.setFont(new Font("Myraid Pro", Font.BOLD, 25)) ;
g.drawString("Login", 230, 48) ;
g.setFont(new Font("Myraid Pro", Font.PLAIN, 14 )) ;
g.drawString("Please enter your login details ", 180, 68) ;
g.setFont(new Font("Myriad Pro", Font.BOLD, 16)) ;
g.drawString(result, 215, 480) ;
g.drawString("Forname" , 75, 130) ;
g.drawString("Surname: ", 75, 160) ;
g.drawString("Age: ", 75, 190) ;
g.drawString("Email: ", 75, 220) ;
g.drawString("Username: ", 75, 395) ;
g.drawString("Password: ", 75, 420) ;
g.setFont(new Font("", Font.BOLD, 12)) ;
g.drawString(fnameinput, 200, 280) ;
g.drawString(snameinput, 200, 300) ;
g.drawString(ageinput, 200, 320) ;
g.drawString(emailinput, 200, 340) ;
}
}
推荐答案
嘿,我的意思是当我输入我的细节时,会出现一个图像在后台的文字,我希望图像出现和登录成功而不是其他如用户名和密码或注册等我希望那些在第二张图片出现时隐藏,当我写错了密码一个图像出现,如果可能的话,我想要同样的事情
Hey, I mean when i put in my details an image appears and with that the text in the background, i would like the image to appear and the "Login Successfully" yet not the other such as username and password or register etc i would like those to hid when the second image comes, also when i write the wrong password an image appears and i would like the same thing if its possible
这篇关于Java问题,如果你可以帮助我的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文