当前位置: 代码迷 >> Java相关 >> JScrollPane滚条的问题[请求帮助]
  详细解决方案

JScrollPane滚条的问题[请求帮助]

热度:419   发布时间:2005-12-27 15:45:00.0
JScrollPane滚条的问题[请求帮助]

闲着没事,网上找了许多资料自学JAVA不久,想尝试自己做个什么项目.但是碰到个小小的困难,就是面板布局的时候,其中的表单超过了显示的范围,想在其中加JScrollPane的滚条效果.我显示用GridBagConstraints()布局,但是表单的位置设置不好(是水平不佳吧..)..后来用setBounds(X,X,X,X)定义表单位置,却没有了滚条的效果.又找不到解决的方法.想寻求下帮助,谢谢!(另外..有个较笨的错误,首页上有个txt表单,不知怎么去掉..知道是哪写错了漏了帮个忙,谢谢~THANKS!)

代码如下:

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.Container.*;
import java.sql.*;

public class Sysobj extends JApplet
{
//参数定义
int n,m;
int id;

//窗口参数
JPanel paneltop;
JPanel panelbottom;
JPanel panelEnter;
JPanel panelEnter1;
JPanel panelLogin;
JPanel panelShow;

//登陆页表单参数
JLabel UserID;
JLabel PassWord;
JLabel Login;
JLabel GetPassWord;
JTextField TextUserID;
JPasswordField TextPassWord;
JButton Enter;

//登陆后显示的表单参数
JButton lbttop1;
JButton lbttop2;
JButton lbttop3;
JButton lbttop4;
JButton lbttop5;
JButton lbttop6;

//1设置
JButton jbtset1;
JButton jbtset2;
//2基本信息
JButton jbtmsg1;
JButton jbtmsg2;
JButton jbtmsg3;
//3海运出口
JButton jbtso1;
JButton jbtso2;
JButton jbtso3;
JButton jbtso4;
JButton jbtso5;
JButton jbtso6;
JButton jbtso7;
JComboBox comboselect;
JTextField textselect;
JButton jbtguolv1;
JLabel lbview1;
JComboBox comboyear;
JComboBox combomonth;
JLabel lbseao1;
JLabel lbseao2;
JLabel lbseao3;
JLabel lbseao4;
JLabel lbseao5;
JLabel lbseao6;
JLabel lbseao7;
JLabel lbseao8;
JLabel lbseao9;
JLabel lbseao10;
JLabel lbseao11;
JLabel lbseao12;
JLabel lbseao13;
JLabel lbseao14;
JLabel lbseao15;
JLabel lbseao16;
JLabel lbseao17;
JLabel lbseao18;
JScrollPane jsp;

//4海运进口
JButton jbtsi1;
JButton jbtsi2;
JButton jbtsi3;
JButton jbtsi4;
JButton jbtsi5;
JButton jbtsi6;
//5财务管理
JButton jbtcw1;
JButton jbtcw2;
//5-1出口
JButton jbtcwo1;
JButton jbtcwo2;
JButton jbtcwo3;
JButton jbtcwo4;
JButton jbtcwo5;
//5-2进口
JButton jbtcwi1;
JButton jbtcwi2;
JButton jbtcwi3;
//6发票管理
JButton jbtfp1;
JButton jbtfp2;

JLabel Speace;

//颜色参数定义
Color a1=new Color(128,219,239);
Color a2=new Color(109,181,255);
//数据库连接参数定义
Connection con;
ResultSet result;
Statement stat;

public void init()
{
getContentPane().setLayout(null);
getContentPane().setBackground(a1);
getAppletContext().showStatus("只是试验而已");

/*try
{
//数据库连接
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:mysql","sa","1111");
stat=con.createStatement();
}
//数据库连接错误返回信息
catch(Exception exception)
{
System.out.print("Error encountered while entering date in the database: " + exception);
}*/

//加载显示窗口

//主页顶上的图标
paneltop();

//登陆主页界面
panelEnter();

//登陆后的主窗口
panelShow();
}
//顶上图表窗口
public void paneltop()
{
JLabel top;
JLabel miqi1;

paneltop = new JPanel();
getContentPane().add(paneltop);
paneltop.setBackground(a1);
paneltop.setLayout(null);
paneltop.setBounds(0,0,800,80);

ImageIcon miqipic1 = new ImageIcon("");
miqi1 = new JLabel(miqipic1);
miqi1.setBounds(0,8,800,80);
paneltop.add(miqi1);

}

//登陆界面
public void panelEnter()
{
a1=new Color(128,219,239);
panelEnter = new JPanel();
panelEnter1 = new JPanel();
getContentPane().add(panelEnter);
panelEnter.setLayout(null);
panelEnter.setBounds(0,80,800,440);
panelEnter.setBackground(a1);
panelEnter.add(panelEnter1);
panelEnter1.setBounds(0,80,800,300);


panelEnter1.setBackground(a1);
GridBagLayout gl;
GridBagConstraints gbc;

gl = new GridBagLayout();
gbc = new GridBagConstraints();

panelEnter1.setLayout(gl);

UserID = new JLabel("用户名:");
gbc.anchor = GridBagConstraints.CENTER;
gbc.gridx = 1;
gbc.gridy = 1;
gl.setConstraints(UserID,gbc);
panelEnter1.add(UserID);
UserID.setForeground(Color.blue);

TextUserID = new JTextField(8);
gbc.anchor = GridBagConstraints.CENTER;
gbc.gridx = 2;
gbc.gridy = 1;
gl.setConstraints(TextUserID,gbc);
panelEnter1.add(TextUserID);

PassWord = new JLabel("密 码:");
gbc.anchor = GridBagConstraints.CENTER;
gbc.gridx = 1;
gbc.gridy = 2;
gl.setConstraints(PassWord,gbc);
panelEnter1.add(PassWord);
PassWord.setForeground(Color.blue);

TextPassWord = new JPasswordField(8);
gbc.anchor = GridBagConstraints.CENTER;
gbc.gridx = 2;
gbc.gridy = 2;
gl.setConstraints(TextPassWord,gbc);
panelEnter1.add(TextPassWord);

GetPassWord = new JLabel("找回密码");
gbc.anchor = GridBagConstraints.CENTER;
gbc.gridx = 3;
gbc.gridy = 1;
gl.setConstraints(GetPassWord,gbc);
panelEnter1.add(GetPassWord);
GetPassWord.setForeground(Color.blue);

Enter = new JButton("登陆");
gbc.anchor = GridBagConstraints.WEST;
gbc.gridx = 3;
gbc.gridy = 2;
gl.setConstraints(Enter,gbc);
panelEnter1.add(Enter);
Enter.setBackground(Color.green);

validateAction validateButton = new validateAction();
Enter.addActionListener(validateButton);
}

//登陆事件
class validateAction implements ActionListener
{
public void actionPerformed(ActionEvent evt)
{
Object obj = evt.getSource();

//按登陆按键所触发的事件
if (obj == Enter)
{/*
String UserID = TextUserID.getText();
if (UserID.length() == 0)
{
JOptionPane.showMessageDialog(null,"用户名不能为空!",
"Error message",JOptionPane.WARNING_MESSAGE);
return;
}

char[] passWord = TextPassWord.getPassword();
if (passWord.length == 0)
{
JOptionPane.showMessageDialog(null,"密码不能为空!",
"Error message",JOptionPane.WARNING_MESSAGE);
return;
}

try
{
int ok = 0;
//登陆数据查询验证
Statement stat=con.createStatement();
ResultSet result = stat.executeQuery("Select * from cus");

while (result.next())
{
if (TextUserID.getText().equals(result.getString(1).trim()))//验证第1列数据(用户名)
{
if (String.valueOf(TextPassWord.getPassword()).equals(result.getString(2).trim()))//验证第2列数据(密码)
{
ok = 1;
break;
}
else
{
JOptionPane.showMessageDialog(null,"您输入的密码不正确!",
"Error message",JOptionPane.WARNING_MESSAGE);
stat.close();
return;
}
}
else
continue;
}
if(ok != 1)
{
JOptionPane.showMessageDialog(null,"您输入的用户名不存在!",
"Error message",JOptionPane.WARNING_MESSAGE);
stat.close();
return;
}
stat.close();
}
//访问数据库错误的返回信息
catch(Exception exception)
{
JOptionPane.showMessageDialog(null,"Error 访问数据库错误: " + exception,
"Error message",JOptionPane.WARNING_MESSAGE);
}*/
panelEnter.setVisible(false);
remove(panelEnter);
panelEnter1.setVisible(false);
remove(panelEnter1);
panelShow.setVisible(true);
jsp.setVisible(true);
getContentPane().add(jsp);
}
}
}

搜索更多相关的解决方案: 请求  JScrollPane  

----------------解决方案--------------------------------------------------------
接下来第2部分:


//登陆成功界面
public void panelShow()
{
GridBagLayout gl;
GridBagConstraints gbc;

panelShow = new JPanel();
getContentPane().add(panelShow);
panelShow.setLayout(null);
panelShow.setBounds(10,80,750,500);
jsp = new JScrollPane(panelShow);
jsp.setBounds(new Rectangle(10,80,750,500));
this.getContentPane().add(jsp,null);

/*gl = new GridBagLayout();
gbc = new GridBagConstraints();
panelShow.setLayout(gl);*/

lbttop1 = new JButton("系统设置");
panelShow.add(lbttop1);
lbttop1.setBounds(20,10,100,20);

lbttop2 = new JButton("基本信息");
panelShow.add(lbttop2);
lbttop2.setBounds(120,10,100,20);

lbttop3 = new JButton("海运出口");
panelShow.add(lbttop3);
lbttop3.setBounds(220,10,100,20);

lbttop4 = new JButton("海运进口");
panelShow.add(lbttop4);
lbttop4.setBounds(320,10,100,20);

lbttop5 = new JButton("财务管理");
panelShow.add(lbttop5);
lbttop5.setBounds(420,10,100,20);

lbttop6 = new JButton("发票管理");
panelShow.add(lbttop6);
lbttop6.setBounds(520,10,100,20);

//1系统
jbtset1 = new JButton("设置");
panelShow.add(jbtset1);
jbtset1.setBounds(20,30,100,20);

jbtset2 = new JButton("登出");
panelShow.add(jbtset2);
jbtset2.setBounds(20,50,100,20);

//2基本信息

jbtmsg1 = new JButton("客户");
panelShow.add(jbtmsg1);
jbtmsg1.setBounds(120,30,100,20);

jbtmsg2 = new JButton("集装箱");
panelShow.add(jbtmsg2);
jbtmsg2.setBounds(120,50,100,20);

jbtmsg3 = new JButton("用户信息");
panelShow.add(jbtmsg3);
jbtmsg3.setBounds(120,70,100,20);

//3海运出口
jbtso1 = new JButton("出口登记表录入");
panelShow.add(jbtso1);
jbtso1.setBounds(220,30,150,20);

jbtso2 = new JButton("核销单清单");
panelShow.add(jbtso2);
jbtso2.setBounds(220,50,150,20);

jbtso3 = new JButton("箱量统计");
panelShow.add(jbtso3);
jbtso3.setBounds(220,70,150,20);

jbtso4 = new JButton("业务员统计");
panelShow.add(jbtso4);
jbtso4.setBounds(220,90,150,20);

jbtso5 = new JButton("未付款客户名单");
panelShow.add(jbtso5);
jbtso5.setBounds(220,110,150,20);

jbtso6 = new JButton("修改记录");
panelShow.add(jbtso6);
jbtso6.setBounds(220,130,150,20);

jbtso7 = new JButton("打印格式");
panelShow.add(jbtso7);
jbtso7.setBounds(220,150,150,20);

//4海运进口
jbtsi1 = new JButton("进口登记表录入");
panelShow.add(jbtsi1);
jbtsi1.setBounds(320,30,150,20);

jbtsi2 = new JButton("报进报关单清单");
panelShow.add(jbtsi2);
jbtsi2.setBounds(320,50,150,20);

jbtsi3 = new JButton("报出报关单清单");
panelShow.add(jbtsi3);
jbtsi3.setBounds(320,70,150,20);

jbtsi4 = new JButton("箱量统计");
panelShow.add(jbtsi4);
jbtsi4.setBounds(320,90,150,20);

jbtsi5 = new JButton("业务员统计");
panelShow.add(jbtsi5);
jbtsi5.setBounds(320,110,150,20);

jbtsi6 = new JButton("未付款客户名单");
panelShow.add(jbtsi6);
jbtsi6.setBounds(320,130,150,20);

//5财务管理
jbtcw1 = new JButton("进口业务→");
panelShow.add(jbtcw1);
jbtcw1.setBounds(420,30,100,20);

jbtcw2 = new JButton("出口业务→");
panelShow.add(jbtcw2);
jbtcw2.setBounds(420,50,100,20);

//5-1出口
jbtcwo1 = new JButton("收款清单");
panelShow.add(jbtcwo1);
jbtcwo1.setBounds(520,30,150,20);

jbtcwo2 = new JButton("付款清单");
panelShow.add(jbtcwo2);
jbtcwo2.setBounds(520,50,150,20);

jbtcwo3 = new JButton("利润分析表");
panelShow.add(jbtcwo3);
jbtcwo3.setBounds(520,70,150,20);

jbtcwo4 = new JButton("收款汇总清单");
panelShow.add(jbtcwo4);
jbtcwo4.setBounds(520,90,150,20);

jbtcwo5 = new JButton("付款汇总清单");
panelShow.add(jbtcwo5);
jbtcwo5.setBounds(520,110,150,20);

//5-2进口
jbtcwi1 = new JButton("收款清单");
panelShow.add(jbtcwi1);
jbtcwi1.setBounds(520,50,150,20);

jbtcwi2 = new JButton("付款清单");
panelShow.add(jbtcwi2);
jbtcwi2.setBounds(520,70,150,20);

jbtcwi3 = new JButton("利润分析表");
panelShow.add(jbtcwi3);
jbtcwi3.setBounds(520,90,150,20);

//6发票管理
jbtfp1 = new JButton("发票管理");
panelShow.add(jbtfp1);
jbtfp1.setBounds(520,30,100,20);

jbtfp2 = new JButton("打印格式");
panelShow.add(jbtfp2);
jbtfp2.setBounds(520,50,100,20);

//隐藏菜单按键
jbtset1.setVisible(false);
jbtset2.setVisible(false);

jbtmsg1.setVisible(false);
jbtmsg2.setVisible(false);
jbtmsg3.setVisible(false);

jbtso1.setVisible(false);
jbtso2.setVisible(false);
jbtso3.setVisible(false);
jbtso4.setVisible(false);
jbtso5.setVisible(false);
jbtso6.setVisible(false);
jbtso7.setVisible(false);

jbtsi1.setVisible(false);
jbtsi2.setVisible(false);
jbtsi3.setVisible(false);
jbtsi4.setVisible(false);
jbtsi5.setVisible(false);
jbtsi6.setVisible(false);

jbtcw1.setVisible(false);
jbtcw2.setVisible(false);

jbtcwo1.setVisible(false);
jbtcwo2.setVisible(false);
jbtcwo3.setVisible(false);
jbtcwo4.setVisible(false);
jbtcwo5.setVisible(false);

jbtcwi1.setVisible(false);
jbtcwi2.setVisible(false);
jbtcwi3.setVisible(false);

jbtfp1.setVisible(false);
jbtfp2.setVisible(false);

//1系统-设置

//2基本信息-客户
//2基本信息-集装箱
//2基本信息-用户信息

//3海运出口-出口登记表录入
String sel[] ={"登记号","客户","船公司","订舱编号","提单号","目的港","箱型","订舱公司","客户发票","付款方式(O)","付款方式(H)","船期","核销单号","手册号","交货地","用户","退手册日期","业务员"};
comboselect = new JComboBox(sel);
comboselect.setBounds(20,50,100,20);
comboselect.setSelectedIndex(0);
comboselect.setMaximumRowCount(6);
panelShow.add(comboselect);
comboselect.setEnabled(true);
comboselect.setBackground(a1);

textselect = new JTextField(18);
textselect.setBounds(120,50,220,20);
panelShow.add(textselect);

jbtguolv1 = new JButton("过滤");
jbtguolv1.setBounds(340,50,60,20);
panelShow.add(jbtguolv1);

lbview1 = new JLabel(" 显示");
lbview1.setBounds(410,50,100,20);
panelShow.add(lbview1);

String years[] ={"今年","2003年","2004年","2005年","2006年","2007年"};
comboyear = new JComboBox(years);
comboyear.setBounds(450,50,80,20);
comboyear.setSelectedIndex(0);
comboyear.setMaximumRowCount(6);
panelShow.add(comboyear);
comboyear.setEnabled(true);
comboyear.setBackground(a1);

String months[] ={"当月","1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"};
combomonth = new JComboBox(months);
combomonth.setBounds(530,50,80,20);
combomonth.setSelectedIndex(0);
combomonth.setMaximumRowCount(6);
panelShow.add(combomonth);
combomonth.setEnabled(true);
combomonth.setBackground(a1);

lbseao1 = new JLabel("登记号");
lbseao1.setBounds(120,70,80,20);
panelShow.add(lbseao1);

lbseao2 = new JLabel("船期");
lbseao2.setBounds(200,70,80,20);
panelShow.add(lbseao2);

lbseao3 = new JLabel("订舱编号");
lbseao3.setBounds(280,70,80,20);
panelShow.add(lbseao3);

lbseao4 = new JLabel("客户");
lbseao4.setBounds(360,70,50,20);
panelShow.add(lbseao4);

lbseao5 = new JLabel("船公司");
lbseao5.setBounds(410,70,50,20);
panelShow.add(lbseao5);

lbseao6 = new JLabel("客户发票号");
lbseao6.setBounds(460,70,100,20);
panelShow.add(lbseao6);

lbseao7 = new JLabel("订舱公司");
lbseao7.setBounds(560,70,80,20);
panelShow.add(lbseao7);

lbseao8 = new JLabel("目的港");
lbseao8.setBounds(640,70,100,20);
panelShow.add(lbseao8);

lbseao9 = new JLabel("交货地");
lbseao9.setBounds(740,70,100,20);
panelShow.add(lbseao9);

lbseao10 = new JLabel("提单号");
lbseao10.setBounds(840,70,100,20);
panelShow.add(lbseao10);

lbseao11 = new JLabel("陆运方式");
lbseao11.setBounds(840,70,100,20);
panelShow.add(lbseao11);

lbseao12 = new JLabel("箱型");
lbseao12.setBounds(840,70,100,20);
panelShow.add(lbseao12);

lbseao13 = new JLabel("核销单号");
lbseao13.setBounds(940,70,100,20);
panelShow.add(lbseao13);

lbseao14 = new JLabel("手册号");
lbseao14.setBounds(1040,70,80,20);
panelShow.add(lbseao14);

lbseao15 = new JLabel("退手册日期");
lbseao15.setBounds(1120,70,100,20);
panelShow.add(lbseao15);

//3海运出口-核销单清单
//3海运出口-箱量统计
//3海运出口-业务员统计
//3海运出口-未付款客户名单
//3海运出口-修改记录
//3海运出口-打印格式

//4海运进口-进口登记表录入
//4海运进口-报进报关单清单
//4海运进口-报出报关单清单
//4海运进口-箱量统计
//4海运进口-业务员统计
//4海运进口-未付款客户名单

//5财务管理-出口业务
//5-1收款清单
//5-2付款清单
//5-3利润分析表
//5-4收款汇总清单
//5-5付款汇总清单
//5财务管理-进口业务
//5-1收款清单
//5-2付款清单
//5-3利润分析表

//6发票管理-发票管理
//6发票管理-打印格式

//登陆后界面按键触发事件
validateAction3 validateButton3 = new validateAction3();
jbtset2.addActionListener(validateButton3);
lbttop1.addActionListener(validateButton3);
lbttop2.addActionListener(validateButton3);
lbttop3.addActionListener(validateButton3);
lbttop4.addActionListener(validateButton3);
lbttop5.addActionListener(validateButton3);
lbttop6.addActionListener(validateButton3);
jbtcw1.addActionListener(validateButton3);
jbtcw2.addActionListener(validateButton3);
panelShow.addMouseMotionListener(validateButton3);

}

----------------解决方案--------------------------------------------------------
第3部分....




//登陆成功后界面中的按键事件
class validateAction3 implements ActionListener,MouseMotionListener
{
public void actionPerformed(ActionEvent evt)
{
Object obj = evt.getSource();

if (obj == jbtset2)
{
panelShow.setVisible(false);
remove(panelShow);
jsp.setVisible(false);
remove(jsp);
getContentPane().add(panelEnter);
TextUserID.setText(null);
TextPassWord.setText(null);
Enter.setVisible(true);
}
if (obj == lbttop1)
{

jbtset1.setVisible(true);
jbtset2.setVisible(true);

jbtmsg1.setVisible(false);
jbtmsg2.setVisible(false);
jbtmsg3.setVisible(false);

jbtso1.setVisible(false);
jbtso2.setVisible(false);
jbtso3.setVisible(false);
jbtso4.setVisible(false);
jbtso5.setVisible(false);
jbtso6.setVisible(false);
jbtso7.setVisible(false);

jbtsi1.setVisible(false);
jbtsi2.setVisible(false);
jbtsi3.setVisible(false);
jbtsi4.setVisible(false);
jbtsi5.setVisible(false);
jbtsi6.setVisible(false);

jbtcw1.setVisible(false);
jbtcw2.setVisible(false);

jbtcwo1.setVisible(false);
jbtcwo2.setVisible(false);
jbtcwo3.setVisible(false);
jbtcwo4.setVisible(false);
jbtcwo5.setVisible(false);

jbtcwi1.setVisible(false);
jbtcwi2.setVisible(false);
jbtcwi3.setVisible(false);

jbtfp1.setVisible(false);
jbtfp2.setVisible(false);
}
if (obj == lbttop2)
{
jbtset1.setVisible(false);
jbtset2.setVisible(false);

jbtmsg1.setVisible(true);
jbtmsg2.setVisible(true);
jbtmsg3.setVisible(true);

jbtso1.setVisible(false);
jbtso2.setVisible(false);
jbtso3.setVisible(false);
jbtso4.setVisible(false);
jbtso5.setVisible(false);
jbtso6.setVisible(false);
jbtso7.setVisible(false);

jbtsi1.setVisible(false);
jbtsi2.setVisible(false);
jbtsi3.setVisible(false);
jbtsi4.setVisible(false);
jbtsi5.setVisible(false);
jbtsi6.setVisible(false);

jbtcw1.setVisible(false);
jbtcw2.setVisible(false);

jbtcwo1.setVisible(false);
jbtcwo2.setVisible(false);
jbtcwo3.setVisible(false);
jbtcwo4.setVisible(false);
jbtcwo5.setVisible(false);

jbtcwi1.setVisible(false);
jbtcwi2.setVisible(false);
jbtcwi3.setVisible(false);

jbtfp1.setVisible(false);
jbtfp2.setVisible(false);
}
if (obj == lbttop3)
{
jbtset1.setVisible(false);
jbtset2.setVisible(false);

jbtmsg1.setVisible(false);
jbtmsg2.setVisible(false);
jbtmsg3.setVisible(false);

jbtso1.setVisible(true);
jbtso2.setVisible(true);
jbtso3.setVisible(true);
jbtso4.setVisible(true);
jbtso5.setVisible(true);
jbtso6.setVisible(true);
jbtso7.setVisible(true);

jbtsi1.setVisible(false);
jbtsi2.setVisible(false);
jbtsi3.setVisible(false);
jbtsi4.setVisible(false);
jbtsi5.setVisible(false);
jbtsi6.setVisible(false);

jbtcw1.setVisible(false);
jbtcw2.setVisible(false);

jbtcwo1.setVisible(false);
jbtcwo2.setVisible(false);
jbtcwo3.setVisible(false);
jbtcwo4.setVisible(false);
jbtcwo5.setVisible(false);

jbtcwi1.setVisible(false);
jbtcwi2.setVisible(false);
jbtcwi3.setVisible(false);

jbtfp1.setVisible(false);
jbtfp2.setVisible(false);
}
if (obj == lbttop4)
{
jbtset1.setVisible(false);
jbtset2.setVisible(false);

jbtmsg1.setVisible(false);
jbtmsg2.setVisible(false);
jbtmsg3.setVisible(false);

jbtso1.setVisible(false);
jbtso2.setVisible(false);
jbtso3.setVisible(false);
jbtso4.setVisible(false);
jbtso5.setVisible(false);
jbtso6.setVisible(false);
jbtso7.setVisible(false);

jbtsi1.setVisible(true);
jbtsi2.setVisible(true);
jbtsi3.setVisible(true);
jbtsi4.setVisible(true);
jbtsi5.setVisible(true);
jbtsi6.setVisible(true);

jbtcw1.setVisible(false);
jbtcw2.setVisible(false);

jbtcwo1.setVisible(false);
jbtcwo2.setVisible(false);
jbtcwo3.setVisible(false);
jbtcwo4.setVisible(false);
jbtcwo5.setVisible(false);

jbtcwi1.setVisible(false);
jbtcwi2.setVisible(false);
jbtcwi3.setVisible(false);

jbtfp1.setVisible(false);
jbtfp2.setVisible(false);
}
if (obj == lbttop5)
{
jbtset1.setVisible(false);
jbtset2.setVisible(false);

jbtmsg1.setVisible(false);
jbtmsg2.setVisible(false);
jbtmsg3.setVisible(false);

jbtso1.setVisible(false);
jbtso2.setVisible(false);
jbtso3.setVisible(false);
jbtso4.setVisible(false);
jbtso5.setVisible(false);
jbtso6.setVisible(false);
jbtso7.setVisible(false);

jbtsi1.setVisible(false);
jbtsi2.setVisible(false);
jbtsi3.setVisible(false);
jbtsi4.setVisible(false);
jbtsi5.setVisible(false);
jbtsi6.setVisible(false);

jbtcw1.setVisible(true);
jbtcw2.setVisible(true);

jbtcwo1.setVisible(false);
jbtcwo2.setVisible(false);
jbtcwo3.setVisible(false);
jbtcwo4.setVisible(false);
jbtcwo5.setVisible(false);

jbtcwi1.setVisible(false);
jbtcwi2.setVisible(false);
jbtcwi3.setVisible(false);

jbtfp1.setVisible(false);
jbtfp2.setVisible(false);
}

if (obj == jbtcw1)
{
jbtset1.setVisible(false);
jbtset2.setVisible(false);

jbtmsg1.setVisible(false);
jbtmsg2.setVisible(false);
jbtmsg3.setVisible(false);

jbtso1.setVisible(false);
jbtso2.setVisible(false);
jbtso3.setVisible(false);
jbtso4.setVisible(false);
jbtso5.setVisible(false);
jbtso6.setVisible(false);
jbtso7.setVisible(false);

jbtsi1.setVisible(false);
jbtsi2.setVisible(false);
jbtsi3.setVisible(false);
jbtsi4.setVisible(false);
jbtsi5.setVisible(false);
jbtsi6.setVisible(false);

jbtcw1.setVisible(true);
jbtcw2.setVisible(true);

jbtcwo1.setVisible(true);
jbtcwo2.setVisible(true);
jbtcwo3.setVisible(true);
jbtcwo4.setVisible(true);
jbtcwo5.setVisible(true);

jbtcwi1.setVisible(false);
jbtcwi2.setVisible(false);
jbtcwi3.setVisible(false);

jbtfp1.setVisible(false);
jbtfp2.setVisible(false);
}

if (obj == jbtcw2)
{
jbtset1.setVisible(false);
jbtset2.setVisible(false);

jbtmsg1.setVisible(false);
jbtmsg2.setVisible(false);
jbtmsg3.setVisible(false);

jbtso1.setVisible(false);
jbtso2.setVisible(false);
jbtso3.setVisible(false);
jbtso4.setVisible(false);
jbtso5.setVisible(false);
jbtso6.setVisible(false);
jbtso7.setVisible(false);

jbtsi1.setVisible(false);
jbtsi2.setVisible(false);
jbtsi3.setVisible(false);
jbtsi4.setVisible(false);
jbtsi5.setVisible(false);
jbtsi6.setVisible(false);

jbtcw1.setVisible(true);
jbtcw2.setVisible(true);

jbtcwo1.setVisible(false);
jbtcwo2.setVisible(false);
jbtcwo3.setVisible(false);
jbtcwo4.setVisible(false);
jbtcwo5.setVisible(false);

jbtcwi1.setVisible(true);
jbtcwi2.setVisible(true);
jbtcwi3.setVisible(true);

jbtfp1.setVisible(false);
jbtfp2.setVisible(false);
}

if (obj == lbttop6)
{
jbtset1.setVisible(false);
jbtset2.setVisible(false);

jbtmsg1.setVisible(false);
jbtmsg2.setVisible(false);
jbtmsg3.setVisible(false);

jbtso1.setVisible(false);
jbtso2.setVisible(false);
jbtso3.setVisible(false);
jbtso4.setVisible(false);
jbtso5.setVisible(false);
jbtso6.setVisible(false);
jbtso7.setVisible(false);

jbtsi1.setVisible(false);
jbtsi2.setVisible(false);
jbtsi3.setVisible(false);
jbtsi4.setVisible(false);
jbtsi5.setVisible(false);
jbtsi6.setVisible(false);

jbtcw1.setVisible(false);
jbtcw2.setVisible(false);

jbtcwo1.setVisible(false);
jbtcwo2.setVisible(false);
jbtcwo3.setVisible(false);
jbtcwo4.setVisible(false);
jbtcwo5.setVisible(false);

jbtcwi1.setVisible(false);
jbtcwi2.setVisible(false);
jbtcwi3.setVisible(false);

jbtfp1.setVisible(true);
jbtfp2.setVisible(true);
}

}
public void mouseEntered(MouseEvent evt) {}
public void mouseExited(MouseEvent evt){}
public void mousePressed(MouseEvent e){}
public void mouseReleased(MouseEvent e){}

public void mouseMoved(MouseEvent e)
{
jbtset1.setVisible(false);
jbtset2.setVisible(false);

jbtmsg1.setVisible(false);
jbtmsg2.setVisible(false);
jbtmsg3.setVisible(false);

jbtso1.setVisible(false);
jbtso2.setVisible(false);
jbtso3.setVisible(false);
jbtso4.setVisible(false);
jbtso5.setVisible(false);
jbtso6.setVisible(false);
jbtso7.setVisible(false);

jbtsi1.setVisible(false);
jbtsi2.setVisible(false);
jbtsi3.setVisible(false);
jbtsi4.setVisible(false);
jbtsi5.setVisible(false);
jbtsi6.setVisible(false);

jbtcw1.setVisible(false);
jbtcw2.setVisible(false);

jbtcwo1.setVisible(false);
jbtcwo2.setVisible(false);
jbtcwo3.setVisible(false);
jbtcwo4.setVisible(false);
jbtcwo5.setVisible(false);

jbtcwi1.setVisible(false);
jbtcwi2.setVisible(false);
jbtcwi3.setVisible(false);

jbtfp1.setVisible(false);
jbtfp2.setVisible(false);

return;
}
//鼠标移动事件2(关闭按键)
public void mouseDragged(MouseEvent e)
{
jbtset1.setVisible(false);
jbtset2.setVisible(false);

jbtmsg1.setVisible(false);
jbtmsg2.setVisible(false);
jbtmsg3.setVisible(false);

jbtso1.setVisible(false);
jbtso2.setVisible(false);
jbtso3.setVisible(false);
jbtso4.setVisible(false);
jbtso5.setVisible(false);
jbtso6.setVisible(false);
jbtso7.setVisible(false);

jbtsi1.setVisible(false);
jbtsi2.setVisible(false);
jbtsi3.setVisible(false);
jbtsi4.setVisible(false);
jbtsi5.setVisible(false);
jbtsi6.setVisible(false);

jbtcw1.setVisible(false);
jbtcw2.setVisible(false);

jbtcwo1.setVisible(false);
jbtcwo2.setVisible(false);
jbtcwo3.setVisible(false);
jbtcwo4.setVisible(false);
jbtcwo5.setVisible(false);

jbtcwi1.setVisible(false);
jbtcwi2.setVisible(false);
jbtcwi3.setVisible(false);

jbtfp1.setVisible(false);
jbtfp2.setVisible(false);
return;
}
}
}

----------------解决方案--------------------------------------------------------
不是不般的长啊~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
----------------解决方案--------------------------------------------------------
还没打算写功能呢...
----------------解决方案--------------------------------------------------------

刚学的时候都很想自己写程序来测试自己学得怎么样了,这无可厚非,但首先你要多看看别人是怎么写程序的……我想对你的程序提一点意见……觉得有用的就记一下,觉得没用就当我放P吧……

1. 程序过长是显而易见的……为什么会造成的呢?因为过多的重复代码引起的……你肯定会想反驳我吧?这里面没一句是重复的!JPanel申明了lbseao1~lbseao18,你完全可以使用数组来做,其他的组件也一样.你的第三部分看看基本上就被setVisible覆盖了,如果使用数组的话可以使用一个方法或一个循环就可以解决一大段了

2. 按钮“系统设置”、“基本信息”等等,这些完全可以使用菜单栏来代替,根本不必写一大堆的setVisible

对于你的问题暂时还不知道是怎么回事……


----------------解决方案--------------------------------------------------------
老大就是老大!~恩 有水平啊
----------------解决方案--------------------------------------------------------

哦~明白了!嘿嘿,非常感谢您的建议!


----------------解决方案--------------------------------------------------------