當前位置: 首頁>>代碼示例>>Java>>正文


Java JPanel.addMouseListener方法代碼示例

本文整理匯總了Java中javax.swing.JPanel.addMouseListener方法的典型用法代碼示例。如果您正苦於以下問題:Java JPanel.addMouseListener方法的具體用法?Java JPanel.addMouseListener怎麽用?Java JPanel.addMouseListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.JPanel的用法示例。


在下文中一共展示了JPanel.addMouseListener方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: MouseTrackerFrame

import javax.swing.JPanel; //導入方法依賴的package包/類
public MouseTrackerFrame()
{
   super("Demonstrating Mouse Events");

   mousePanel = new JPanel(); 
   mousePanel.setBackground(Color.WHITE); 
   add(mousePanel, BorderLayout.CENTER); // add panel to JFrame

   statusBar = new JLabel("Mouse outside JPanel"); 
   add(statusBar, BorderLayout.SOUTH); // add label to JFrame

   // create and register listener for mouse and mouse motion events
   MouseHandler handler = new MouseHandler(); 
   mousePanel.addMouseListener(handler); 
   mousePanel.addMouseMotionListener(handler); 
}
 
開發者ID:cleitonferreira,項目名稱:LivroJavaComoProgramar10Edicao,代碼行數:17,代碼來源:MouseTrackerFrame.java

示例2: getPanel

import javax.swing.JPanel; //導入方法依賴的package包/類
/**
 * set up the thumb image UI
 *
 * @param f
 * @return
 */
JPanel getPanel(final String f) {
    setThumbImage(f);
    JPanel p = new JPanel() {
        @Override
        public void paintComponent(Graphics g) {
            g.drawImage(thumbs.get(f), 0, 0, null);
        }
    };
    p.setPreferredSize(THUMB_SIZE);
    p.setBorder(new LineBorder(Color.LIGHT_GRAY, 3));
    JComponent c = getThumbSelector(f);
    JComponent cl = setupThumbClose(p);
    setupAlignment(p, c, cl);
    p.setName(f);
    p.addMouseListener(thumbselected);
    p.addMouseListener(Listeners.thumbPrevFocus);
    thumbList.add(p);
    return p;
}
 
開發者ID:CognizantQAHub,項目名稱:Cognizant-Intelligent-Test-Scripter,代碼行數:26,代碼來源:ImageGallery.java

示例3: setupGlassPane

import javax.swing.JPanel; //導入方法依賴的package包/類
protected void setupGlassPane(JPanel glassPane) {
    this.glassPane = glassPane;
    if (mouse != null) {
        glassPane.addMouseListener(mouse);
        if (enableInteraction) {
            glassPane.addMouseMotionListener(mouse);
        }
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:10,代碼來源:ComponentDetailsProvider.java

示例4: createCentre

import javax.swing.JPanel; //導入方法依賴的package包/類
private JComponent createCentre()
{
	dayGrid = new JPanel(new GridLayout(7, 7, 5, 5));
	dayGrid.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1));
	dayGrid.setBackground(Color.WHITE);
	dayGrid.addMouseListener(this);

	Map<TextAttribute, Float> dayAttributes = new HashMap<TextAttribute, Float>();
	dayAttributes.put(TextAttribute.WEIGHT, TextAttribute.WEIGHT_BOLD);
	Font dayFont = new Font(dayAttributes);

	for( int i = 0; i < DAYS.length; i++ )
	{
		JLabel day = new JLabel(DAYS[i]);
		day.setHorizontalAlignment(SwingConstants.CENTER);
		day.setVerticalAlignment(SwingConstants.CENTER);
		day.setFont(dayFont);

		dayGrid.add(day);
	}

	days = new DayLabel[6][7];
	for( int i = 0; i < days.length; i++ )
	{
		for( int j = 0; j < days[i].length; j++ )
		{
			days[i][j] = new DayLabel();
			days[i][j].setDay(0);
			dayGrid.add(days[i][j]);
		}
	}

	return dayGrid;
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:35,代碼來源:JCalendar.java


注:本文中的javax.swing.JPanel.addMouseListener方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。