当前位置: 首页>>代码示例>>Java>>正文


Java MouseAdapter类代码示例

本文整理汇总了Java中java.awt.event.MouseAdapter的典型用法代码示例。如果您正苦于以下问题:Java MouseAdapter类的具体用法?Java MouseAdapter怎么用?Java MouseAdapter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MouseAdapter类属于java.awt.event包,在下文中一共展示了MouseAdapter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildTree

import java.awt.event.MouseAdapter; //导入依赖的package包/类
/**
 * 
 */
private void buildTree() {
    DefaultMutableTreeNode root = new DefaultMutableTreeNode("user");
    tree = new JTree(root);
    tree.putClientProperty("JTree.lineStyle", "Angled");
    tree.setCellRenderer(new NavigationTreeCellRenderer());
    tree.setShowsRootHandles(true);
    
    DefaultTreeSelectionModel model = new DefaultTreeSelectionModel();
    model.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    
    graphsCategory = new DefaultMutableTreeNode("graphs");
    
    mouseAdapter = new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            itemSelected(e);
        }
    };
    tree.addMouseListener(mouseAdapter);
    
    root.add(graphsCategory);        
    loadGraphs();
}
 
开发者ID:guilhebl,项目名称:routerapp,代码行数:26,代码来源:NavigationView.java

示例2: WindowNotification

import java.awt.event.MouseAdapter; //导入依赖的package包/类
public WindowNotification() {
	m_window = new JWindow();
	m_window.setAlwaysOnTop(true);

	m_listener = new MouseAdapter() {
		@Override
		public void mouseClicked(MouseEvent e) {
			fireListeners(CLICKED);
			if (m_closeOnClick)
				removeFromManager();
		}
	};

	setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);
	setPanel(new JPanel());
}
 
开发者ID:OwaNotifier,项目名称:owa-notifier,代码行数:17,代码来源:WindowNotification.java

示例3: prepareControls

