谢谢!!!
解决方案 »
- 请问内部类有哪些作用
- jdbtable连接显示MySQL上面的表时怎么无法显示完整时间的值(时间包括年月日时分秒)
- java 的最小化到托盘
- 怎么样输出这种格式的日期的字符串呀?“2007-04-05"
- 请问大家现在一般用什么工具进行UML建模?要比较流行的和容易使用的
- Java做ERP合适吗?Java主要用在什么方面?
- 如何确定FILE类型,是PLAIN TEXT还是BINARY的
- SimpleDateFormat中的parse怎么用?
- 进入!来者有分!
- java通过jna调用c++/c的.dll/.so动态库
- 我不准备使用JBuilder ,那么JCreator和Eclipse那个更好
- 在java中怎么向串口发送回车符号?
Menu file = new Menu("file");
MenuItem add = new MenuItem("add");
MenuItem delete = new MenuItem("delete");
pop.add(file);
file.add(add);
file.add(delete);一般都是这么用你再加个鼠标监听让它响应右键事件时show一下就OK啦
Exception occurred during event dispatching:
java.lang.NullPointerException: parent is nu
at java/awt/PopupMenu.show
at FTable.actionPerformed
at java/awt/Button.processActionEven
at java/awt/Button.processEvent
at java/awt/Component.dispatchEventI
at java/awt/Component.dispatchEvent
at java/awt/EventDispatchThread.runAPI中说Shows the popup menu at the x, y position relative to an origin component. The origin component must be contained within the component hierarchy of the popup menu's parent. Both the origin and the parent must be showing on the screen for this method to be valid.我虽然看懂了,却不知错再哪,
import java.awt.event.*;class test2 extends Frame implements ActionListener
{Button b;
public test2()
{super("Welcome"); b=new Button("test");
b.addActionListener(this); add(b,"Center"); pack();setVisible(true);
}
public void actionPerformed(ActionEvent e)
{String s=e.getActionCommand();
if(s.equals("test"))
{
PopupMenu pop = new PopupMenu();
Menu file = new Menu("file");
MenuItem add = new MenuItem("add");
MenuItem delete = new MenuItem("delete");
pop.add(file);
file.add(add);
file.add(delete);
pop.show(b,0,0); }
}
public static void main(String args[])
{test2 t=new test2(); }
}