在JFrame里面的JTextField,JButton都能显示,就JLabel显示,为什么啊下面是我的代码
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;public class Loading extends JFrame{
private static JButton load;
private static JButton exit;
private JTextField user, password;
private Label tUser, tPassword;
static int locX = 100;
static int locY = 100;
private static int WIDTH = 400;
private static int HIGHT = 200;
static int BWIDTH = 80;
static int BHIGHT = 30;
public Loading(){
this.setBounds(locX, locY, WIDTH, HIGHT);
this.setVisible(true);
this.setTitle("登陆");
this.setLayout(null); //设空后才可以自己排版
this.setResizable(false);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
load = new JButton("登陆");
exit = new JButton("退出");
add(load);
add(exit);
load.setBounds(WIDTH/4-BWIDTH/2, HIGHT/2, BWIDTH, BHIGHT);
exit.setBounds(3*WIDTH/4-BWIDTH/2, HIGHT/2, BWIDTH, BHIGHT); tUser = new Label("用户名");
tUser.setLocation(WIDTH/4, HIGHT/10);
add(tUser);
tPassword = new Label("密码");
tPassword.setLocation(WIDTH/4, 3*HIGHT/10);
add(tPassword);
user = new JTextField();
user.setBounds(WIDTH/2, HIGHT/10, WIDTH/3, 20);
add(user);
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;public class Loading extends JFrame{
private static JButton load;
private static JButton exit;
private JTextField user, password;
private Label tUser, tPassword;
static int locX = 100;
static int locY = 100;
private static int WIDTH = 400;
private static int HIGHT = 200;
static int BWIDTH = 80;
static int BHIGHT = 30;
public Loading(){
this.setBounds(locX, locY, WIDTH, HIGHT);
this.setVisible(true);
this.setTitle("登陆");
this.setLayout(null); //设空后才可以自己排版
this.setResizable(false);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
load = new JButton("登陆");
exit = new JButton("退出");
add(load);
add(exit);
load.setBounds(WIDTH/4-BWIDTH/2, HIGHT/2, BWIDTH, BHIGHT);
exit.setBounds(3*WIDTH/4-BWIDTH/2, HIGHT/2, BWIDTH, BHIGHT); tUser = new Label("用户名");
tUser.setLocation(WIDTH/4, HIGHT/10);
add(tUser);
tPassword = new Label("密码");
tPassword.setLocation(WIDTH/4, 3*HIGHT/10);
add(tPassword);
user = new JTextField();
user.setBounds(WIDTH/2, HIGHT/10, WIDTH/3, 20);
add(user);
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货