当前位置: 技术问答>java相关
JList的疑问
来源: 互联网 发布时间:2015-03-25
本文导语: import java.awt.*; import javax.swing.*; import com.borland.jbcl.layout.*; import java.awt.event.*; /** * Title: * Description: * Copyright: Copyright (c) 2001 * Company: * @author * @version 1.0 */ public class seqchooser extends JDialog { ...
import java.awt.*;
import javax.swing.*;
import com.borland.jbcl.layout.*;
import java.awt.event.*;
/**
* Title:
* Description:
* Copyright: Copyright (c) 2001
* Company:
* @author
* @version 1.0
*/
public class seqchooser extends JDialog {
JPanel panel1 = new JPanel();
XYLayout xYLayout1 = new XYLayout();
JScrollPane jScrollPane1 = new JScrollPane();
JButton jButton1 = new JButton();
String choices[] = new String[6];
public JList jList1;
public int selection;
public ChoiceListener cListener = new ChoiceListener(); //line25col 41
public seqchooser(Frame frame, String title, boolean modal) {
super(frame, title, modal);
try {
jbInit();
pack();
}
catch(Exception ex) {
ex.printStackTrace();
}
}
public void show(){
jList1 = new JList(choices);
super.show();
}
public seqchooser() {
this(null, "", false);
}
void jbInit() throws Exception {
panel1.setLayout(xYLayout1);
jButton1.setText("OK");
jButton1.addActionListener(new seqchooser_jButton1_actionAdapter(this));
getContentPane().add(panel1);
panel1.add(jScrollPane1, new XYConstraints(52, 20, 161, 89));
panel1.add(jButton1, new XYConstraints(73, 130, -1, -1));
jScrollPane1.getViewport().add(jList1, null);
jList1.addListSelectionListener(cListener); //line 55, column 12
}
class ChoiceListener implements ListSelectionListener // line59col35
{
public void valueChanged(ListSelectionEvent e)
{
selection = jList1.getSelectedIndex();
}
}
void jButton1_actionPerformed(ActionEvent e) {
}
}
class seqchooser_jButton1_actionAdapter implements java.awt.event.ActionListener {
seqchooser adaptee;
seqchooser_jButton1_actionAdapter(seqchooser adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton1_actionPerformed(e);
}
}
编译后有下列错误,大侠能否帮我改一下:已在源程序中注明错处
error1:"seqchooser.java": Error #: 300 : class ListSelectionListener not found in class seqanalysis.seqchooser.ChoiceListener at line 59, column 35
error2:"seqchooser.java": Error #: 300 : constructor ChoiceListener() not found in class seqanalysis.seqchooser.ChoiceListener at line 25, column 41
error3:"seqchooser.java": Error #: 300 : method addListSelectionListener(seqanalysis.seqchooser.ChoiceListener) not found in class javax.swing.JList at line 55, column 12
import javax.swing.*;
import com.borland.jbcl.layout.*;
import java.awt.event.*;
/**
* Title:
* Description:
* Copyright: Copyright (c) 2001
* Company:
* @author
* @version 1.0
*/
public class seqchooser extends JDialog {
JPanel panel1 = new JPanel();
XYLayout xYLayout1 = new XYLayout();
JScrollPane jScrollPane1 = new JScrollPane();
JButton jButton1 = new JButton();
String choices[] = new String[6];
public JList jList1;
public int selection;
public ChoiceListener cListener = new ChoiceListener(); //line25col 41
public seqchooser(Frame frame, String title, boolean modal) {
super(frame, title, modal);
try {
jbInit();
pack();
}
catch(Exception ex) {
ex.printStackTrace();
}
}
public void show(){
jList1 = new JList(choices);
super.show();
}
public seqchooser() {
this(null, "", false);
}
void jbInit() throws Exception {
panel1.setLayout(xYLayout1);
jButton1.setText("OK");
jButton1.addActionListener(new seqchooser_jButton1_actionAdapter(this));
getContentPane().add(panel1);
panel1.add(jScrollPane1, new XYConstraints(52, 20, 161, 89));
panel1.add(jButton1, new XYConstraints(73, 130, -1, -1));
jScrollPane1.getViewport().add(jList1, null);
jList1.addListSelectionListener(cListener); //line 55, column 12
}
class ChoiceListener implements ListSelectionListener // line59col35
{
public void valueChanged(ListSelectionEvent e)
{
selection = jList1.getSelectedIndex();
}
}
void jButton1_actionPerformed(ActionEvent e) {
}
}
class seqchooser_jButton1_actionAdapter implements java.awt.event.ActionListener {
seqchooser adaptee;
seqchooser_jButton1_actionAdapter(seqchooser adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton1_actionPerformed(e);
}
}
编译后有下列错误,大侠能否帮我改一下:已在源程序中注明错处
error1:"seqchooser.java": Error #: 300 : class ListSelectionListener not found in class seqanalysis.seqchooser.ChoiceListener at line 59, column 35
error2:"seqchooser.java": Error #: 300 : constructor ChoiceListener() not found in class seqanalysis.seqchooser.ChoiceListener at line 25, column 41
error3:"seqchooser.java": Error #: 300 : method addListSelectionListener(seqanalysis.seqchooser.ChoiceListener) not found in class javax.swing.JList at line 55, column 12
|
再加上
import javax.swing.event.*;
import javax.swing.event.*;
您可能感兴趣的文章:
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。