import java.awt.event.MouseAdapter; //导入依赖的package包/类
@Override
protected void prepareControls() {


    JDesktopPane desktopPane = new JDesktopPane();

    JInternalFrame bottomFrame = new JInternalFrame("bottom frame", false, false, false, false);
    bottomFrame.setSize(220, 220);
    super.propagateAWTControls(bottomFrame);
    desktopPane.add(bottomFrame);
    bottomFrame.setVisible(true);

    JInternalFrame topFrame = new JInternalFrame("top frame", false, false, false, false);
    topFrame.setSize(200, 200);
    topFrame.add(new JButton("LW Button") {

        {
            addMouseListener(new MouseAdapter() {

                @Override
                public void mouseClicked(MouseEvent e) {
                    lwClicked = true;
                }
            });
        }
    });
    desktopPane.add(topFrame);
    topFrame.setVisible(true);

    JFrame frame = new JFrame("Test Window");
    frame.setSize(300, 300);
    frame.setContentPane(desktopPane);
    frame.setVisible(true);

    locTopFrame = topFrame.getLocationOnScreen();
    locTarget = new Point(locTopFrame.x + bottomFrame.getWidth() / 2, locTopFrame.y + bottomFrame.getHeight()/2);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:38,代码来源:JInternalFrameMoveOverlapping.java

示例4: ClassSelector

import java.awt.event.MouseAdapter; //导入依赖的package包/类
public ClassSelector(Comparator<ClassEntry> comparator) {
	m_comparator = comparator;
	
	// configure the tree control
	setRootVisible(false);
	setShowsRootHandles(false);
	setModel(null);
	
	// hook events
	addMouseListener(new MouseAdapter() {
		@Override
		public void mouseClicked(MouseEvent event) {
			if (m_listener != null && event.getClickCount() == 2) {
				// get the selected node
				TreePath path = getSelectionPath();
				if (path != null && path.getLastPathComponent() instanceof ClassSelectorClassNode) {
					ClassSelectorClassNode node = (ClassSelectorClassNode)path.getLastPathComponent();
					m_listener.onSelectClass(node.getClassEntry());
				}
			}
		}
	});
	
	// init defaults
	m_listener = null;
}
 
开发者ID:cccssw,项目名称:enigma-vk,代码行数:27,代码来源:ClassSelector.java

示例5: addMouseListenerToHeaderInTable

import java.awt.event.MouseAdapter; //导入依赖的package包/类
public void addMouseListenerToHeaderInTable(JTable table) { 
    final TableSorter sorter = this; 
    final JTable tableView = table; 
    tableView.setColumnSelectionAllowed(false); 
    MouseAdapter listMouseListener = new MouseAdapter() {
        boolean ascending = false;
        public void mouseClicked(MouseEvent e) {
            TableColumnModel columnModel = tableView.getColumnModel();
            int viewColumn = columnModel.getColumnIndexAtX(e.getX()); 
            int column = tableView.convertColumnIndexToModel(viewColumn); 
            if (e.getClickCount() == 1 && column != -1) {
                //System.out.println("Sorting ..."); 
                //int shiftPressed = e.getModifiers()&InputEvent.SHIFT_MASK; 
                //boolean ascending = (shiftPressed == 0);
                if (column == sortBy)                    
                    ascending = !ascending;
                else
                    ascending = true; 
                sorter.sortByColumn(column, ascending);   
                tableView.getTableHeader().updateUI();                  
            }
        }
    };
    JTableHeader th = tableView.getTableHeader(); 
    th.addMouseListener(listMouseListener); 
}
 
开发者ID:ser316asu,项目名称:Neukoelln_SER316,代码行数:27,代码来源:TableSorter.java

示例6: WhatIfPlot

import java.awt.event.MouseAdapter; //导入依赖的package包/类
public WhatIfPlot(double[] xAxis) {
	super();
	this.xAxis = xAxis;
	// Adds popup menu
	this.addMouseListener(new MouseAdapter() {
		/**
		 * Invoked when the mouse has been clicked on a component.
		 */
		@Override
		public void mouseClicked(MouseEvent e) {
			if (e.getButton() == MouseEvent.BUTTON3) {
				popup.show(WhatIfPlot.this, e.getX(), e.getY());
			}
		}
	});
}
 
开发者ID:HOMlab,项目名称:QN-ACTR-Release,代码行数:17,代码来源:WhatIfPlot.java

示例7: addChoice

import java.awt.event.MouseAdapter; //导入依赖的package包/类
public void addChoice(final String key, String displayText)
{
	final JRadioButton rb = new JRadioButton(displayText);
	if( doubleClickToSelect )
	{
		rb.addMouseListener(new MouseAdapter()
		{
			@Override
			public void mouseClicked(MouseEvent e)
			{
				if( e.getClickCount() >= 2 )
				{
					addClicked(key);
				}
			}
		});
	}

	choices.addButton(rb, key);

	// Add after the instructions label and any existing choices
	add(rb, choices.size());
}
 
开发者ID:equella,项目名称:Equella,代码行数:24,代码来源:AbstractChoiceDialog.java

示例8: simpleFiller

import java.awt.event.MouseAdapter; //导入依赖的package包/类
private Box.Filler simpleFiller() {
    Box.Filler filler = new Box.Filler(
            new java.awt.Dimension(10, 0),
            new java.awt.Dimension(10, 0),
            new java.awt.Dimension(10, 32767));

    filler.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseEntered(MouseEvent me) {
            setGlassPane(docker);
            SwingUtilities.invokeLater(() -> {
                getGlassPane().setVisible(true);
            });
        }

    });
    return filler;
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:20,代码来源:AppMainFrame.java

示例9: JCheckBoxList

import java.awt.event.MouseAdapter; //导入依赖的package包/类
public JCheckBoxList() {
  setCellRenderer(new CellRenderer());
  addMouseListener(new MouseAdapter() {
    @Override
    public void mousePressed(MouseEvent e) {
      int index = locationToIndex(e.getPoint());
      if (index != -1) {
        JCheckBox checkbox = getModel().getElementAt(index);

        if (e.getPoint().x < checkbox.getHorizontalTextPosition()) {

          checkbox.setSelected(!checkbox.isSelected());
        }
        repaint();
      }
    }
  });
  setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
}
 
开发者ID:gurkenlabs,项目名称:litiengine,代码行数:20,代码来源:JCheckBoxList.java

示例10: showModalDialog

