我想做几个界面。
第一个界面 姓氏 张
李
王 然后第2个界面 名字
张三 张大
李四 李五
王大 王二 张 张三 张大。 这些都是JLabel 然后想每个都设置监听 想来想去 想设置点击,然后就设置鼠标监听 鼠标中有成单击。
然后单击 第一个界面的张 。就弹出第2个界面。点击张三或张大,就弹出第一个界面(可能的话,比如姓氏名字很多,滚动条很长。然后张是在中间,点击张三 或者点击张大 出现第一个界面,而且是屏幕中有张三的这个位置)前辈们 能不能告诉下监听中怎么写吗? 怎么样写可以点击下弹出另一个界面啊?
第一个界面 姓氏 张
李
王 然后第2个界面 名字
张三 张大
李四 李五
王大 王二 张 张三 张大。 这些都是JLabel 然后想每个都设置监听 想来想去 想设置点击,然后就设置鼠标监听 鼠标中有成单击。
然后单击 第一个界面的张 。就弹出第2个界面。点击张三或张大,就弹出第一个界面(可能的话,比如姓氏名字很多,滚动条很长。然后张是在中间,点击张三 或者点击张大 出现第一个界面,而且是屏幕中有张三的这个位置)前辈们 能不能告诉下监听中怎么写吗? 怎么样写可以点击下弹出另一个界面啊?
lbName.addActionListener(new lbClick());
JLabel 没有 ActionListener 监听吧?
import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.*;
import javax.swing.JFrame.*;
public class XueDaoFrame1 extends JPanel{public static void main(String[] args) {
JFrame frame1=new JFrame();
XueDaoFrame1 XDframe1=new XueDaoFrame1();
frame1.getContentPane().add(XDframe1);
frame1.setSize(700,700);
JScrollPane scrollPane=new JScrollPane(XDframe1);
frame1.getContentPane().add(scrollPane,BorderLayout.CENTER);
frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame1.setVisible(true);
}
private JLabel label[] ;
private JCheckBox checkBox;
private ImageIcon imageIcon;
private JTextArea textArea;
private JPanel panel1;
public XueDaoFrame1(){
super();
this.setLayout(new GridLayout(8,3));
label=new JLabel[20];
checkBox=new JCheckBox();
imageIcon=new ImageIcon();
textArea=new JTextArea();
label[10]=new JLabel("xxxxxxxxxxxxxx");
label[10].setFont(new Font("Serif",Font.PLAIN,36));
this.add(label[10]);
label[0]=new JLabel("a");
label[1]=new JLabel("b");
label[2]=new JLabel("c");
label[3]=new JLabel("d");
label[4]=new JLabel("e");
label[5]=new JLabel("f");
label[6]=new JLabel("g");
label[7]=new JLabel("h");
label[8]=new JLabel("j");
label[9]=new JLabel("::");
String Xushu="abcdefg是英文";
textArea.setText(Xushu);
imageIcon=new ImageIcon("images\\XueDao.jpg");
checkBox=new JCheckBox(imageIcon);
this.setLayout(new GridLayout(7,3));
this.add(label[0]);
this.add(textArea);
this.add(checkBox);
this.add(label[1]);
this.add(label[9]);
this.add(label[7]);
this.add(label[2]);
this.add(label[9]);
this.add(label[7]);
this.add(label[3]);
this.add(label[9]);
this.add(label[7]);
this.add(label[4]);
this.add(label[9]);
this.add(label[8]);
this.add(label[5]);
this.add(label[9]);
this.add(label[8]);
this.add(label[6]);
this.add(label[9]);
this.add(label[8]);
}
}
这是我的第一个界面 还没添加监听。 我寓意是8行3列。 然后最后出来的就是6行2列。 是不是一个组件只能用一次啊? 我add了同样的那么多 没效果阿?
用eclipse界面是挺头疼,不能拖拽。