java TextField 取出字符串 和 string类型变量比较
内容一样他也不认昂java达人们帮帮忙额主要出问题的地方就是打注释的那里ps:艹的百度刚才问过一遍不给显示//log.javaimportjava.awt.*;impor...
内容一样他也不认昂java达人们帮帮忙额
主要出问题的地方就是打注释的那里
ps:艹的百度 刚才问过一遍不给显示
//log.java
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.io.*;
import javax.swing.*;
import javax.swing.event.*;
public class log extends Frame
{
private class WindowCloser extends WindowAdapter
{
public void windowClosing( WindowEvent we )
{
System.exit(0);
}
}
String[][] user_group = {{"root","sirenia"},{"administrator","admin"}};//user_group[0][0]的出处
int user_count = 2;
boolean flag = false;
JButton login = new JButton("login");
JButton exit = new JButton("exit");
Label user = new Label("username:");
Label psw = new Label("password:");
TextField _user = new TextField(13); //TextField
TextField _psw = new TextField(13);
log()
{
super("login...");
setSize(230, 180);
setLocation(200,200);
show();
setLayout(null);
setBackground(new Color(255,255,255));
add(user);
user.setSize(80,20);
user.setLocation(5,30);
add(psw);
psw.setSize(80,20);
psw.setLocation(5,70);
add(_user);
_user.setSize(120,25);
_user.setLocation(100,25);
add(_psw);
_psw.setSize(120,25);
_psw.setLocation(100,65);
_psw.setEchoChar('*');
add(login);
login.setSize(80,50);
login.setLocation(25,110);
login.addActionListener
(
new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent e)
{
if(_user.getText() == user_group[0][0]) //为什么这个不好使
JOptionPane.showMessageDialog(null,"fuck_java_1");
else if("root"== _user.getText()) //还有这个不好使
JOptionPane.showMessageDialog(null,"fuck_java_2");
else if("root" == user_group[0][0]) //这个好使
JOptionPane.showMessageDialog(null,"fuck_java_3");
_user.setText(_user.getText()+"_fuckjava"); //这个又好使
}
}
);
add(exit);
exit.setSize(80,50);
exit.setLocation(130,110);
exit.addActionListener
(
new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent e)
{
System.exit(0);
}
}
);
validate();
addWindowListener(new WindowCloser());
}
public static void main(String args[])
{
log fr = new log();
}
} 展开
主要出问题的地方就是打注释的那里
ps:艹的百度 刚才问过一遍不给显示
//log.java
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.io.*;
import javax.swing.*;
import javax.swing.event.*;
public class log extends Frame
{
private class WindowCloser extends WindowAdapter
{
public void windowClosing( WindowEvent we )
{
System.exit(0);
}
}
String[][] user_group = {{"root","sirenia"},{"administrator","admin"}};//user_group[0][0]的出处
int user_count = 2;
boolean flag = false;
JButton login = new JButton("login");
JButton exit = new JButton("exit");
Label user = new Label("username:");
Label psw = new Label("password:");
TextField _user = new TextField(13); //TextField
TextField _psw = new TextField(13);
log()
{
super("login...");
setSize(230, 180);
setLocation(200,200);
show();
setLayout(null);
setBackground(new Color(255,255,255));
add(user);
user.setSize(80,20);
user.setLocation(5,30);
add(psw);
psw.setSize(80,20);
psw.setLocation(5,70);
add(_user);
_user.setSize(120,25);
_user.setLocation(100,25);
add(_psw);
_psw.setSize(120,25);
_psw.setLocation(100,65);
_psw.setEchoChar('*');
add(login);
login.setSize(80,50);
login.setLocation(25,110);
login.addActionListener
(
new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent e)
{
if(_user.getText() == user_group[0][0]) //为什么这个不好使
JOptionPane.showMessageDialog(null,"fuck_java_1");
else if("root"== _user.getText()) //还有这个不好使
JOptionPane.showMessageDialog(null,"fuck_java_2");
else if("root" == user_group[0][0]) //这个好使
JOptionPane.showMessageDialog(null,"fuck_java_3");
_user.setText(_user.getText()+"_fuckjava"); //这个又好使
}
}
);
add(exit);
exit.setSize(80,50);
exit.setLocation(130,110);
exit.addActionListener
(
new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent e)
{
System.exit(0);
}
}
);
validate();
addWindowListener(new WindowCloser());
}
public static void main(String args[])
{
log fr = new log();
}
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询