M
mycwcgr
Unregistered / Unconfirmed
GUEST, unregistred user!
为什么在JBuild9.0中,Jlist控件的valueChanged事件会执行两次,这是JBuild9.0的BUg吗?
下面的程式,当我单点Jlist中的一个item时,void jList1_valueChanged(ListSelectionEvent e) 过程执行了两次,
这是JBuild9.0的BUg吗?
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
public class Frame1 extends JFrame {
JPanel contentPane;
BorderLayout borderLayout1 = new BorderLayout();
JList jList1 = new JList();
//Construct the frame
public Frame1() {
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
private void jbInit() throws Exception {
contentPane = (JPanel) this.getContentPane();
contentPane.setLayout(borderLayout1);
this.setSize(new Dimension(400, 300));
this.setTitle("Frame Title");
String[] aa={"1","2","3"};
jList1.setListData(aa);
jList1.addListSelectionListener(new Frame1_jList1_listSelectionAdapter(this));
contentPane.add(jList1, BorderLayout.CENTER);
}
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
System.exit(0);
}
}
void jList1_valueChanged(ListSelectionEvent e) {
System.out.println("This value will be displayed two time: "+ this.jList1.getSelectedValue() );
}
}
class Frame1_jList1_listSelectionAdapter implements javax.swing.event.ListSelectionListener {
Frame1 adaptee;
Frame1_jList1_listSelectionAdapter(Frame1 adaptee) {
this.adaptee = adaptee;
}
public void valueChanged(ListSelectionEvent e) {
adaptee.jList1_valueChanged(e);
}
}
下面的程式,当我单点Jlist中的一个item时,void jList1_valueChanged(ListSelectionEvent e) 过程执行了两次,
这是JBuild9.0的BUg吗?
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
public class Frame1 extends JFrame {
JPanel contentPane;
BorderLayout borderLayout1 = new BorderLayout();
JList jList1 = new JList();
//Construct the frame
public Frame1() {
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
private void jbInit() throws Exception {
contentPane = (JPanel) this.getContentPane();
contentPane.setLayout(borderLayout1);
this.setSize(new Dimension(400, 300));
this.setTitle("Frame Title");
String[] aa={"1","2","3"};
jList1.setListData(aa);
jList1.addListSelectionListener(new Frame1_jList1_listSelectionAdapter(this));
contentPane.add(jList1, BorderLayout.CENTER);
}
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
System.exit(0);
}
}
void jList1_valueChanged(ListSelectionEvent e) {
System.out.println("This value will be displayed two time: "+ this.jList1.getSelectedValue() );
}
}
class Frame1_jList1_listSelectionAdapter implements javax.swing.event.ListSelectionListener {
Frame1 adaptee;
Frame1_jList1_listSelectionAdapter(Frame1 adaptee) {
this.adaptee = adaptee;
}
public void valueChanged(ListSelectionEvent e) {
adaptee.jList1_valueChanged(e);
}
}