JPopupMenu popup = new JPopupMenu();
JCheckBoxMenuItem showLabelItem = null;
JCheckBoxMenuItem showLampItem = null;
showLabelItem=new JCheckBoxMenuItem("11111");
showLabelItem.addActionListener(showLabel);
showLabelItem.setSelected(false);
popup.add(showLabelItem);
showLampItem = new JCheckBoxMenuItem("22222");
showLampItem.setEnabled(false);
showLampItem.setSelected(false);
showLampItem.addActionListener(showLamp);
popup.add(showLampItem); ActionListener showLamp = new ActionListener() {
public void actionPerformed(ActionEvent e) {
showLamp_actionPerformed();
}
};应该对你有帮助吧。另外你描述的是不大清楚。
JCheckBoxMenuItem showLabelItem = null;
JCheckBoxMenuItem showLampItem = null;
showLabelItem=new JCheckBoxMenuItem("11111");
showLabelItem.addActionListener(showLabel);
showLabelItem.setSelected(false);
popup.add(showLabelItem);
showLampItem = new JCheckBoxMenuItem("22222");
showLampItem.setEnabled(false);
showLampItem.setSelected(false);
showLampItem.addActionListener(showLamp);
popup.add(showLampItem); ActionListener showLamp = new ActionListener() {
public void actionPerformed(ActionEvent e) {
showLamp_actionPerformed();
}
};应该对你有帮助吧。另外你描述的是不大清楚。
解决方案 »
- 学完java基础转向jsp应该不难吧?
- 设计一个含有JPanel的自定义JFrame类,要求JPanel的尺寸为JFrame的一半,并且永远居中
- 还是新手,还是内部类(关于继承内部类)
- 处学者的简单问题。错误:Exception in thread "main" java.lang.NosuchMethodError:main,带原码;
- 一个关于如何在编写JAVA程序时调用方法的菜鸟问题
- 奇怪问题,关于Socket的!
- applet不能正常运行的问题,有请各位大侠。
- 在一个java class中可以调用执行一个exe文件吗?
- JAVA:一个头痛的问题
- JB做的APPLET打包后的JAR文件怎么放到网页中去呀?
- 考 SCJP,想出去兼职有用吗?
- META-INF文件夹是什么东西?怎么生成的?可以删掉吗?
public int getCaretPosition() Returns the position of the text insertion caret for the text component. Returns:
the position of the text insertion caret for the text component >= 0
置上添入数据怎么来?也就是如何捕捉光标位置。
这样说是不是清楚一点。