java图形界面的问题
packagecom.cncd.ch04.client;importjavax.swing.*;importjava.awt.*;importjava.awt.event...
package com.cncd.ch04.client;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
public final class RF extends JFrame implements KeyListener, ActionListener, ItemListener, FocusListener {
public static final String appName = "Register";
JPanel RPanel;
JTextField RtxtNick;
JPasswordField RtxtPassword;
JButton RbuttonRegister;
public RF() {
RuiInit();
}
public void RuiInit() {
RPanel = new JPanel(new GridLayout(0, 2));
RPanel.add(new JLabel("Nick:"));
RPanel.add(RtxtNick = new JTextField());
RPanel.add(new JLabel("Password:"));
RPanel.add(RtxtPassword = new JPasswordField());
RPanel.add(new JLabel(""));
RPanel.add(RbuttonRegister = new JButton("Register"));
RtxtNick.addFocusListener(this);
RtxtNick.addKeyListener(this);
RtxtPassword.addKeyListener(this);
RtxtPassword.addFocusListener(this);
RbuttonRegister.addKeyListener(this);
}
public static void main(String args[]) {
RF rf = new RF();
rf.setTitle(rf.appName);
rf.setSize(300, 300);
rf.setLocation(100, 100);
rf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
rf.setVisible(true);
}
}
为什么只显示一个框,没有里面的按钮等内容呢? 展开
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
public final class RF extends JFrame implements KeyListener, ActionListener, ItemListener, FocusListener {
public static final String appName = "Register";
JPanel RPanel;
JTextField RtxtNick;
JPasswordField RtxtPassword;
JButton RbuttonRegister;
public RF() {
RuiInit();
}
public void RuiInit() {
RPanel = new JPanel(new GridLayout(0, 2));
RPanel.add(new JLabel("Nick:"));
RPanel.add(RtxtNick = new JTextField());
RPanel.add(new JLabel("Password:"));
RPanel.add(RtxtPassword = new JPasswordField());
RPanel.add(new JLabel(""));
RPanel.add(RbuttonRegister = new JButton("Register"));
RtxtNick.addFocusListener(this);
RtxtNick.addKeyListener(this);
RtxtPassword.addKeyListener(this);
RtxtPassword.addFocusListener(this);
RbuttonRegister.addKeyListener(this);
}
public static void main(String args[]) {
RF rf = new RF();
rf.setTitle(rf.appName);
rf.setSize(300, 300);
rf.setLocation(100, 100);
rf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
rf.setVisible(true);
}
}
为什么只显示一个框,没有里面的按钮等内容呢? 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询