zoukankan      html  css  js  c++  java
  • JAVA菜单事件

    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    public class MenuFrame extends JFrame{
    	public static final int default_width=300;
    	public static final int default_height=200;
    	public MenuFrame(){
        setTitle("弹出菜单测试");
        setSize(default_width,default_height);
        final JPopupMenu popup;
        popup=new JPopupMenu();
        JMenuItem item=new JMenuItem("请单击");
        item.addActionListener(new ActionListener(){
        	public void actionPerformed(ActionEvent e)
        	{JOptionPane.showMessageDialog(MenuFrame.this,"大家好","提示对话框",1);
        	}
        	});
        popup.add(item);
        getContentPane().addMouseListener(new MouseAdapter(){
        	public void mousePressed(MouseEvent event)
        	{
        		if(event.isPopupTrigger())
        		popup.show(event.getComponent(),event.getX(),event.getY());
        	}
        	public void mouseReleased(MouseEvent event)
        	{
        		if(event.isPopupTrigger())
        			popup.show(event.getComponent(),event.getX(),event.getY());
        	}
        });
    	}
    	
    
    	
    	@SuppressWarnings("deprecation")
    	public static void main(String[] args) {
    	 MenuFrame frame=new MenuFrame();
    	 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    	 frame.show();
    	}
    
    }
    
  • 相关阅读:
    视差滚动(Parallax Scrolling)插件补充
    10个最佳的触控手式的JavaScript框架(转)
    50个必备的实用jQuery代码段(转)
    PhoneGap开发不可或缺的五件装备
    优化移动网站的9大窍门(转)
    WSADATA
    htons
    INADDR_ANY
    SOCKADDR_IN
    mysql_query()与mysql_real_query()
  • 原文地址:https://www.cnblogs.com/canyangfeixue/p/2474037.html
Copyright © 2011-2022 走看看