关于JTabeedPane中多个JPane的显示问题 对于这种UI,楼主是不是都是手工写代码添加的的?如果是的话,强烈建议使用JBuilder来做.如果不是的话,建议不要使用XY或Null Layout 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 import javax.swing.*;import java.awt.*;import java.awt.event.*;import java.sql.*;import java.util.*;import java.io.*;import java.util.Date;import java.util.Calendar;import java.util.GregorianCalendar;import java.net.*;//<Applet code=Change1.class height=300 width=300 ></applet>public class Change1 extends JApplet implements Runnable{ JRadioButton man,woman; ButtonGroup bg; Label label_userID1 = new Label("用户名: "); Label label_userPassword1 = new Label("密码: "); JTextField text_userID1 = new JTextField(15); JPasswordField text_userPassword1 = new JPasswordField(15); JButton button_ok1 = new JButton("登入"); JButton button_register1 = new JButton("注册"); Label label_userID2 = new Label("用户名:"); Label label_userPassword2 = new Label("输入密码:"); Label label_userPasswordAgain2 = new Label("确认密码:"); Label label_userName2 = new Label("真实姓名:"); Label label_userSex2 = new Label("选择性别:"); Label label_userEmail2 = new Label("E-Mail:"); Label label_userAddress2 = new Label("联系地址:"); Label label_userZipcode2 = new Label("邮政编码:"); Label label_userCreditCardType2 = new Label("信用卡类型:"); Label label_userCreditCardNo2 = new Label("信用卡号码:"); Label label_userPersonCardType2 = new Label("证件类型:"); Label label_userPersonCardNo2 = new Label("证件号码:"); JTextField text_userID2 = new JTextField(15); JPasswordField text_userPassword2 = new JPasswordField(15); JPasswordField text_userPasswordAgain2 = new JPasswordField(15); JTextField text_userName2 = new JTextField(15); JTextField text_userEmail2 = new JTextField(15); JTextField text_userAddress2 = new JTextField(15); JTextField text_userZipcode2 = new JTextField(15); JTextField text_userCreditCardNo2 = new JTextField(15); JTextField text_userPersonCardNo2 = new JTextField(15); JButton button_ok2 = new JButton("注册"); JButton button_register2 = new JButton("清空"); JComboBox combo_userCreditCardType,combo_userPersonCardType; GridBagLayout gbl = new GridBagLayout(); GridBagConstraints gbc = new GridBagConstraints(); Thread datimeThread; Date date; GregorianCalendar calendar; String strDate,strTime,strStatus; String personSex,userPersonType2; JTabbedPane tabbedPane; JPanel toy,orders,accept,register;接下面的: 接上面: public void init() { tabbedPane=new JTabbedPane(); accept=new JPanel(); tabbedPane.addTab("登录",null,accept); register=new JPanel(); tabbedPane.addTab("注册",null,register); toy=new JPanel(); tabbedPane.addTab("玩具展区",null,toy,"快来看看哦!"); orders=new JPanel(); tabbedPane.addTab("订购",null,orders,"快来买东西噢!"); getContentPane().add(tabbedPane); tabbedPane.setEnabledAt(1,false); tabbedPane.setEnabledAt(3,false); accept.setLayout(gbl); gbc.gridx=0; gbc.gridy=0; gbc.anchor=GridBagConstraints.WEST; gbl.setConstraints(label_userID1,gbc); accept.add(label_userID1); gbc.gridx=1; gbc.gridy=0; gbc.anchor=GridBagConstraints.WEST; gbl.setConstraints(text_userID1,gbc); accept.add(text_userID1); gbc.gridx=0; gbc.gridy=1; gbc.anchor=GridBagConstraints.WEST; gbl.setConstraints(label_userPassword1,gbc); accept.add(label_userPassword1); gbc.gridx=1; gbc.gridy=1; gbc.anchor=GridBagConstraints.WEST; gbl.setConstraints(text_userPassword1,gbc); accept.add(text_userPassword1); gbc.gridx=1; gbc.gridy=2; gbc.anchor=GridBagConstraints.CENTER; gbl.setConstraints(button_ok1,gbc); accept.add(button_ok1); validateAction validateButton3 = new validateAction(); button_ok1.addActionListener(validateButton3); gbc.gridx=1; gbc.gridy=2; gbc.anchor=GridBagConstraints.EAST; gbl.setConstraints(button_register1,gbc); accept.add(button_register1); validateAction validateButton4 = new validateAction(); button_register1.addActionListener(validateButton4); register.setVisible(false); register.setLayout(gbl); bg=new ButtonGroup(); man=new JRadioButton("男"); woman=new JRadioButton("女"); bg.add(man); bg.add(woman); String CreditCardType[] = {"Master Card","Visa Card"}; String PersonCardType[]={"身份证","学生证","军人证"}; combo_userCreditCardType = new JComboBox(CreditCardType); combo_userPersonCardType = new JComboBox(PersonCardType); gbc.gridx=0; gbc.gridy=0; gbc.anchor=GridBagConstraints.WEST; gbl.setConstraints(label_userID2,gbc); register.add(label_userID2); gbc.gridx=1; gbc.gridy=0; gbl.setConstraints(text_userID2,gbc); register.add(text_userID2); gbc.gridx=0; gbc.gridy=1; gbc.anchor=GridBagConstraints.WEST; gbl.setConstraints(label_userPassword2,gbc); register.add(label_userPassword2); gbc.gridx=1; gbc.gridy=1; gbl.setConstraints(text_userPassword2,gbc); register.add(text_userPassword2); gbc.gridx=0; gbc.gridy=2; gbc.anchor=GridBagConstraints.WEST; gbl.setConstraints(label_userPasswordAgain2,gbc); register.add(label_userPasswordAgain2); gbc.gridx=1; gbc.gridy=2; gbl.setConstraints(text_userPasswordAgain2,gbc); register.add(text_userPasswordAgain2); gbc.gridx=0; gbc.gridy=3; gbc.anchor=GridBagConstraints.WEST; gbl.setConstraints(label_userName2,gbc); register.add(label_userName2); gbc.gridx=1; gbc.gridy=3; gbl.setConstraints(text_userName2,gbc); register.add(text_userName2); gbc.gridx=0; gbc.gridy=4; gbc.anchor=GridBagConstraints.WEST; gbl.setConstraints(label_userSex2,gbc); register.add(label_userSex2); gbc.gridx=1; gbc.gridy=4; gbc.anchor=GridBagConstraints.WEST; gbl.setConstraints(man,gbc); register.add(man); gbc.gridx=1; gbc.gridy=4; gbc.anchor=GridBagConstraints.CENTER; gbl.setConstraints(woman,gbc); register.add(woman); gbc.gridx=0; gbc.gridy=5; gbc.anchor=GridBagConstraints.WEST; gbl.setConstraints(label_userPersonCardType2,gbc); register.add(label_userPersonCardType2); gbc.gridx=1; gbc.gridy=5; gbc.anchor=GridBagConstraints.WEST; gbl.setConstraints(combo_userPersonCardType,gbc); register.add(combo_userPersonCardType); gbc.gridx=0; gbc.gridy=6; gbc.anchor=GridBagConstraints.WEST; gbl.setConstraints(label_userPersonCardNo2,gbc); register.add(label_userPersonCardNo2); gbc.gridx=1; gbc.gridy=6; gbl.setConstraints(text_userPersonCardNo2,gbc); register.add(text_userPersonCardNo2); gbc.gridx=0; gbc.gridy=7; gbc.anchor=GridBagConstraints.WEST; gbl.setConstraints(label_userEmail2,gbc); register.add(label_userEmail2); gbc.gridx=1; gbc.gridy=7; gbl.setConstraints(text_userEmail2,gbc); register.add(text_userEmail2); gbc.gridx=0; gbc.gridy=8; gbc.anchor=GridBagConstraints.WEST; gbl.setConstraints(label_userAddress2,gbc); register.add(label_userAddress2); gbc.gridx=1; gbc.gridy=8; gbl.setConstraints(text_userAddress2,gbc); register.add(text_userAddress2); gbc.gridx=0; gbc.gridy=9; gbc.anchor=GridBagConstraints.WEST; gbl.setConstraints(label_userZipcode2,gbc); register.add(label_userZipcode2); gbc.gridx=1; gbc.gridy=9; gbl.setConstraints(text_userZipcode2,gbc); register.add(text_userZipcode2); gbc.gridx=0; gbc.gridy=10; gbc.anchor=GridBagConstraints.WEST; gbl.setConstraints(label_userCreditCardType2,gbc); register.add(label_userCreditCardType2); gbc.gridx=1; gbc.gridy=10; gbc.anchor=GridBagConstraints.WEST; gbl.setConstraints(combo_userCreditCardType,gbc); register.add(combo_userCreditCardType); gbc.gridx=0; gbc.gridy=11; gbc.anchor=GridBagConstraints.WEST; gbl.setConstraints(label_userCreditCardNo2,gbc); register.add(label_userCreditCardNo2); gbc.gridx=1; gbc.gridy=11; gbl.setConstraints(text_userCreditCardNo2,gbc); register.add(text_userCreditCardNo2); gbc.gridx=1; gbc.gridy=12; gbc.anchor=GridBagConstraints.CENTER; gbl.setConstraints(button_ok2,gbc); register.add(button_ok2); validateAction validateButton1 = new validateAction(); button_ok2.addActionListener(validateButton1); gbc.gridx=1; gbc.gridy=12; gbc.anchor=GridBagConstraints.EAST; gbl.setConstraints(button_register2,gbc); register.add(button_register2); validateAction validateButton2 = new validateAction(); button_register2.addActionListener(validateButton2); datimeThread = new Thread(this); datimeThread.start(); } 没用过GridBagLayout,但register.setLayout(gbl);这里是不是应该新new一个GridBagLayout和GridBagConstraints呢? 关于nutch的配置问题 字符串向整形的转换错误 instanceof的错误 关于绘制双曲线和贝塞尔曲线的问题,求高手帮忙、、、、、、 JAVA的环境变量设置 想做一下Web版本的windows远程资源管理器对远程server的硬盘文件进行管理,请给点提示> JAVA程序编译后无法运行 JAVA 和本地相关信息的获取问题 问一个循环定时执行的问题,希望大家能来帮忙,谢谢~~~~~~~~~~~~~~ JBoss3.0 with Tomcat4.0.3怎么用? 子类访问父类具有相同名称的变量? JTextField如何控制输入长度
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import java.util.*;
import java.io.*;
import java.util.Date;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.net.*;
//<Applet code=Change1.class height=300 width=300 ></applet>
public class Change1 extends JApplet implements Runnable
{
JRadioButton man,woman;
ButtonGroup bg;
Label label_userID1 = new Label("用户名: ");
Label label_userPassword1 = new Label("密码: ");
JTextField text_userID1 = new JTextField(15);
JPasswordField text_userPassword1 = new JPasswordField(15);
JButton button_ok1 = new JButton("登入");
JButton button_register1 = new JButton("注册");
Label label_userID2 = new Label("用户名:");
Label label_userPassword2 = new Label("输入密码:");
Label label_userPasswordAgain2 = new Label("确认密码:");
Label label_userName2 = new Label("真实姓名:");
Label label_userSex2 = new Label("选择性别:");
Label label_userEmail2 = new Label("E-Mail:");
Label label_userAddress2 = new Label("联系地址:");
Label label_userZipcode2 = new Label("邮政编码:");
Label label_userCreditCardType2 = new Label("信用卡类型:");
Label label_userCreditCardNo2 = new Label("信用卡号码:");
Label label_userPersonCardType2 = new Label("证件类型:");
Label label_userPersonCardNo2 = new Label("证件号码:");
JTextField text_userID2 = new JTextField(15);
JPasswordField text_userPassword2 = new JPasswordField(15);
JPasswordField text_userPasswordAgain2 = new JPasswordField(15);
JTextField text_userName2 = new JTextField(15);
JTextField text_userEmail2 = new JTextField(15);
JTextField text_userAddress2 = new JTextField(15);
JTextField text_userZipcode2 = new JTextField(15);
JTextField text_userCreditCardNo2 = new JTextField(15);
JTextField text_userPersonCardNo2 = new JTextField(15);
JButton button_ok2 = new JButton("注册");
JButton button_register2 = new JButton("清空");
JComboBox combo_userCreditCardType,combo_userPersonCardType;
GridBagLayout gbl = new GridBagLayout();
GridBagConstraints gbc = new GridBagConstraints(); Thread datimeThread; Date date; GregorianCalendar calendar; String strDate,strTime,strStatus;
String personSex,userPersonType2;
JTabbedPane tabbedPane;
JPanel toy,orders,accept,register;
接下面的:
public void init()
{
tabbedPane=new JTabbedPane();
accept=new JPanel();
tabbedPane.addTab("登录",null,accept);
register=new JPanel();
tabbedPane.addTab("注册",null,register);
toy=new JPanel();
tabbedPane.addTab("玩具展区",null,toy,"快来看看哦!");
orders=new JPanel();
tabbedPane.addTab("订购",null,orders,"快来买东西噢!");
getContentPane().add(tabbedPane);
tabbedPane.setEnabledAt(1,false);
tabbedPane.setEnabledAt(3,false);
accept.setLayout(gbl);
gbc.gridx=0;
gbc.gridy=0;
gbc.anchor=GridBagConstraints.WEST;
gbl.setConstraints(label_userID1,gbc);
accept.add(label_userID1);
gbc.gridx=1;
gbc.gridy=0;
gbc.anchor=GridBagConstraints.WEST;
gbl.setConstraints(text_userID1,gbc);
accept.add(text_userID1);
gbc.gridx=0;
gbc.gridy=1;
gbc.anchor=GridBagConstraints.WEST;
gbl.setConstraints(label_userPassword1,gbc);
accept.add(label_userPassword1);
gbc.gridx=1;
gbc.gridy=1;
gbc.anchor=GridBagConstraints.WEST;
gbl.setConstraints(text_userPassword1,gbc);
accept.add(text_userPassword1);
gbc.gridx=1;
gbc.gridy=2;
gbc.anchor=GridBagConstraints.CENTER;
gbl.setConstraints(button_ok1,gbc);
accept.add(button_ok1);
validateAction validateButton3 = new validateAction();
button_ok1.addActionListener(validateButton3);
gbc.gridx=1;
gbc.gridy=2;
gbc.anchor=GridBagConstraints.EAST;
gbl.setConstraints(button_register1,gbc);
accept.add(button_register1);
validateAction validateButton4 = new validateAction();
button_register1.addActionListener(validateButton4);
register.setVisible(false);
register.setLayout(gbl);
bg=new ButtonGroup();
man=new JRadioButton("男");
woman=new JRadioButton("女");
bg.add(man);
bg.add(woman);
String CreditCardType[] = {"Master Card","Visa Card"};
String PersonCardType[]={"身份证","学生证","军人证"};
combo_userCreditCardType = new JComboBox(CreditCardType);
combo_userPersonCardType = new JComboBox(PersonCardType);
gbc.gridx=0;
gbc.gridy=0;
gbc.anchor=GridBagConstraints.WEST;
gbl.setConstraints(label_userID2,gbc);
register.add(label_userID2);
gbc.gridx=1;
gbc.gridy=0;
gbl.setConstraints(text_userID2,gbc);
register.add(text_userID2);
gbc.gridx=0;
gbc.gridy=1;
gbc.anchor=GridBagConstraints.WEST;
gbl.setConstraints(label_userPassword2,gbc);
register.add(label_userPassword2);
gbc.gridx=1;
gbc.gridy=1;
gbl.setConstraints(text_userPassword2,gbc);
register.add(text_userPassword2);
gbc.gridx=0;
gbc.gridy=2;
gbc.anchor=GridBagConstraints.WEST;
gbl.setConstraints(label_userPasswordAgain2,gbc);
register.add(label_userPasswordAgain2);
gbc.gridx=1;
gbc.gridy=2;
gbl.setConstraints(text_userPasswordAgain2,gbc);
register.add(text_userPasswordAgain2);
gbc.gridx=0;
gbc.gridy=3;
gbc.anchor=GridBagConstraints.WEST;
gbl.setConstraints(label_userName2,gbc);
register.add(label_userName2);
gbc.gridx=1;
gbc.gridy=3;
gbl.setConstraints(text_userName2,gbc);
register.add(text_userName2);
gbc.gridx=0;
gbc.gridy=4;
gbc.anchor=GridBagConstraints.WEST;
gbl.setConstraints(label_userSex2,gbc);
register.add(label_userSex2);
gbc.gridx=1;
gbc.gridy=4;
gbc.anchor=GridBagConstraints.WEST;
gbl.setConstraints(man,gbc);
register.add(man);
gbc.gridx=1;
gbc.gridy=4;
gbc.anchor=GridBagConstraints.CENTER;
gbl.setConstraints(woman,gbc);
register.add(woman);
gbc.gridx=0;
gbc.gridy=5;
gbc.anchor=GridBagConstraints.WEST;
gbl.setConstraints(label_userPersonCardType2,gbc);
register.add(label_userPersonCardType2);
gbc.gridx=1;
gbc.gridy=5;
gbc.anchor=GridBagConstraints.WEST;
gbl.setConstraints(combo_userPersonCardType,gbc);
register.add(combo_userPersonCardType);
gbc.gridx=0;
gbc.gridy=6;
gbc.anchor=GridBagConstraints.WEST;
gbl.setConstraints(label_userPersonCardNo2,gbc);
register.add(label_userPersonCardNo2);
gbc.gridx=1;
gbc.gridy=6;
gbl.setConstraints(text_userPersonCardNo2,gbc);
register.add(text_userPersonCardNo2);
gbc.gridx=0;
gbc.gridy=7;
gbc.anchor=GridBagConstraints.WEST;
gbl.setConstraints(label_userEmail2,gbc);
register.add(label_userEmail2);
gbc.gridx=1;
gbc.gridy=7;
gbl.setConstraints(text_userEmail2,gbc);
register.add(text_userEmail2);
gbc.gridx=0;
gbc.gridy=8;
gbc.anchor=GridBagConstraints.WEST;
gbl.setConstraints(label_userAddress2,gbc);
register.add(label_userAddress2);
gbc.gridx=1;
gbc.gridy=8;
gbl.setConstraints(text_userAddress2,gbc);
register.add(text_userAddress2);
gbc.gridx=0;
gbc.gridy=9;
gbc.anchor=GridBagConstraints.WEST;
gbl.setConstraints(label_userZipcode2,gbc);
register.add(label_userZipcode2);
gbc.gridx=1;
gbc.gridy=9;
gbl.setConstraints(text_userZipcode2,gbc);
register.add(text_userZipcode2);
gbc.gridx=0;
gbc.gridy=10;
gbc.anchor=GridBagConstraints.WEST;
gbl.setConstraints(label_userCreditCardType2,gbc);
register.add(label_userCreditCardType2);
gbc.gridx=1;
gbc.gridy=10;
gbc.anchor=GridBagConstraints.WEST;
gbl.setConstraints(combo_userCreditCardType,gbc);
register.add(combo_userCreditCardType);
gbc.gridx=0;
gbc.gridy=11;
gbc.anchor=GridBagConstraints.WEST;
gbl.setConstraints(label_userCreditCardNo2,gbc);
register.add(label_userCreditCardNo2);
gbc.gridx=1;
gbc.gridy=11;
gbl.setConstraints(text_userCreditCardNo2,gbc);
register.add(text_userCreditCardNo2);
gbc.gridx=1;
gbc.gridy=12;
gbc.anchor=GridBagConstraints.CENTER;
gbl.setConstraints(button_ok2,gbc);
register.add(button_ok2);
validateAction validateButton1 = new validateAction();
button_ok2.addActionListener(validateButton1);
gbc.gridx=1;
gbc.gridy=12;
gbc.anchor=GridBagConstraints.EAST;
gbl.setConstraints(button_register2,gbc);
register.add(button_register2);
validateAction validateButton2 = new validateAction();
button_register2.addActionListener(validateButton2);
datimeThread = new Thread(this);
datimeThread.start();
}
register.setLayout(gbl);
这里是不是应该新new一个GridBagLayout和GridBagConstraints呢?