import java.awt.event.MouseAdapter; //导入依赖的package包/类
private static void showModalDialog(Frame targetFrame) {

        Dialog dialog = new Dialog(targetFrame, true);

        dialog.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseClicked(MouseEvent e) {
                passed = true;
                dialog.dispose();
            }
        });

        dialog.setSize(400, 300);
        dialog.setTitle("Modal Dialog!");

        clickOnModalDialog(dialog);
        dialog.setVisible(true);
    }
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:20,代码来源:MissingEventsOnModalDialogTest.java

示例11: initialize

import java.awt.event.MouseAdapter; //导入依赖的package包/类
/**
 * Initialize the contents of the frame.
 */
private void initialize() {
	frame = new JFrame();
	frame.setBounds(100, 100, 800, 450);
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	frame.getContentPane().setLayout(null);

	final JButton btnNewButton = new JButton("\u62CD\u7167");
	btnNewButton.addMouseListener(new MouseAdapter() {
		@Override
		public void mouseClicked(MouseEvent arg0) {
			flag = 1;// ��̬��������Ϊ1���Ӷ����°�ťʱ��ֹͣ����ͷ�ĵ���
		}
	});
	btnNewButton.setBounds(33, 13, 113, 27);
	frame.getContentPane().add(btnNewButton);

	label = new JLabel("");
	label.setBounds(0, 0, 800, 450);
	frame.getContentPane().add(label);
}
 
开发者ID:zylo117,项目名称:SpotSpotter,代码行数:24,代码来源:CameraShot.java

示例12: buildList

import java.awt.event.MouseAdapter; //导入依赖的package包/类
/**
 * Creates the process list
 *
 * @return JComponent
 */
private JComponent buildList() {
    list = new JList<>();
    list.setCellRenderer(new CellRenderer(list.getCellRenderer()));
    list.setTransferHandler(new ProcessTransferHandler());
    list.setDragEnabled(true);
    list.setDropMode(DropMode.ON_OR_INSERT);
    list.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent e) {
            if (e.getClickCount() % 2 == 0) {
                ProcessInformationPane.showDialog(list.getSelectedValue());
            }
        }
    });
    return ScrollFactory.pane(list).create();
}
 
开发者ID:VISNode,项目名称:VISNode,代码行数:22,代码来源:ProcessBrowser.java

示例13: BusyGlassPane

import java.awt.event.MouseAdapter; //导入依赖的package包/类
/**
 * GlassPane constructor comment.
 * 
 * @param Container a
 */
protected BusyGlassPane(Component activeComponent, boolean stopClosing)
{
	this.stopClosing = stopClosing;

	// add adapters that do nothing for keyboard and mouse actions
	addMouseListener(new MouseAdapter()
	{
		// We don't care about any events
	});

	addKeyListener(new KeyAdapter()
	{
		// We don't care about any events
	});

	setActiveComponent(activeComponent);
}
 
开发者ID:equella,项目名称:Equella,代码行数:23,代码来源:BusyGlassPane.java

示例14: initTestWindow

import java.awt.event.MouseAdapter; //导入依赖的package包/类
public static void initTestWindow() {
    mainFrame = new Frame();
    mainFrame.setTitle("TestWindow");
    mainFrame.setBounds(700, 10, 300, 300);
    mainFrame.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent e) {
            int ex = e.getModifiersEx();
            if ((ex & InputEvent.ALT_GRAPH_DOWN_MASK) == 0) {
                AltGraphModifierTest.fail("Alt-Gr Modifier bit is not set.");
            } else {
                AltGraphModifierTest.pass();
            }
        }
    });
    mainFrame.setVisible(true);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:AltGraphModifierTest.java

示例15: HyperlinkLabel

import java.awt.event.MouseAdapter; //导入依赖的package包/类
/**
 * Constructor
 */
public HyperlinkLabel() {
	super();
	setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

	setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0));
	addMouseListener(new MouseAdapter() {
		@Override
		public void mouseClicked(final MouseEvent evt) {
			if (_url != null) {
				Util.browse(_url, getText());
			}
		}
	});
	setForeground(Color.BLUE);
}
 
开发者ID:leolewis,项目名称:openvisualtraceroute,代码行数:19,代码来源:HyperlinkLabel.java


注:本文中的java.awt.event.MouseAdapter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。