当前位置: 技术问答>java相关
最后一点分全给了吧,我是JAVA初学者,这些问题弄得我不想学下去了,搞不定我就不学了?,没人答我天天问
来源: 互联网 发布时间:2015-03-12
本文导语: 问题一: 关于的JList的事件处理,为何执行两次,下面是我的MainFrame.java(主窗体) package bbr;//封装成bbr包 /*++导入必要的包++*/ import java.util.*; import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*;...
问题一:
关于的JList的事件处理,为何执行两次,下面是我的MainFrame.java(主窗体)
package bbr;//封装成bbr包
/*++导入必要的包++*/
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.sql.*;
/*--导入必要的包--*/
public class Mainframe extends JFrame implements ListSelectionListener //实现JList的事件接口(ListSelectionListener)
{
/*++初始化界面元素++*/
private mydialogue dlg;//对话框类实例
JButton btnAdd = new JButton("添加");
JButton btnMod = new JButton("修改");
JButton btnDel = new JButton("删除");
JButton btnSel = new JButton("查询");
JCheckBox cbxmeiqi=new JCheckBox("煤气");
JCheckBox cbxmeibiao=new JCheckBox("有无煤气卡表");
JCheckBox cbxnuanqi=new JCheckBox("暖气");
JCheckBox cbxdian=new JCheckBox("用电");
JCheckBox cbxdianbiao=new JCheckBox("有无电卡表");
JCheckBox cbxxsd=new JCheckBox("下水道");
JCheckBox cbxzls=new JCheckBox("自来水");
JCheckBox cbxshuibiao=new JCheckBox("有无水卡表");
JCheckBox cbxwsj=new JCheckBox("卫生间");
JLabel lbljiequ=new JLabel("街区",JLabel.CENTER);
JLabel lbldonghao=new JLabel("栋号",JLabel.CENTER);
JLabel lblfanghao=new JLabel("房号",JLabel.CENTER);
JLabel lblxiaoqu=new JLabel("小区",JLabel.CENTER);
JLabel lblzjbz=new JLabel("租金标准",JLabel.CENTER);
JLabel lbljzmj=new JLabel("建筑面积 ",JLabel.CENTER);
JLabel lblsymj=new JLabel("使用面积",JLabel.CENTER);
JLabel lblfwzk=new JLabel("房屋状况",JLabel.CENTER);
JLabel lblsyzt=new JLabel("使用状态",JLabel.CENTER);
JLabel lblylrfwzl=new JLabel("已录入房屋资料",JLabel.CENTER);
JComboBox comjiequ=new JComboBox(new String[] {"-请选择-"});
JComboBox comdonghao=new JComboBox(new String[] {"-请选择-"});
JComboBox comxiaoqu=new JComboBox(new String[] {"-请选择-"});
JComboBox comfwzk=new JComboBox(new String[] {"良好","需改造"});
JComboBox comsyzt=new JComboBox(new String[] {"闲置","出租","出售"});
JTextField txtfanghao=new JTextField();
JTextField txtzjbz=new JTextField("",5);
JTextField txtjzmj=new JTextField("",5);
JTextField txtsymj=new JTextField("",5);
JList lstylrfwzl;
/*--初始化界面元素--*/
Dboperation db_jiequ=new Dboperation("jdbc:odbc:javadsn","weiming","158200");//建立数据库联接Bean的实例对象
/**Construct the frame*/
public Mainframe() {
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
/**Component initialization*/
private void jbInit() throws Exception
{
/*++建立菜单++*/
JMenuBar mbar = new JMenuBar();//1、建立菜单条对象JMenuBar实例mbar
setJMenuBar(mbar); //2、用MainFrame的setJMenuBar()方法加入此mbar
JMenu operation=new JMenu("分级管理");//3、建立两顶极菜单operation,systool
JMenu systool=new JMenu("系统管理"); //3、建立两顶极菜单operation,systool
JMenuItem fwzl=new JMenuItem("房屋资料");//4、建立顶极菜单的子菜单
JMenuItem fwcz=new JMenuItem("房屋出租");//4、建立顶极菜单的子菜单
JMenuItem fzsq=new JMenuItem("房屋收取");//4、建立顶极菜单的子菜单
JMenuItem wxdj=new JMenuItem("维修登记");//4、建立顶极菜单的子菜单
JMenuItem wxjl=new JMenuItem("维修记录");//4、建立顶极菜单的子菜单
JMenuItem dytj=new JMenuItem("打印统计");//4、建立顶极菜单的子菜单
JMenuItem lbwh=new JMenuItem("列表维护");//4、建立顶极菜单的子菜单
JMenuItem about=new JMenuItem("关于...");//4、建立顶极菜单的子菜单
JMenuItem exit=new JMenuItem("退出系统");//4、建立顶极菜单的子菜单
about.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
about_actionPerformed(e);
}
});//5、为需摇事件反映的菜单添加事件监听器与处理方法
exit.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
exit_actionPerformed(e);
}
});//5、为需摇事件反映的菜单添加事件监听器与处理方法
operation.add(fwzl);//6、把子菜单添加到所属顶极菜单
operation.add(fwcz);//6、把子菜单添加到所属顶极菜单
operation.add(fzsq);//6、把子菜单添加到所属顶极菜单
operation.add(wxdj);//6、把子菜单添加到所属顶极菜单
operation.add(wxjl);//6、把子菜单添加到所属顶极菜单
operation.add(dytj);//6、把子菜单添加到所属顶极菜单
operation.addSeparator();//6、把子菜单添加到所属顶极菜单
operation.add(lbwh);//6、把子菜单添加到所属顶极菜单
systool.add(about);//6、把子菜单添加到所属顶极菜单
systool.add(exit);//6、把子菜单添加到所属顶极菜单
mbar.add(operation);//7、把顶极菜单添加到菜单条
mbar.add(systool); //7、把顶极菜单添加到菜单条
/*++建立菜单++*/
/*++设置的一些MainFrame属性++*/
this.setSize(new Dimension(600, 300));//大下
this.setTitle("商业用房出租管理"); //标题
this.setResizable(false); //Resizable
/*--设置的一些MainFrame属性--*/
JList_Initial(); //调用JList_Initial()方法初始化JList
comjiequ_Initial(); //调用comjiequ_Initial()方法初始化comjiequ
comxiaoqu_Initial();//调用comxiaoqu_Initial()方法初始化comxiaoqu
/*++为界面元素指定布局++*/
Container contentPane=getContentPane();
GridBagLayout gbl = new GridBagLayout();
contentPane.setLayout(gbl);
GridBagConstraints gbc = new GridBagConstraints();
gbc.fill = GridBagConstraints.VERTICAL;
gbc.weightx = 100;
gbc.weighty = 100;
add(lbljiequ, gbc, 0, 0, 1, 1);
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.weightx = 100;
gbc.weighty = 100;
add(comjiequ, gbc, 1, 0, 1, 1);
gbc.fill = GridBagConstraints.VERTICAL;
gbc.weightx = 100;
gbc.weighty = 100;
add(lbldonghao, gbc, 2, 0, 1, 1);
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.weightx = 100;
gbc.weighty = 100;
add(comdonghao, gbc, 3, 0, 1, 1);
gbc.fill = GridBagConstraints.VERTICAL;
gbc.weightx = 100;
gbc.weighty = 100;
add(lblfanghao, gbc, 4, 0, 1, 1);
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.weightx = 100;
gbc.weighty = 100;
add(txtfanghao, gbc, 5, 0, 1, 1);
gbc.fill = GridBagConstraints.VERTICAL;
gbc.weightx = 100;
gbc.weighty = 100;
add(lblxiaoqu, gbc, 6, 0, 1, 1);
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.weightx = 100;
gbc.weighty = 100;
add(comxiaoqu, gbc, 7, 0, 1, 1);
gbc.fill = GridBagConstraints.VERTICAL;
gbc.weightx = 100;
gbc.weighty = 100;
add(lblylrfwzl, gbc, 8, 0, 2, 1);
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.weightx = 100;
gbc.weighty = 100;
add(lblzjbz, gbc, 0, 1, 1, 1);
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.weightx = 100;
gbc.weighty = 100;
add(txtzjbz, gbc, 1, 1, 2, 1);
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.weightx = 100;
gbc.weighty = 100;
add(lbljzmj, gbc, 3, 1, 1, 1);
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.weightx = 100;
gbc.weighty = 100;
add(txtjzmj, gbc, 4, 1, 2, 1);
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.weightx = 100;
gbc.weighty = 100;
add(lblsymj, gbc, 6, 1, 1, 1);
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.weightx = 100;
gbc.weighty = 100;
add(txtsymj, gbc, 7, 1, 1, 1);
gbc.fill = GridBagConstraints.BOTH;
gbc.weightx = 100;
gbc.weighty = 100;
add(lstylrfwzl, gbc, 8, 1, 2, 6);
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.weightx = 100;
gbc.weighty = 100;
add(lblfwzk, gbc, 0, 2, 2, 1);
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.weightx = 100;
gbc.weighty = 100;
add(comfwzk, gbc, 2, 2, 2, 1);
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.weightx = 100;
gbc.weighty = 100;
add(lblsyzt, gbc, 4, 2, 2, 1);
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.weightx = 100;
gbc.weighty = 100;
add(comsyzt, gbc, 6, 2, 2, 1);
gbc.fill = GridBagConstraints.VERTICAL;
gbc.weightx = 100;
gbc.weighty = 100;
add(cbxmeiqi, gbc, 0, 3, 3, 1);
gbc.fill = GridBagConstraints.VERTICAL;
gbc.weightx = 100;
gbc.weighty = 100;
add(cbxmeibiao, gbc, 3, 3, 3, 1);
gbc.fill = GridBagConstraints.VERTICAL;
gbc.weightx = 100;
gbc.weighty = 100;
add(cbxnuanqi, gbc, 6, 3, 2, 1);
gbc.fill = GridBagConstraints.VERTICAL;
gbc.weightx = 100;
gbc.weighty = 100;
add(cbxdian, gbc, 0, 4, 3, 1);
gbc.fill = GridBagConstraints.VERTICAL;
gbc.weightx = 100;
gbc.weighty = 100;
add(cbxdianbiao, gbc, 3, 4, 3, 1);
gbc.fill = GridBagConstraints.VERTICAL;
gbc.weightx = 100;
gbc.weighty = 100;
add(cbxxsd, gbc, 6, 4, 2, 1);
gbc.fill = GridBagConstraints.VERTICAL;
gbc.weightx = 100;
gbc.weighty = 100;
add(cbxzls, gbc, 0, 5, 3, 1);
gbc.fill = GridBagConstraints.VERTICAL;
gbc.weightx = 100;
gbc.weighty = 100;
add(cbxshuibiao, gbc, 3, 5, 3, 1);
gbc.fill = GridBagConstraints.VERTICAL;
gbc.weightx = 100;
gbc.weighty = 100;
add(cbxwsj, gbc, 6, 5, 2, 1);
gbc.fill = GridBagConstraints.NONE;
gbc.weightx = 100;
gbc.weighty = 100;
add(btnAdd, gbc, 0, 6, 2, 1);
gbc.fill = GridBagConstraints.NONE;
gbc.weightx = 100;
gbc.weighty = 100;
add(btnMod, gbc, 2, 6, 2, 1);
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.weightx = 100;
gbc.weighty = 100;
add(btnDel, gbc, 4, 6, 2, 1);
gbc.fill = GridBagConstraints.NONE;
gbc.weightx = 100;
gbc.weighty = 100;
add(btnSel, gbc, 6, 6, 2, 1);
/*--为界面元素指定布局--*/
/*++为btnAdd添加事件处理方法++*/
btnAdd.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
btnAdd_actionPerformed(e);
}
});
/*--为btnAdd添加事件处理方法--*/
lstylrfwzl.addListSelectionListener(this);///*++为JList添加事件处理方法++*/
/*++为comjiequ添加事件处理方法++*/
comjiequ.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
comjiequ_actionPerformed(e);
}
});
/*--为comjiequ添加事件处理方法--*/
}
/*++添加界面元素到指定布局++*/
public void add(Component c, GridBagConstraints gbc, int x, int y, int w, int h)
{ gbc.gridx = x;
gbc.gridy = y;
gbc.gridwidth = w;
gbc.gridheight = h;
getContentPane().add(c, gbc);
}
/*--添加界面元素到指定布局--*/
/*++菜单项about的处理事件++*/
void about_actionPerformed(ActionEvent evt)
{
if (dlg==null) dlg=new mydialogue(this,"nolove",true);
dlg.show();
}
/*--菜单项about的处理事件--*/
/*++菜单项exit的处理事件++*/
void exit_actionPerformed(ActionEvent evt)
{
System.exit(0);
}
/*--菜单项exit的处理事件--*/
/*++btnAdd的处理事件++*/
void btnAdd_actionPerformed(ActionEvent evt)
{
String sql="";
sql="insert into weiming.酒钢商业用房基本资料库(街区,栋号,房号,小区,租金标准,建筑面积,使用面积,房屋状况,使用状态,煤气,有无煤气IC表,用电,有无电IC表,自来水,有无水IC表,暖气,下水道,卫生间,住宅编号) values(";
sql=sql + "'" + (String)comjiequ.getSelectedItem() + "',";
sql=sql + "'" + (String)comdonghao.getSelectedItem() + "',";
sql=sql + "'" + txtfanghao.getText() + "',";
sql=sql + "'" + (String)comxiaoqu.getSelectedItem() + "',";
sql=sql + "'" + txtzjbz.getText() + "',";
sql=sql + "'" + txtjzmj.getText() + "',";
sql=sql + "'" + txtsymj.getText() + "',";
sql=sql + "'" + (String)comfwzk.getSelectedItem() + "',";
sql=sql + "'" + (String)comsyzt.getSelectedItem() + "',";
String meiqiValue=cbxmeiqi.isSelected()? "有" : "没有";
String zlsValue=cbxzls.isSelected()? "有" : "没有";
String meibiaoValue=cbxmeibiao.isSelected()? "有" : "没有";
String dianValue=cbxdian.isSelected()? "有" : "没有";
String dianbiaoValue=cbxdianbiao.isSelected()? "有" : "没有";
String nuanqiValue=cbxnuanqi.isSelected()? "有" : "没有";
String shuibiaoValue=cbxshuibiao.isSelected()? "有" : "没有";
String wsjValue=cbxwsj.isSelected()? "有" : "没有";
String xsdValue=cbxxsd.isSelected()? "有" : "没有";
sql=sql + "'" + meiqiValue + "',";
sql=sql + "'" + meibiaoValue + "',";
sql=sql + "'" + dianValue + "',";
sql=sql + "'" + dianbiaoValue + "',";
sql=sql + "'" + zlsValue + "',";
sql=sql + "'" + shuibiaoValue + "',";
sql=sql + "'" + nuanqiValue + "',";
sql=sql + "'" + xsdValue + "',";
sql=sql + "'" + wsjValue + "',";
sql=sql + "商业房.nextval" + ")";
try
{
db_jiequ.execUpdate(sql);
}
catch(Exception ex)
{
System.out.println(ex.toString());
}
Vector vec=new Vector();
String itemList5="";
String itemList3="";
String itemList2="";
String itemList="";
//lstylrfwzl.removeAll();
try{
ResultSet yiluru=db_jiequ.rs_jiequ("SELECT * FROM WEIMING.酒钢商业用房基本资料库 order by 街区,栋号,房号");
while (yiluru.next())
{
itemList2=yiluru.getString(2);
itemList3=yiluru.getString(3);
itemList5=yiluru.getString(5);
itemList=itemList5 + itemList3 + "栋" + itemList2 +"号";
vec.addElement(itemList);
}
lstylrfwzl.setListData(vec);
}
catch(Exception e)
{
System.out.println(itemList);
}
InitFrame();
}
/*--btnAdd的处理事件--*/
/*++comjiequ的事件处理++*/
void comjiequ_actionPerformed(ActionEvent evt)
{
comdonghao.removeAllItems();
ResultSet donghao=db_jiequ.rs_jiequ("SELECT 栋号 FROM WEIMING.酒钢商业用房栋号维护表 WHERE 街区名='" + (String)comjiequ.getSelectedItem() +"'");
try
{
while (donghao.next())
{
comdonghao.addItem(donghao.getString(1));
}
}
catch(Exception ex)
{
System.out.println(ex.toString());
}
}
/*--comjiequ的事件处理--*/
/*++添加记录后使界面元素还原成初始值++*/
private void InitFrame()
{
txtzjbz.setText("");
txtfanghao.setText("");
txtsymj.setText("");
txtjzmj.setText("");
cbxdian.setSelected(false);
cbxdianbiao.setSelected(false);
cbxmeibiao.setSelected(false);
cbxmeiqi.setSelected(false);
cbxnuanqi.setSelected(false);
cbxshuibiao.setSelected(false);
cbxwsj.setSelected(false);
cbxxsd.setSelected(false);
cbxzls.setSelected(false);
comdonghao.setSelectedIndex(0);
comfwzk.setSelectedIndex(0);
comxiaoqu.setSelectedIndex(0);
comjiequ.setSelectedIndex(0);
comsyzt.setSelectedIndex(0);
}
/*--添加记录后使界面元素还原成初始值--*/
/*++JList的事件处理程序++*/
public void valueChanged(ListSelectionEvent evt)
{
String selList=(String)lstylrfwzl.getSelectedValue();
int selList_jiequ_i=selList.indexOf("街区");
int selList_donghao_i=selList.indexOf("栋");
int selList_fanghao_i=selList.indexOf("号");
String selList_jiequ=selList.substring(0,selList_jiequ_i + 2);
String selList_donghao=selList.substring(selList_jiequ_i + 2,selList_donghao_i);
String selList_fanghao=selList.substring(selList_donghao_i + 1,selList_fanghao_i);
String sql11="select * from weiming.酒钢商业用房基本资料库 where 街区='" + selList_jiequ + "' and 栋号='" + selList_donghao + "' and 房号='" + selList_fanghao + "'";
System.out.println(sql11);
}
/*--JList的事件处理程序--*/
/*++初始化的JList中数据库数据++*/
public void JList_Initial()
{
/*++初始化的JList中数据库数据++*/
Vector vec=new Vector(); //jbInit()方法中定义的局部对象或变量,仅供jbInit()使用
String itemList5=""; //jbInit()方法中定义的局部对象或变量,仅供jbInit()使用
String itemList3=""; //jbInit()方法中定义的局部对象或变量,仅供jbInit()使用
String itemList2=""; //jbInit()方法中定义的局部对象或变量,仅供jbInit()使用
String itemList=""; //jbInit()方法中定义的局部对象或变量,仅供jbInit()使用
try
{
ResultSet yiluru=db_jiequ.rs_jiequ("SELECT * FROM WEIMING.酒钢商业用房基本资料库 order by 街区,栋号,房号");
while (yiluru.next())
{
itemList2=yiluru.getString(2);
itemList3=yiluru.getString(3);
itemList5=yiluru.getString(5);
itemList=itemList5 + itemList3 + "栋" + itemList2 +"号";
vec.addElement(itemList);
}
lstylrfwzl=new JList(vec);
}
catch(Exception e)
{
System.out.println(itemList);
}
}
/*--初始化的JList中数据库数据--*/
/*++初始化的comjiequ中数据库数据++*/
public void comjiequ_Initial()
{
ResultSet jiequ=db_jiequ.rs_jiequ("SELECT 街区名称 FROM WEIMING.街区表 order by 街区名称");
try
{
while (jiequ.next())
{
comjiequ.addItem(jiequ.getString(1));
}
}
catch (Exception ex)
{
System.out.println(ex.toString());
}
}
/*--初始化的comjiequ中数据库数据--*/
/*++初始化的comxiaoqu中数据库数据++*/
public void comxiaoqu_Initial()
{
ResultSet xiaoqu=db_jiequ.rs_jiequ("SELECT 小区名称 FROM WEIMING.小区表 order by 小区名称");
try
{
while (xiaoqu.next())
{
comxiaoqu.addItem(xiaoqu.getString(1));
}
}
catch(Exception ex)
{
System.out.println(ex.toString());
}
}
/*--初始化的comxiaoqu中数据库数据--*/
/**Overridden so we can exit when window is closed*/
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
System.exit(0);
}
}
}
为何valueChanged()中的输出语句每一次要输出两次,后来我干脆只写一句System.out.println("pp"),它也要输出两句,为何呢?
------------------------------------------------
问题2:
我看了《用jb5一步一步开发ejb》这篇文章,照着它说的做,为何编译后出现
"MyejbClient.java": Error #: 354 : incompatible types; found: bbr.MyejbRemote, required: bbr.Myejb at line 23, column 33
"bbr.jpx": C:BorlandAppServerbinjava2iiop -VBJclasspath "D:projectbbrclasses;C:BorlandAppServerlibasrt.jar;C:BorlandAppServerlibvbdev.jar;C:BorlandAppServerlibvbjdev.jar;C:BorlandAppServerlibvbjorb.jar;C:BorlandAppServerlibvbsec.jar;C:BorlandAppServerlibmigration.jar;C:BorlandAppServerlibbeandt.jar;C:BorlandAppServerlibdbswing.jar;C:BorlandAppServerlibdbtools.jar;C:BorlandAppServerlibdx.jar;C:BorlandAppServerlibhelp.jar;C:BorlandAppServerlibias.jar;C:BorlandAppServerlibinternetbeans.jar;C:BorlandAppServerlibjbcl.jar;C:BorlandAppServerlibjcert.jar;C:BorlandAppServerlibjds.jar;C:BorlandAppServerlibjdsremote.jar;C:BorlandAppServerlibjdsserver.jar;C:BorlandAppServerlibjmclient.jar;C:BorlandAppServerlibjmserver.jar;C:BorlandAppServerlibjnet.jar;C:BorlandAppServerlibjsse.jar;C:BorlandAppServerlibnavigator.jar;C:BorlandAppServerlibsqltools.jar;C:BorlandAppServerlibtomcat3jasper.jar;C:BorlandAppServerlibtomcat3jaxp.jar;C:BorlandAppServerlibtomcat3parser.jar;C:BorlandAppServerlibtomcat3servlet.jar;C:BorlandAppServerlibtomcat3webserver.jar;C:BorlandAppServerlibtomcat3.jar;C:BorlandAppServerlibvbejb.jar;C:BorlandAppServerlibvisiconnect.jar;C:jbuilder5jdk1.3demojfcJava2DJava2Demo.jar;C:jbuilder5jdk1.3jrelibi18n.jar;C:jbuilder5jdk1.3jrelibjaws.jar;C:jbuilder5jdk1.3jrelibrt.jar;C:jbuilder5jdk1.3jrelibsunrsasign.jar;C:jbuilder5jdk1.3libdt.jar;C:jbuilder5jdk1.3libtools.jar" -no_tie -no_comments -list_files -root_dir "D:projectbbrclassesGenerated Source" bbr.Myejb
"bbr.jpx": java2iiop did not generate stubs for Myejb.java
请教
关于的JList的事件处理,为何执行两次,下面是我的MainFrame.java(主窗体)
package bbr;//封装成bbr包
/*++导入必要的包++*/
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.sql.*;
/*--导入必要的包--*/
public class Mainframe extends JFrame implements ListSelectionListener //实现JList的事件接口(ListSelectionListener)
{
/*++初始化界面元素++*/
private mydialogue dlg;//对话框类实例
JButton btnAdd = new JButton("添加");
JButton btnMod = new JButton("修改");
JButton btnDel = new JButton("删除");
JButton btnSel = new JButton("查询");
JCheckBox cbxmeiqi=new JCheckBox("煤气");
JCheckBox cbxmeibiao=new JCheckBox("有无煤气卡表");
JCheckBox cbxnuanqi=new JCheckBox("暖气");
JCheckBox cbxdian=new JCheckBox("用电");
JCheckBox cbxdianbiao=new JCheckBox("有无电卡表");
JCheckBox cbxxsd=new JCheckBox("下水道");
JCheckBox cbxzls=new JCheckBox("自来水");
JCheckBox cbxshuibiao=new JCheckBox("有无水卡表");
JCheckBox cbxwsj=new JCheckBox("卫生间");
JLabel lbljiequ=new JLabel("街区",JLabel.CENTER);
JLabel lbldonghao=new JLabel("栋号",JLabel.CENTER);
JLabel lblfanghao=new JLabel("房号",JLabel.CENTER);
JLabel lblxiaoqu=new JLabel("小区",JLabel.CENTER);
JLabel lblzjbz=new JLabel("租金标准",JLabel.CENTER);
JLabel lbljzmj=new JLabel("建筑面积 ",JLabel.CENTER);
JLabel lblsymj=new JLabel("使用面积",JLabel.CENTER);
JLabel lblfwzk=new JLabel("房屋状况",JLabel.CENTER);
JLabel lblsyzt=new JLabel("使用状态",JLabel.CENTER);
JLabel lblylrfwzl=new JLabel("已录入房屋资料",JLabel.CENTER);
JComboBox comjiequ=new JComboBox(new String[] {"-请选择-"});
JComboBox comdonghao=new JComboBox(new String[] {"-请选择-"});
JComboBox comxiaoqu=new JComboBox(new String[] {"-请选择-"});
JComboBox comfwzk=new JComboBox(new String[] {"良好","需改造"});
JComboBox comsyzt=new JComboBox(new String[] {"闲置","出租","出售"});
JTextField txtfanghao=new JTextField();
JTextField txtzjbz=new JTextField("",5);
JTextField txtjzmj=new JTextField("",5);
JTextField txtsymj=new JTextField("",5);
JList lstylrfwzl;
/*--初始化界面元素--*/
Dboperation db_jiequ=new Dboperation("jdbc:odbc:javadsn","weiming","158200");//建立数据库联接Bean的实例对象
/**Construct the frame*/
public Mainframe() {
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
/**Component initialization*/
private void jbInit() throws Exception
{
/*++建立菜单++*/
JMenuBar mbar = new JMenuBar();//1、建立菜单条对象JMenuBar实例mbar
setJMenuBar(mbar); //2、用MainFrame的setJMenuBar()方法加入此mbar
JMenu operation=new JMenu("分级管理");//3、建立两顶极菜单operation,systool
JMenu systool=new JMenu("系统管理"); //3、建立两顶极菜单operation,systool
JMenuItem fwzl=new JMenuItem("房屋资料");//4、建立顶极菜单的子菜单
JMenuItem fwcz=new JMenuItem("房屋出租");//4、建立顶极菜单的子菜单
JMenuItem fzsq=new JMenuItem("房屋收取");//4、建立顶极菜单的子菜单
JMenuItem wxdj=new JMenuItem("维修登记");//4、建立顶极菜单的子菜单
JMenuItem wxjl=new JMenuItem("维修记录");//4、建立顶极菜单的子菜单
JMenuItem dytj=new JMenuItem("打印统计");//4、建立顶极菜单的子菜单
JMenuItem lbwh=new JMenuItem("列表维护");//4、建立顶极菜单的子菜单
JMenuItem about=new JMenuItem("关于...");//4、建立顶极菜单的子菜单
JMenuItem exit=new JMenuItem("退出系统");//4、建立顶极菜单的子菜单
about.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
about_actionPerformed(e);
}
});//5、为需摇事件反映的菜单添加事件监听器与处理方法
exit.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
exit_actionPerformed(e);
}
});//5、为需摇事件反映的菜单添加事件监听器与处理方法
operation.add(fwzl);//6、把子菜单添加到所属顶极菜单
operation.add(fwcz);//6、把子菜单添加到所属顶极菜单
operation.add(fzsq);//6、把子菜单添加到所属顶极菜单
operation.add(wxdj);//6、把子菜单添加到所属顶极菜单
operation.add(wxjl);//6、把子菜单添加到所属顶极菜单
operation.add(dytj);//6、把子菜单添加到所属顶极菜单
operation.addSeparator();//6、把子菜单添加到所属顶极菜单
operation.add(lbwh);//6、把子菜单添加到所属顶极菜单
systool.add(about);//6、把子菜单添加到所属顶极菜单
systool.add(exit);//6、把子菜单添加到所属顶极菜单
mbar.add(operation);//7、把顶极菜单添加到菜单条
mbar.add(systool); //7、把顶极菜单添加到菜单条
/*++建立菜单++*/
/*++设置的一些MainFrame属性++*/
this.setSize(new Dimension(600, 300));//大下
this.setTitle("商业用房出租管理"); //标题
this.setResizable(false); //Resizable
/*--设置的一些MainFrame属性--*/
JList_Initial(); //调用JList_Initial()方法初始化JList
comjiequ_Initial(); //调用comjiequ_Initial()方法初始化comjiequ
comxiaoqu_Initial();//调用comxiaoqu_Initial()方法初始化comxiaoqu
/*++为界面元素指定布局++*/
Container contentPane=getContentPane();
GridBagLayout gbl = new GridBagLayout();
contentPane.setLayout(gbl);
GridBagConstraints gbc = new GridBagConstraints();
gbc.fill = GridBagConstraints.VERTICAL;
gbc.weightx = 100;
gbc.weighty = 100;
add(lbljiequ, gbc, 0, 0, 1, 1);
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.weightx = 100;
gbc.weighty = 100;
add(comjiequ, gbc, 1, 0, 1, 1);
gbc.fill = GridBagConstraints.VERTICAL;
gbc.weightx = 100;
gbc.weighty = 100;
add(lbldonghao, gbc, 2, 0, 1, 1);
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.weightx = 100;
gbc.weighty = 100;
add(comdonghao, gbc, 3, 0, 1, 1);
gbc.fill = GridBagConstraints.VERTICAL;
gbc.weightx = 100;
gbc.weighty = 100;
add(lblfanghao, gbc, 4, 0, 1, 1);
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.weightx = 100;
gbc.weighty = 100;
add(txtfanghao, gbc, 5, 0, 1, 1);
gbc.fill = GridBagConstraints.VERTICAL;
gbc.weightx = 100;
gbc.weighty = 100;
add(lblxiaoqu, gbc, 6, 0, 1, 1);
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.weightx = 100;
gbc.weighty = 100;
add(comxiaoqu, gbc, 7, 0, 1, 1);
gbc.fill = GridBagConstraints.VERTICAL;
gbc.weightx = 100;
gbc.weighty = 100;
add(lblylrfwzl, gbc, 8, 0, 2, 1);
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.weightx = 100;
gbc.weighty = 100;
add(lblzjbz, gbc, 0, 1, 1, 1);
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.weightx = 100;
gbc.weighty = 100;
add(txtzjbz, gbc, 1, 1, 2, 1);
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.weightx = 100;
gbc.weighty = 100;
add(lbljzmj, gbc, 3, 1, 1, 1);
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.weightx = 100;
gbc.weighty = 100;
add(txtjzmj, gbc, 4, 1, 2, 1);
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.weightx = 100;
gbc.weighty = 100;
add(lblsymj, gbc, 6, 1, 1, 1);
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.weightx = 100;
gbc.weighty = 100;
add(txtsymj, gbc, 7, 1, 1, 1);
gbc.fill = GridBagConstraints.BOTH;
gbc.weightx = 100;
gbc.weighty = 100;
add(lstylrfwzl, gbc, 8, 1, 2, 6);
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.weightx = 100;
gbc.weighty = 100;
add(lblfwzk, gbc, 0, 2, 2, 1);
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.weightx = 100;
gbc.weighty = 100;
add(comfwzk, gbc, 2, 2, 2, 1);
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.weightx = 100;
gbc.weighty = 100;
add(lblsyzt, gbc, 4, 2, 2, 1);
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.weightx = 100;
gbc.weighty = 100;
add(comsyzt, gbc, 6, 2, 2, 1);
gbc.fill = GridBagConstraints.VERTICAL;
gbc.weightx = 100;
gbc.weighty = 100;
add(cbxmeiqi, gbc, 0, 3, 3, 1);
gbc.fill = GridBagConstraints.VERTICAL;
gbc.weightx = 100;
gbc.weighty = 100;
add(cbxmeibiao, gbc, 3, 3, 3, 1);
gbc.fill = GridBagConstraints.VERTICAL;
gbc.weightx = 100;
gbc.weighty = 100;
add(cbxnuanqi, gbc, 6, 3, 2, 1);
gbc.fill = GridBagConstraints.VERTICAL;
gbc.weightx = 100;
gbc.weighty = 100;
add(cbxdian, gbc, 0, 4, 3, 1);
gbc.fill = GridBagConstraints.VERTICAL;
gbc.weightx = 100;
gbc.weighty = 100;
add(cbxdianbiao, gbc, 3, 4, 3, 1);
gbc.fill = GridBagConstraints.VERTICAL;
gbc.weightx = 100;
gbc.weighty = 100;
add(cbxxsd, gbc, 6, 4, 2, 1);
gbc.fill = GridBagConstraints.VERTICAL;
gbc.weightx = 100;
gbc.weighty = 100;
add(cbxzls, gbc, 0, 5, 3, 1);
gbc.fill = GridBagConstraints.VERTICAL;
gbc.weightx = 100;
gbc.weighty = 100;
add(cbxshuibiao, gbc, 3, 5, 3, 1);
gbc.fill = GridBagConstraints.VERTICAL;
gbc.weightx = 100;
gbc.weighty = 100;
add(cbxwsj, gbc, 6, 5, 2, 1);
gbc.fill = GridBagConstraints.NONE;
gbc.weightx = 100;
gbc.weighty = 100;
add(btnAdd, gbc, 0, 6, 2, 1);
gbc.fill = GridBagConstraints.NONE;
gbc.weightx = 100;
gbc.weighty = 100;
add(btnMod, gbc, 2, 6, 2, 1);
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.weightx = 100;
gbc.weighty = 100;
add(btnDel, gbc, 4, 6, 2, 1);
gbc.fill = GridBagConstraints.NONE;
gbc.weightx = 100;
gbc.weighty = 100;
add(btnSel, gbc, 6, 6, 2, 1);
/*--为界面元素指定布局--*/
/*++为btnAdd添加事件处理方法++*/
btnAdd.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
btnAdd_actionPerformed(e);
}
});
/*--为btnAdd添加事件处理方法--*/
lstylrfwzl.addListSelectionListener(this);///*++为JList添加事件处理方法++*/
/*++为comjiequ添加事件处理方法++*/
comjiequ.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
comjiequ_actionPerformed(e);
}
});
/*--为comjiequ添加事件处理方法--*/
}
/*++添加界面元素到指定布局++*/
public void add(Component c, GridBagConstraints gbc, int x, int y, int w, int h)
{ gbc.gridx = x;
gbc.gridy = y;
gbc.gridwidth = w;
gbc.gridheight = h;
getContentPane().add(c, gbc);
}
/*--添加界面元素到指定布局--*/
/*++菜单项about的处理事件++*/
void about_actionPerformed(ActionEvent evt)
{
if (dlg==null) dlg=new mydialogue(this,"nolove",true);
dlg.show();
}
/*--菜单项about的处理事件--*/
/*++菜单项exit的处理事件++*/
void exit_actionPerformed(ActionEvent evt)
{
System.exit(0);
}
/*--菜单项exit的处理事件--*/
/*++btnAdd的处理事件++*/
void btnAdd_actionPerformed(ActionEvent evt)
{
String sql="";
sql="insert into weiming.酒钢商业用房基本资料库(街区,栋号,房号,小区,租金标准,建筑面积,使用面积,房屋状况,使用状态,煤气,有无煤气IC表,用电,有无电IC表,自来水,有无水IC表,暖气,下水道,卫生间,住宅编号) values(";
sql=sql + "'" + (String)comjiequ.getSelectedItem() + "',";
sql=sql + "'" + (String)comdonghao.getSelectedItem() + "',";
sql=sql + "'" + txtfanghao.getText() + "',";
sql=sql + "'" + (String)comxiaoqu.getSelectedItem() + "',";
sql=sql + "'" + txtzjbz.getText() + "',";
sql=sql + "'" + txtjzmj.getText() + "',";
sql=sql + "'" + txtsymj.getText() + "',";
sql=sql + "'" + (String)comfwzk.getSelectedItem() + "',";
sql=sql + "'" + (String)comsyzt.getSelectedItem() + "',";
String meiqiValue=cbxmeiqi.isSelected()? "有" : "没有";
String zlsValue=cbxzls.isSelected()? "有" : "没有";
String meibiaoValue=cbxmeibiao.isSelected()? "有" : "没有";
String dianValue=cbxdian.isSelected()? "有" : "没有";
String dianbiaoValue=cbxdianbiao.isSelected()? "有" : "没有";
String nuanqiValue=cbxnuanqi.isSelected()? "有" : "没有";
String shuibiaoValue=cbxshuibiao.isSelected()? "有" : "没有";
String wsjValue=cbxwsj.isSelected()? "有" : "没有";
String xsdValue=cbxxsd.isSelected()? "有" : "没有";
sql=sql + "'" + meiqiValue + "',";
sql=sql + "'" + meibiaoValue + "',";
sql=sql + "'" + dianValue + "',";
sql=sql + "'" + dianbiaoValue + "',";
sql=sql + "'" + zlsValue + "',";
sql=sql + "'" + shuibiaoValue + "',";
sql=sql + "'" + nuanqiValue + "',";
sql=sql + "'" + xsdValue + "',";
sql=sql + "'" + wsjValue + "',";
sql=sql + "商业房.nextval" + ")";
try
{
db_jiequ.execUpdate(sql);
}
catch(Exception ex)
{
System.out.println(ex.toString());
}
Vector vec=new Vector();
String itemList5="";
String itemList3="";
String itemList2="";
String itemList="";
//lstylrfwzl.removeAll();
try{
ResultSet yiluru=db_jiequ.rs_jiequ("SELECT * FROM WEIMING.酒钢商业用房基本资料库 order by 街区,栋号,房号");
while (yiluru.next())
{
itemList2=yiluru.getString(2);
itemList3=yiluru.getString(3);
itemList5=yiluru.getString(5);
itemList=itemList5 + itemList3 + "栋" + itemList2 +"号";
vec.addElement(itemList);
}
lstylrfwzl.setListData(vec);
}
catch(Exception e)
{
System.out.println(itemList);
}
InitFrame();
}
/*--btnAdd的处理事件--*/
/*++comjiequ的事件处理++*/
void comjiequ_actionPerformed(ActionEvent evt)
{
comdonghao.removeAllItems();
ResultSet donghao=db_jiequ.rs_jiequ("SELECT 栋号 FROM WEIMING.酒钢商业用房栋号维护表 WHERE 街区名='" + (String)comjiequ.getSelectedItem() +"'");
try
{
while (donghao.next())
{
comdonghao.addItem(donghao.getString(1));
}
}
catch(Exception ex)
{
System.out.println(ex.toString());
}
}
/*--comjiequ的事件处理--*/
/*++添加记录后使界面元素还原成初始值++*/
private void InitFrame()
{
txtzjbz.setText("");
txtfanghao.setText("");
txtsymj.setText("");
txtjzmj.setText("");
cbxdian.setSelected(false);
cbxdianbiao.setSelected(false);
cbxmeibiao.setSelected(false);
cbxmeiqi.setSelected(false);
cbxnuanqi.setSelected(false);
cbxshuibiao.setSelected(false);
cbxwsj.setSelected(false);
cbxxsd.setSelected(false);
cbxzls.setSelected(false);
comdonghao.setSelectedIndex(0);
comfwzk.setSelectedIndex(0);
comxiaoqu.setSelectedIndex(0);
comjiequ.setSelectedIndex(0);
comsyzt.setSelectedIndex(0);
}
/*--添加记录后使界面元素还原成初始值--*/
/*++JList的事件处理程序++*/
public void valueChanged(ListSelectionEvent evt)
{
String selList=(String)lstylrfwzl.getSelectedValue();
int selList_jiequ_i=selList.indexOf("街区");
int selList_donghao_i=selList.indexOf("栋");
int selList_fanghao_i=selList.indexOf("号");
String selList_jiequ=selList.substring(0,selList_jiequ_i + 2);
String selList_donghao=selList.substring(selList_jiequ_i + 2,selList_donghao_i);
String selList_fanghao=selList.substring(selList_donghao_i + 1,selList_fanghao_i);
String sql11="select * from weiming.酒钢商业用房基本资料库 where 街区='" + selList_jiequ + "' and 栋号='" + selList_donghao + "' and 房号='" + selList_fanghao + "'";
System.out.println(sql11);
}
/*--JList的事件处理程序--*/
/*++初始化的JList中数据库数据++*/
public void JList_Initial()
{
/*++初始化的JList中数据库数据++*/
Vector vec=new Vector(); //jbInit()方法中定义的局部对象或变量,仅供jbInit()使用
String itemList5=""; //jbInit()方法中定义的局部对象或变量,仅供jbInit()使用
String itemList3=""; //jbInit()方法中定义的局部对象或变量,仅供jbInit()使用
String itemList2=""; //jbInit()方法中定义的局部对象或变量,仅供jbInit()使用
String itemList=""; //jbInit()方法中定义的局部对象或变量,仅供jbInit()使用
try
{
ResultSet yiluru=db_jiequ.rs_jiequ("SELECT * FROM WEIMING.酒钢商业用房基本资料库 order by 街区,栋号,房号");
while (yiluru.next())
{
itemList2=yiluru.getString(2);
itemList3=yiluru.getString(3);
itemList5=yiluru.getString(5);
itemList=itemList5 + itemList3 + "栋" + itemList2 +"号";
vec.addElement(itemList);
}
lstylrfwzl=new JList(vec);
}
catch(Exception e)
{
System.out.println(itemList);
}
}
/*--初始化的JList中数据库数据--*/
/*++初始化的comjiequ中数据库数据++*/
public void comjiequ_Initial()
{
ResultSet jiequ=db_jiequ.rs_jiequ("SELECT 街区名称 FROM WEIMING.街区表 order by 街区名称");
try
{
while (jiequ.next())
{
comjiequ.addItem(jiequ.getString(1));
}
}
catch (Exception ex)
{
System.out.println(ex.toString());
}
}
/*--初始化的comjiequ中数据库数据--*/
/*++初始化的comxiaoqu中数据库数据++*/
public void comxiaoqu_Initial()
{
ResultSet xiaoqu=db_jiequ.rs_jiequ("SELECT 小区名称 FROM WEIMING.小区表 order by 小区名称");
try
{
while (xiaoqu.next())
{
comxiaoqu.addItem(xiaoqu.getString(1));
}
}
catch(Exception ex)
{
System.out.println(ex.toString());
}
}
/*--初始化的comxiaoqu中数据库数据--*/
/**Overridden so we can exit when window is closed*/
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
System.exit(0);
}
}
}
为何valueChanged()中的输出语句每一次要输出两次,后来我干脆只写一句System.out.println("pp"),它也要输出两句,为何呢?
------------------------------------------------
问题2:
我看了《用jb5一步一步开发ejb》这篇文章,照着它说的做,为何编译后出现
"MyejbClient.java": Error #: 354 : incompatible types; found: bbr.MyejbRemote, required: bbr.Myejb at line 23, column 33
"bbr.jpx": C:BorlandAppServerbinjava2iiop -VBJclasspath "D:projectbbrclasses;C:BorlandAppServerlibasrt.jar;C:BorlandAppServerlibvbdev.jar;C:BorlandAppServerlibvbjdev.jar;C:BorlandAppServerlibvbjorb.jar;C:BorlandAppServerlibvbsec.jar;C:BorlandAppServerlibmigration.jar;C:BorlandAppServerlibbeandt.jar;C:BorlandAppServerlibdbswing.jar;C:BorlandAppServerlibdbtools.jar;C:BorlandAppServerlibdx.jar;C:BorlandAppServerlibhelp.jar;C:BorlandAppServerlibias.jar;C:BorlandAppServerlibinternetbeans.jar;C:BorlandAppServerlibjbcl.jar;C:BorlandAppServerlibjcert.jar;C:BorlandAppServerlibjds.jar;C:BorlandAppServerlibjdsremote.jar;C:BorlandAppServerlibjdsserver.jar;C:BorlandAppServerlibjmclient.jar;C:BorlandAppServerlibjmserver.jar;C:BorlandAppServerlibjnet.jar;C:BorlandAppServerlibjsse.jar;C:BorlandAppServerlibnavigator.jar;C:BorlandAppServerlibsqltools.jar;C:BorlandAppServerlibtomcat3jasper.jar;C:BorlandAppServerlibtomcat3jaxp.jar;C:BorlandAppServerlibtomcat3parser.jar;C:BorlandAppServerlibtomcat3servlet.jar;C:BorlandAppServerlibtomcat3webserver.jar;C:BorlandAppServerlibtomcat3.jar;C:BorlandAppServerlibvbejb.jar;C:BorlandAppServerlibvisiconnect.jar;C:jbuilder5jdk1.3demojfcJava2DJava2Demo.jar;C:jbuilder5jdk1.3jrelibi18n.jar;C:jbuilder5jdk1.3jrelibjaws.jar;C:jbuilder5jdk1.3jrelibrt.jar;C:jbuilder5jdk1.3jrelibsunrsasign.jar;C:jbuilder5jdk1.3libdt.jar;C:jbuilder5jdk1.3libtools.jar" -no_tie -no_comments -list_files -root_dir "D:projectbbrclassesGenerated Source" bbr.Myejb
"bbr.jpx": java2iiop did not generate stubs for Myejb.java
请教
|
JAVA初学者???
若是,为什么挑比较简单的练练,要注意循序渐进!!!
若是,为什么挑比较简单的练练,要注意循序渐进!!!
|
好象是说类型不匹配
|
建议使用ActionListener
ListSelectionListener 在选择和取消选择时都会激发
ListSelectionListener 在选择和取消选择时都会激发
|
摘自 java tutorial:
Many list selection events can be generated from a single user action such as a mouse click. The getValueIsAdjusting method returns true if the user is still manipulating the selection. This particular program is interested only in the final result of the user's action, so the valueChanged method updates the image only if getValueIsAdjusting returns false.
解决办法:
public void valueChanged(ListSelectionEvent e) {
if (e.getValueIsAdjusting())
return;
......
......
......
}
Many list selection events can be generated from a single user action such as a mouse click. The getValueIsAdjusting method returns true if the user is still manipulating the selection. This particular program is interested only in the final result of the user's action, so the valueChanged method updates the image only if getValueIsAdjusting returns false.
解决办法:
public void valueChanged(ListSelectionEvent e) {
if (e.getValueIsAdjusting())
return;
......
......
......
}
|
要自己先琢磨,然后问问题的关键,动不动就拿来源程序,哪有那么多时间?
|
1.似乎你不是JAVA初学者
2.gflei(gflei@sina.com)说得有道理
3.怎么会遇到一点挫折就轻言放弃?
4.这么长的代码别人也要调好一阵!
2.gflei(gflei@sina.com)说得有道理
3.怎么会遇到一点挫折就轻言放弃?
4.这么长的代码别人也要调好一阵!
|
新年快乐!!